프로젝트

일반

사용자정보

개정판 e69a3fd8

IDe69a3fd829263403a5d20d9e5ac01025e0fcb05d
상위 edc395e4
하위 d1e76237, ce619e52

김연진이(가) 약 5년 전에 추가함

issue #1201 : 2 Phase 계산식

Change-Id: I290d1497cbca2b13acb086909465d2bb9613dd43

차이점 보기:

HYTOS/HYTOS/AppDocData.py
21 21
import symbol
22 22
from NominalPipeSize import NominalPipeSize
23 23

  
24

  
24 25
class Source:
25 26
    def __init__(self, source):
26 27
        if type(source) is np.ndarray:
......
31 32
            self.source = Image.fromqimage(source)
32 33
        elif type(source) is QPixmap:
33 34
            self.source = Image.fromqpixmap(source)
34
        
35

  
35 36
    '''
36 37
        @history    2018.05.18  Jeongwoo    When Parameter [rect] is None, return whole image
37 38
    '''
38
    def getPyImageOnRect(self, rect = None):
39

  
40
    def getPyImageOnRect(self, rect=None):
39 41
        if rect is not None:
40 42
            return self.source.copy().crop((rect.left(), rect.top(), rect.right(), rect.bottom()))
41 43
        else:
42 44
            return self.source.copy()
43 45

  
44
    def getQImageOnRect(self, rect = None):
46
    def getQImageOnRect(self, rect=None):
45 47
        image = ImageQt(self.getPyImageOnRect(rect))
46 48
        return image.convertToFormat(QImage.Format_RGBA8888)
47 49

  
50

  
48 51
class Config:
49 52
    def __init__(self, section, key, value):
50 53
        self.section = section
51 54
        self.key = key
52 55
        self.value = value
53 56

  
54
    
57

  
55 58
'''
56 59
    @brief      MessageType
57 60
    @author     humkyung 
58 61
    @date       2018.07.31
59 62
'''
63

  
64

  
60 65
class MessageType(Enum):
61 66
    Normal = 1
62 67
    Error = 2
63 68
    Information = 3
64 69

  
70

  
65 71
class AppDocData(SingletonInstane):
66
    
72

  
67 73
    def __init__(self):
68
        
74

  
69 75
        self._imgFilePath = None
70 76
        self.imgName = None
71 77
        self.imgWidth = 0
......
112 118
        @author     humkyung
113 119
        @date       2018.09.06
114 120
    '''
121

  
115 122
    def clear(self):
116 123
        self._imgFilePath = None
117 124
        self.imgName = None
......
139 146
        @date       2018.06.27
140 147
        @history    2018.06.29  Jeongwoo    Change method to get template db path
141 148
    '''
149

  
142 150
    def getTemplateDbPath(self):
143 151
        path = os.path.join(os.getenv('ALLUSERSPROFILE'), App.NAME)
144 152
        templateDbPath = os.path.join(path, 'Template.db')
......
155 163
                cursor.execute(sql)
156 164
                rows = cursor.fetchall()
157 165
                for row in rows:
158
                    symbolCategoryList.append((row[0])) 
166
                    symbolCategoryList.append((row[0]))
159 167
            except Exception as ex:
160 168
                from App import App
161
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
169
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
170
                                                               sys.exc_info()[-1].tb_lineno)
162 171
                App.mainWnd().addMessage.emit(MessageType.Error, message)
163 172

  
164 173
        return symbolCategoryList
......
176 185
                cursor.execute(sql, param)
177 186
                rows = cursor.fetchall()
178 187
                for row in rows:
179
                    symbolCategoryList.append((row[0], row[1])) 
188
                    symbolCategoryList.append((row[0], row[1]))
180 189
            except Exception as ex:
181 190
                from App import App
182
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
191
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
192
                                                               sys.exc_info()[-1].tb_lineno)
183 193
                App.mainWnd().addMessage.emit(MessageType.Error, message)
184 194

  
185 195
        return symbolCategoryList
186 196

  
187

  
188 197
    def updateTemplateSymbol(self, uid, originalPoint, connectionPoint):
189 198
        isUpdated = False
190 199

  
......
209 218
            # Roll back any change if something goes wrong
210 219
            conn.rollback()
211 220

  
212
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
221
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
222
                                                           sys.exc_info()[-1].tb_lineno)
213 223
            App.mainWnd().addMessage.emit(MessageType.Error, message)
214 224
        finally:
215 225
            # Close the db connection
......
229 239
                cursor.execute(sql, param)
230 240
                rows = cursor.fetchall()
231 241
                for row in rows:
232
                    symbolList.append((row[0], row[1], row[2], row[3])) 
242
                    symbolList.append((row[0], row[1], row[2], row[3]))
233 243
            except Exception as ex:
234 244
                from App import App
235
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
245
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
246
                                                               sys.exc_info()[-1].tb_lineno)
236 247
                App.mainWnd().addMessage.emit(MessageType.Error, message)
237 248

  
238 249
        return symbolList
......
250 261
                cursor.execute(sql, param)
251 262
                rows = cursor.fetchall()
252 263
                for row in rows:
253
                    symbolCategoryList.append((row[0], row[1])) 
264
                    symbolCategoryList.append((row[0], row[1]))
254 265
            except Exception as ex:
255 266
                from App import App
256
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
267
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
268
                                                               sys.exc_info()[-1].tb_lineno)
257 269
                App.mainWnd().addMessage.emit(MessageType.Error, message)
258 270

  
259 271
        return symbolCategoryList
260 272

  
261

  
262 273
    def getAppDbPath(self):
263 274
        """
264 275
        @brief      Get application DB file path in ProgramData
......
268 279

  
269 280
        path = os.path.join(os.getenv('ALLUSERSPROFILE'), App.NAME)
270 281
        app_database = os.path.join(path, 'App.db')
271
        return app_database 
282
        return app_database
272 283

  
273 284
    '''
274 285
        @brief  build application database
275 286
        @author humkyung
276 287
        @date   2018.04.20
277 288
    '''
289

  
278 290
    def buildAppDatabase(self):
279 291
        try:
280 292
            path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'HYTOS')
......
305 317
            # Roll back any change if something goes wrong
306 318
            conn.rollback()
307 319

  
308
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
320
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
321
                                                           sys.exc_info()[-1].tb_lineno)
309 322
            App.mainWnd().addMessage.emit(MessageType.Error, message)
310 323

  
311 324
    '''
......
313 326
        @author humkyung
314 327
        @date   2018.04.20
315 328
    '''
329

  
316 330
    def loadAppStyle(self):
317 331
        style = 'Fusion'
318 332

  
319 333
        self.buildAppDatabase()
320 334

  
321 335
        return style
322
        
336

  
323 337
    @property
324 338
    def border_file_path(self):
325 339
        """ return border file path """
......
345 359
                # Get a cursor object
346 360
                cursor = conn.cursor()
347 361

  
348
                sql = "select UID, Material, Meter, Inch, Feet, Milimeter from Roughness" 
362
                sql = "select UID, Material, Meter, Inch, Feet, Milimeter from Roughness"
349 363
                cursor.execute(sql)
350 364
                rows = cursor.fetchall()
351
                for row in rows:                
365
                for row in rows:
352 366
                    res.append((row[0], row[1], row[2], row[3], row[4], row[5]))
353 367
            # Catch the exception
354 368
            except Exception as ex:
......
356 370
                # Roll back any change if something goes wrong
357 371
                conn.rollback()
358 372

  
359
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
373
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
374
                                                               sys.exc_info()[-1].tb_lineno)
360 375
                App.mainWnd().addMessage.emit(MessageType.Error, message)
361 376

  
362 377
        return res
......
379 394
            param = (nominaldiameter_uid, schedule_uid)
380 395
            cursor.execute(sql, param)
381 396
            rows = cursor.fetchall()
382
            for row in rows:                
397
            for row in rows:
383 398
                res.append((row[0], row[1], row[2]))
384 399
        # Catch the exception
385 400
        except Exception as ex:
......
387 402
            # Roll back any change if something goes wrong
388 403
            conn.rollback()
389 404

  
390
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
405
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
406
                                                           sys.exc_info()[-1].tb_lineno)
391 407
            App.mainWnd().addMessage.emit(MessageType.Error, message)
392 408
        finally:
393 409
            # Close the db connection
......
405 421
                # Get a cursor object
406 422
                cursor = conn.cursor()
407 423

  
408
                sql = "select UID, No from Schedule" 
424
                sql = "select UID, No from Schedule"
409 425
                cursor.execute(sql)
410 426
                rows = cursor.fetchall()
411
                for row in rows:                
427
                for row in rows:
412 428
                    res.append((row[0], row[1]))
413 429
            # Catch the exception
414 430
            except Exception as ex:
......
416 432
                # Roll back any change if something goes wrong
417 433
                conn.rollback()
418 434

  
419
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
435
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
436
                                                               sys.exc_info()[-1].tb_lineno)
420 437
                App.mainWnd().addMessage.emit(MessageType.Error, message)
421 438
        return res
422 439

  
......
449 466
                App.mainWnd().addMessage.emit(MessageType.Error, message)
450 467
        return res
451 468

  
452
    def getNominalDiameter(self):        
469
    def getNominalDiameter(self):
453 470
        res = []
454 471

  
455 472
        # Creates or opens a file called mydb with a SQLite3 DB
......
460 477
                # Get a cursor object
461 478
                cursor = conn.cursor()
462 479

  
463
                sql = "select UID, Milimeter, Inch from NominalDiameter" 
480
                sql = "select UID, Milimeter, Inch from NominalDiameter"
464 481
                cursor.execute(sql)
465 482
                rows = cursor.fetchall()
466
                for row in rows:                
483
                for row in rows:
467 484
                    res.append((row[0], row[1], row[2]))
468 485
            # Catch the exception
469 486
            except Exception as ex:
......
472 489
                # Roll back any change if something goes wrong
473 490
                conn.rollback()
474 491

  
475
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
492
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
493
                                                               sys.exc_info()[-1].tb_lineno)
476 494
                App.mainWnd().addMessage.emit(MessageType.Error, message)
477 495
        return res
478 496

  
479
    
480 497
    def getAppConfigs(self, section, key=None):
481 498
        """
482 499
            @brief  get application configurations
......
511 528
            # Roll back any change if something goes wrong
512 529
            conn.rollback()
513 530

  
514
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
531
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
532
                                                           sys.exc_info()[-1].tb_lineno)
515 533
            App.mainWnd().addMessage.emit(MessageType.Error, message)
516 534
        finally:
517 535
            # Close the db connection
......
549 567
        # Catch the exception
550 568
        except Exception as ex:
551 569
            from App import App
552
            
570

  
553 571
            # Roll back any change if something goes wrong
554 572
            conn.rollback()
555 573

  
556
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
574
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
575
                                                           sys.exc_info()[-1].tb_lineno)
557 576
            App.mainWnd().addMessage.emit(MessageType.Error, message)
558 577
        finally:
559 578
            # Close the db connection
......
592 611
            # Roll back any change if something goes wrong
593 612
            conn.rollback()
594 613

  
595
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
614
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
615
                                                           sys.exc_info()[-1].tb_lineno)
596 616
            App.mainWnd().addMessage.emit(MessageType.Error, message)
597 617
        finally:
598 618
            # Close the db connection
......
628 648
            # Roll back any change if something goes wrong
629 649
            conn.rollback()
630 650

  
631
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
651
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
652
                                                           sys.exc_info()[-1].tb_lineno)
632 653
            App.mainWnd().addMessage.emit(MessageType.Error, message)
633 654
        finally:
634 655
            # Close the db connection
......
643 664
            cursor = conn.cursor()
644 665

  
645 666
            sql = "delete from Components"
646
            cursor.execute(sql)            
647
            
667
            cursor.execute(sql)
668

  
648 669
            conn.commit()
649 670
        # Catch the exception
650 671
        except Exception as ex:
651 672
            from App import App
652 673
            # Roll back any change if something goes wrong
653 674
            conn.rollback()
654
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
675
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
676
                                                           sys.exc_info()[-1].tb_lineno)
655 677
            App.mainWnd().addMessage.emit(MessageType.Error, message)
656 678
        finally:
657 679
            # Close the db connection
......
669 691
                sql = 'delete from Drawings where Name=?'
670 692
                param = (drawingName,)
671 693
                cursor.execute(sql, param)
672
                
694

  
673 695
                conn.commit()
674 696
            # Catch the exception
675 697
            except Exception as ex:
......
677 699
                # Roll back any change if something goes wrong
678 700
                conn.rollback()
679 701

  
680
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
702
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
703
                                                               sys.exc_info()[-1].tb_lineno)
681 704
                App.mainWnd().addMessage.emit(MessageType.Error, message)
682
    
705

  
683 706
    def deleteAppConfigs(self, section, key=None):
684 707
        """
685 708
        @brief  delete application configurations
......
709 732
            # Roll back any change if something goes wrong
710 733
            conn.rollback()
711 734

  
712
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
735
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
736
                                                           sys.exc_info()[-1].tb_lineno)
713 737
            App.mainWnd().addMessage.emit(MessageType.Error, message)
714 738
        finally:
715 739
            # Close the db connection
716 740
            conn.close()
717
   
741

  
718 742
    '''
719 743
        @brief  get symbol name
720 744
        @history    18.04.24    Jeongwoo    Add isExceptDetect Field
721 745
    '''
746

  
722 747
    def getSymbolByQuery(self, fieldName, param):
723 748
        ret = None
724 749

  
......
743 768
                rows = cursor.fetchall()
744 769
                if rows is not None and len(rows) > 0:
745 770
                    symbolTuple = rows[0]
746
                    ret = symbol.SymbolBase(symbolTuple[0], symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4], symbolTuple[5]) 
771
                    ret = symbol.SymbolBase(symbolTuple[0], symbolTuple[1], symbolTuple[2], symbolTuple[3],
772
                                            symbolTuple[4], symbolTuple[5])
747 773
            except Exception as ex:
748 774
                from App import App
749 775

  
750
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
776
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
777
                                                               sys.exc_info()[-1].tb_lineno)
751 778
                App.mainWnd().addMessage.emit(MessageType.Error, message)
752 779

  
753 780
        return ret
......
760 787
        conn.execute('PRAGMA foreign_keys = ON')
761 788
        with conn:
762 789
            cursor = conn.cursor()
763
            
790

  
764 791
            sql = """select s.UID
765 792
                            , s.Name
766 793
                            , t.Category
......
771 798
                        inner join SymbolType t
772 799
                            on s.SymbolType_UID = t.uid 
773 800
                        where s.SymbolType_UID = ?"""
774
            
801

  
775 802
            try:
776 803
                cursor.execute(sql, (uid,))
777 804
                rows = cursor.fetchall()
778 805
                if rows is not None and len(rows) > 0:
779 806
                    for row in rows:
780 807
                        sym = symbol.SymbolBase(row[0], row[1], row[2], row[3], row[4], row[5])
781
                                                
808

  
782 809
                        ret.append(sym)
783 810
            except Exception as ex:
784 811
                from App import App
785 812

  
786
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
813
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
814
                                                               sys.exc_info()[-1].tb_lineno)
787 815
                App.mainWnd().addMessage.emit(MessageType.Error, message)
788 816

  
789 817
        return ret
790 818

  
819
    def get_fittings_input(self, uid):
820
        res = []
821
        try:
822
            # Creates or opens a file called mydb with a SQLite3 DB
823
            dbPath = os.path.join(self.activeDrawing.path)
824
            conn = sqlite3.connect(dbPath)
825
            conn.execute('PRAGMA foreign_keys = ON')
826
            conn.row_factory = sqlite3.Row
827
            # Get a cursor object
828
            cursor = conn.cursor()
829

  
830
            sql = """select Fittings_UID
831
                          , Method
832
                          , Sub_Size
833
                          , Angle
834
                          , Count
835
                       from Fittings_Input
836
                      where Components_UID = ?
837
                      order by rowid"""
838

  
839
            param = (uid,)
840
            cursor.execute(sql, param)
841
            rows = cursor.fetchall()
842
            for row in rows:
843
                res.append((row[0], row[1], row[2], row[3], row[4]))
844
        # Catch the exception
845
        except Exception as ex:
846
            from App import App
847

  
848
            # Roll back any change if something goes wrong
849
            conn.rollback()
850

  
851
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
852
                                                           sys.exc_info()[-1].tb_lineno)
853
            App.mainWnd().addMessage.emit(MessageType.Error, message)
854

  
855
        finally:
856
            # Close the db connection
857
            conn.close()
858

  
859
        return res
860

  
861
    def get_fittings_by_uid(self, uid):
862
        res = None
863
        try:
864
            # Creates or opens a file called mydb with a SQLite3 DB
865
            dbPath = os.path.join(self.activeDrawing.path)
866
            conn = sqlite3.connect(dbPath)
867
            conn.execute('PRAGMA foreign_keys = ON')
868
            conn.row_factory = sqlite3.Row
869
            # Get a cursor object
870
            cursor = conn.cursor()
871

  
872
            sql = """select UID
873
                          , Method
874
                          , Category
875
                          , Type
876
                          , Name
877
                          , K 
878
                          , Image
879
                       from Fittings 
880
                      where UID = ?
881
                      order by rowid"""
791 882

  
792
    def getResistanceCoefficientByMethod(self, method):
883
            param = (uid,)
884
            cursor.execute(sql, param)
885
            rows = cursor.fetchall()
886
            if rows:
887
                res = rows[0]
888
        # Catch the exception
889
        except Exception as ex:
890
            from App import App
891

  
892
            # Roll back any change if something goes wrong
893
            conn.rollback()
894

  
895
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
896
                                                           sys.exc_info()[-1].tb_lineno)
897
            App.mainWnd().addMessage.emit(MessageType.Error, message)
898

  
899
        finally:
900
            # Close the db connection
901
            conn.close()
902

  
903
        return res
904

  
905
    def get_fittings_by_method(self, method):
793 906
        res = []
794 907
        try:
795 908
            # Creates or opens a file called mydb with a SQLite3 DB
......
807 920
                          , Name
808 921
                          , K 
809 922
                          , Image
810
                       from ResistanceCoefficient 
923
                       from Fittings 
811 924
                      where Method = ?
812
                      order by rowid""" 
925
                      order by rowid"""
813 926

  
814 927
            param = (method,)
815 928
            cursor.execute(sql, param)
816 929
            rows = cursor.fetchall()
817
            for row in rows:                
930
            for row in rows:
818 931
                res.append((row[0], row[1], row[2], row[3], row[4], row[5], row[6]))
819 932
        # Catch the exception
820 933
        except Exception as ex:
......
823 936
            # Roll back any change if something goes wrong
824 937
            conn.rollback()
825 938

  
826
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
939
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
940
                                                           sys.exc_info()[-1].tb_lineno)
827 941
            App.mainWnd().addMessage.emit(MessageType.Error, message)
828 942

  
829 943
        finally:
......
837 951
        @author     yjkim
838 952
        @date       2019.08.28
839 953
    '''
954

  
840 955
    def saveToDatabase(self, item, index):
841 956
        """ save given items to database """
842 957
        conn = sqlite3.connect(self.activeDrawing.path, isolation_level=None)
......
850 965
                    # delete Components 
851 966
                    sql = 'delete from Components'
852 967
                    cursor.execute(sql)
853
                
968

  
854 969
                sql = item.toSql()
855 970
                if type(sql) is list:
856 971
                    for item in sql:
......
867 982
                # Roll back any change if something goes wrong
868 983
                conn.rollback()
869 984

  
870
                message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
871
                App.mainWnd().addMessage.emit(MessageType.Error, message)                
985
                message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
986
                                                               sys.exc_info()[-1].tb_lineno)
987
                App.mainWnd().addMessage.emit(MessageType.Error, message)
872 988

  
873
   
874 989
    def getDrawings(self):
875 990
        """
876 991
        @brief      get drawings
......
902 1017
                conn.rollback()
903 1018
                from App import App
904 1019

  
905
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1020
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1021
                                                               sys.exc_info()[-1].tb_lineno)
906 1022
                App.mainWnd().addMessage.emit(MessageType.Error, message)
907 1023

  
908 1024
        return res
......
912 1028
        @author     yeonjin
913 1029
        @date       2019.08.07
914 1030
    '''
1031

  
915 1032
    def updateDrawing(self, drawing):
916 1033
        import uuid
917
        
1034

  
918 1035
        # Creates or opens a file called mydb with a SQLite3 DB
919 1036
        dbPath = self.getAppDbPath()
920 1037
        conn = sqlite3.connect(dbPath)
......
923 1040
            try:
924 1041
                # Get a cursor object
925 1042
                cursor = conn.cursor()
926
                    
1043

  
927 1044
                sql = """update Drawings
928 1045
                            set Name = ?
929 1046
                                , DateTime = ?
......
939 1056
                conn.rollback()
940 1057
                from App import App
941 1058

  
942
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1059
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1060
                                                               sys.exc_info()[-1].tb_lineno)
943 1061
                App.mainWnd().addMessage.emit(MessageType.Error, message)
944 1062

  
945 1063
    '''
......
947 1065
        @author     humkyung
948 1066
        @date       2018.11.03
949 1067
    '''
1068

  
950 1069
    def saveDrawing(self, drawing):
951 1070
        import uuid
952
        from shutil import copyfile       
1071
        from shutil import copyfile
953 1072

  
954 1073
        conn = sqlite3.connect(self.getAppDbPath())
955 1074
        conn.execute('PRAGMA foreign_keys = ON')
......
957 1076
            try:
958 1077
                # Get a cursor object
959 1078
                cursor = conn.cursor()
960
                    
1079

  
961 1080
                sql = 'insert or replace into Drawings(UID, [NAME], [DATETIME]) values(?, ?, ?)'
962 1081
                param = (drawing.UID, drawing.path, drawing.date_time)
963 1082
                cursor.execute(sql, param)
......
971 1090
                conn.rollback()
972 1091
                from App import App
973 1092

  
974
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1093
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1094
                                                               sys.exc_info()[-1].tb_lineno)
975 1095
                App.mainWnd().addMessage.emit(MessageType.Error, message)
976 1096

  
977 1097
    '''
......
979 1099
        @author     yeonjin
980 1100
        @date       19.07.11
981 1101
    '''
1102

  
982 1103
    def getSymbolCategoryList(self):
983 1104
        SymbolCategoryList = []
984 1105

  
......
991 1112
                cursor.execute(sql)
992 1113
                rows = cursor.fetchall()
993 1114
                for row in rows:
994
                    SymbolCategoryList.append((row[0])) # category
1115
                    SymbolCategoryList.append((row[0]))  # category
995 1116
            except Exception as ex:
996 1117
                from App import App
997 1118

  
998
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1119
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1120
                                                               sys.exc_info()[-1].tb_lineno)
999 1121
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1000 1122

  
1001 1123
        return SymbolCategoryList
1002 1124

  
1003

  
1004 1125
    def getComponentByComponentUID(self, uid):
1005 1126
        ComponentList = []
1006 1127

  
......
1010 1131
            try:
1011 1132
                conn.row_factory = sqlite3.Row
1012 1133
                cursor = conn.cursor()
1013
                
1134

  
1014 1135
                sql = """select c.uid
1015 1136
                                , c.Name
1016 1137
                                , c.Symbols_UID
......
1036 1157
                                on s.symboltype_uid = t.uid
1037 1158
                            where c.uid = ?
1038 1159
                            order by p.[Index]"""
1039
                param = (uid,)                      
1160
                param = (uid,)
1040 1161
                cursor.execute(sql, param)
1041 1162
                rows = cursor.fetchall()
1042 1163
                for row in rows:
1043 1164
                    data = []
1044 1165
                    for index in range(len(cursor.description)):
1045 1166
                        data.append(row[index])
1046
                    ComponentList.append(data) # Components_UID
1167
                    ComponentList.append(data)  # Components_UID
1047 1168
            except Exception as ex:
1048 1169
                from App import App
1049 1170

  
1050
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1171
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1172
                                                               sys.exc_info()[-1].tb_lineno)
1051 1173
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1052 1174

  
1053 1175
        return ComponentList
......
1062 1184
        with conn:
1063 1185
            conn.row_factory = sqlite3.Row
1064 1186
            cursor = conn.cursor()
1065
            sql = 'select Pressure, Pressure_Drop, Elevation, Over_Design_CV from Nozzles where Points_UID=?' 
1066
            param = (uid, )
1187
            sql = 'select Pressure, Pressure_Drop, Elevation, Over_Design_CV from Nozzles where Points_UID=?'
1188
            param = (uid,)
1067 1189
            cursor.execute(sql, param)
1068 1190
            rows = cursor.fetchall()
1069 1191
            if rows:
......
1071 1193
                res.parse(rows[0])
1072 1194

  
1073 1195
        return res
1074
    
1196

  
1075 1197
    '''
1076 1198
        @brief      Return Components By DrawingUID
1077 1199
        @author     yeonjin
1078 1200
        @date       19.07.29
1079 1201
    '''
1202

  
1080 1203
    def getComponentListByDrawingUID(self, drawing):
1081 1204
        ComponentList = []
1082 1205

  
......
1090 1213
                cursor.execute(sql)
1091 1214
                rows = cursor.fetchall()
1092 1215
                for row in rows:
1093
                    ComponentList.append((row[0])) # Components_UID
1216
                    ComponentList.append((row[0]))  # Components_UID
1094 1217
            except Exception as ex:
1095 1218
                from App import App
1096 1219

  
1097
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1220
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1221
                                                               sys.exc_info()[-1].tb_lineno)
1098 1222
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1099 1223

  
1100 1224
        return ComponentList
......
1104 1228
        @author     yeonjin
1105 1229
        @date       19.07.11
1106 1230
    '''
1231

  
1107 1232
    def getSymbolTypeListByCategory(self, category):
1108 1233
        symbolTypeList = []
1109 1234

  
......
1116 1241
                cursor.execute(sql)
1117 1242
                rows = cursor.fetchall()
1118 1243
                for row in rows:
1119
                    symbolTypeList.append((row[0], row[1], row[2])) # UID, Category, Type
1244
                    symbolTypeList.append((row[0], row[1], row[2]))  # UID, Category, Type
1120 1245
            except Exception as ex:
1121 1246
                from App import App
1122 1247

  
1123
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1248
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1249
                                                               sys.exc_info()[-1].tb_lineno)
1124 1250
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1125 1251

  
1126 1252
        return symbolTypeList
......
1128 1254
    def getUnits(self):
1129 1255
        unitsList = []
1130 1256

  
1131
        try:            
1257
        try:
1132 1258
            conn = sqlite3.connect(self.activeDrawing.path)
1133 1259
            conn.execute('PRAGMA foreign_keys = ON')
1134 1260
            cursor = conn.cursor()
......
1137 1263
                cursor.execute(sql)
1138 1264
                rows = cursor.fetchall()
1139 1265
                for row in rows:
1140
                    unitsList.append((row[0], row[1], row[2])) # UID, Key, Value
1266
                    unitsList.append((row[0], row[1], row[2]))  # UID, Key, Value
1141 1267
            except Exception as ex:
1142 1268
                from App import App
1143 1269

  
1144
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1270
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1271
                                                               sys.exc_info()[-1].tb_lineno)
1145 1272
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1146 1273
        finally:
1147 1274
            conn.close()
1148 1275

  
1149 1276
        return unitsList
1150 1277

  
1151

  
1152 1278
    def getHMBDisplayNameAndUnitsExpression(self):
1153 1279
        res = []
1154 1280

  
......
1163 1289
                            left join HMBUnits hu
1164 1290
                                on dn.COLUMN_NAME = Hu.Column_Name
1165 1291
                            where dn.Table_Name = 'HMB'
1166
                            order by dn.[Order]"""    
1292
                            order by dn.[Order]"""
1167 1293
                try:
1168
                    cursor.execute(sql)  
1294
                    cursor.execute(sql)
1169 1295
                    rows = cursor.fetchall()
1170 1296
                    for row in rows:
1171
                        res.append((row[0], row[1])) 
1297
                        res.append((row[0], row[1]))
1172 1298
                except Exception as ex:
1173 1299
                    from App import App
1174 1300

  
1175
                    message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1301
                    message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1302
                                                                   sys.exc_info()[-1].tb_lineno)
1176 1303
                    App.mainWnd().addMessage.emit(MessageType.Error, message)
1177 1304

  
1178 1305
        return res
......
1182 1309
        @author     Jeongwoo
1183 1310
        @date       2018.05.09
1184 1311
    '''
1312

  
1185 1313
    def getSymbolCategoryByType(self, type):
1186 1314
        category = None
1187 1315

  
......
1198 1326
            except Exception as ex:
1199 1327
                from App import App
1200 1328

  
1201
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1329
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1330
                                                               sys.exc_info()[-1].tb_lineno)
1202 1331
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1203 1332

  
1204 1333
        return category
......
1208 1337
        @author humkyung
1209 1338
        @date   2018.07.07
1210 1339
    '''
1340

  
1211 1341
    @property
1212 1342
    def activeDrawing(self):
1213 1343
        return self._activeDrawing
......
1217 1347
        @author humkyung
1218 1348
        @date   2018.07.07
1219 1349
    '''
1350

  
1220 1351
    @activeDrawing.setter
1221 1352
    def activeDrawing(self, value):
1222 1353
        self._activeDrawing = value
HYTOS/HYTOS/Calculation.py
619 619
            App.mainWnd().addMessage.emit(MessageType.Error, message)
620 620

  
621 621

  
622
def is_not_blank(s):
623
    return bool(s and s.strip())
624

  
625

  
626
class Calculation_2Phase:
627
    def __init__(self, components_uid, process, geometry):
628
        self.components_uid = components_uid
629
        self.process = process
630
        self.geometry = geometry
631
        self.units = {}
632

  
633
        self.calculated_variable = {}
634
        self.init_units()
635

  
636
        self.tp_cal()
637

  
638
    def init_units(self):
639
        try:
640
            app_doc_data = AppDocData.instance()
641
            self.units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0]
642
        except Exception as ex:
643
            from App import App
644
            from AppDocData import MessageType
645

  
646
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
647
                                                           sys.exc_info()[-1].tb_lineno)
648
            App.mainWnd().addMessage.emit(MessageType.Error, message)
649

  
650
    def get_barometric_pressure(self):
651
        try:
652
            unit = self.units['Pressure']
653
            if unit == 'kg/cm2':
654
                barometric_pressure = 1.033
655
            elif unit == 'bar':
656
                barometric_pressure = 1.01325
657
            elif unit == 'psi':
658
                barometric_pressure = 14.7
659
            elif unit == 'mmHg':
660
                barometric_pressure = 760
661
            elif unit == 'kPa':
662
                barometric_pressure = 101.325
663
            elif unit == 'MPa':
664
                barometric_pressure = 0.101325
665

  
666
            return barometric_pressure
667
        except Exception as ex:
668
            from App import App
669
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
670
                                                           sys.exc_info()[-1].tb_lineno)
671
            App.mainWnd().addMessage.emit(MessageType.Error, message)
672

  
673
    def tp_geo_check(self, row):
674
        element = self.geometry.item(row, 0).text()
675

  
676
        if element == 'Pipe':
677
            inside_diameter = self.geometry.item(row, 3).text()
678
            roughness = self.geometry.item(row, 4).text()
679
            length = self.geometry.item(row, 5).text()
680
            if is_not_blank(inside_diameter) and is_not_blank(roughness) and is_not_blank(length):
681
                return False
682
        elif element == 'Bend':
683
            inside_diameter = self.geometry.item(row, 3).text()
684
            roughness = self.geometry.item(row, 4).text()
685
            angle = self.geometry.item(row, 6).text()
686
            rpd = self.geometry.item(row, 7).text()
687
            if is_not_blank(inside_diameter) and is_not_blank(roughness) and is_not_blank(angle) and is_not_blank(rpd):
688
                return False
689
        elif element == 'Nozzle In' or element == 'Nozzle Out' or element == 'Check Valve' or element == 'Ball Valve' or element == 'Gate Valve' or element == 'Globe Valve' or element == 'Butterfly Valve':
690
            inside_diameter = self.geometry.item(row, 3).text()
691
            roughness = self.geometry.item(row, 4).text()
692
            if is_not_blank(inside_diameter) and is_not_blank(roughness):
693
                return False
694
        elif element == 'Reducer' or element == 'Expander':
695
            inside_diameter = self.geometry.item(row, 3).text()
696
            roughness = self.geometry.item(row, 4).text()
697
            angle = self.geometry.item(row, 6).text()
698
            d1_d2 = self.geometry.item(row, 8).text()
699
            if is_not_blank(inside_diameter) and is_not_blank(roughness) and is_not_blank(angle) and is_not_blank(
700
                    d1_d2):
701
                return False
702

  
703
        return True
704

  
705
    def tp_c_cal(self):
706
        try:
707
            tp_massflux = self.calculated_variable['tp_massflux']
708
            if tp_massflux >= 300:
709
                tp_massflux_c = tp_massflux
710
            else:
711
                tp_massflux_c = 300 + ((300 - tp_massflux) ** 2 / 40)
712

  
713
            lambda1 = self.calculated_variable['lambda1']
714
            l_density = self.calculated_variable['l_density']
715
            v_density = self.calculated_variable['v_density']
716
            tp_quality = self.calculated_variable['tp_quality']
717

  
718
            tp_c1 = 2 + (32 * (1 - 0.16 * (2.5 + lambda1) ** 2) ** 3) / (1 + 0.005664 * tp_massflux_c ** 0.8)
719
            tp_c2 = (v_density / l_density) ** 0.5 + (l_density / v_density) ** 0.5
720
            tp_c3 = ((l_density / v_density) ** 0.125) / (
721
                    (tp_quality + (1 - tp_quality) * (v_density / l_density)) ** 0.5)
722

  
723
            if tp_c1 > tp_c2:
724
                tp_c_prime = tp_c1
725
            else:
726
                # (5) 최종 판별
727
                if tp_c3 > tp_c2 > tp_c1:
728
                    tp_c_prime = tp_c2
729
                elif tp_c2 > tp_c3 > tp_c1:
730
                    tp_c_prime = tp_c3
731
                elif tp_c2 > tp_c1 > tp_c3:
732
                    tp_c_prime = tp_c1
733

  
734
            tp_rea_rough = self.calculated_variable['tp_rea_rough']
735
            tp_C = tp_c_prime * ((1 + 10 ** (-200 * tp_rea_rough)) / 2)
736

  
737
            self.calculated_variable['tp_C'] = tp_C
738
        except Exception as ex:
739
            from App import App
740
            from AppDocData import MessageType
741

  
742
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
743
                                                           sys.exc_info()[-1].tb_lineno)
744
            App.mainWnd().addMessage.emit(MessageType.Error, message)
745

  
746
    def tp_fric(self, row):
747
        try:
748
            tp_massflux = self.calculated_variable['tp_massflux']
749
            tp_quality = self.calculated_variable['tp_quality']
750
            tp_id = self.calculated_variable['tp_id']
751
            l_visco = self.calculated_variable['l_viscosity']
752
            v_visco = self.calculated_variable['v_viscosity']
753

  
754
            l_rey = tp_massflux * (1 - tp_quality) * tp_id / l_visco
755
            v_rey = tp_massflux * tp_quality * tp_id / v_visco
756

  
757
            roughness_unit = self.units['Roughness']
758
            tp_rough = self.geometry.item(row, 4).text()
759
            if roughness_unit == 'm':
760
                tp_rough = tp_rough
761
            elif roughness_unit == 'ft':
762
                tp_rough = tp_rough * 0.3048
763
            elif roughness_unit == 'in':
764
                tp_rough = tp_rough * 0.0254
765
            elif roughness_unit == 'mm':
766
                tp_rough = tp_rough * 0.001
767

  
768
            tp_rea_rough = tp_rough / tp_id
769
            self.calculated_variable['tp_rea_rough'] = tp_rea_rough
770

  
771
            if l_rey <= 2100:
772
                l_f = 16 / l_rey
773
            else:
774
                l_f = (-4 * (math.log(tp_rough / 3.7 / tp_id - 5.02 / l_rey * (
775
                        math.log(tp_rough / tp_id / 3.7 + (6.7 / l_rey) ** 0.9) / math.log(10))) / math.log(10))) ** (
776
                          -2)
777

  
778
            if v_rey <= 2100:
779
                v_f = 16 / v_rey
780
            else:
781
                v_f = (-4 * (math.log(tp_rough / 3.7 / tp_id - 5.02 / v_rey * (
782
                        math.log(tp_rough / tp_id / 3.7 + (6.7 / v_rey) ** 0.9) / math.log(10))) / math.log(10))) ** (
783
                          -2)
784

  
785
            tp_flow = self.calculated_variable['tp_flow']
786
            l_density = self.calculated_variable['l_density']
787
            v_density = self.calculated_variable['v_density']
788

  
789
            # 이 f 값들은 현재 moody friction factor들임
790
            l_vel = tp_flow * (1 - tp_quality) / l_density / tp_id ** 2 / 3.1415 * 4
791
            v_vel = tp_flow * tp_quality / v_density / tp_id ** 2 / 3.1415 * 4
792

  
793
            self.calculated_variable['l_vel'] = l_vel
794
            self.calculated_variable['v_vel'] = v_vel
795

  
796
            l_dp_fric = 2 * l_f * 1 * tp_massflux ** 2 * (1 - tp_quality) ** 2 / tp_id / l_density / 101325 * 1.033
797
            v_dp_fric = 2 * v_f * 1 * tp_massflux ** 2 * tp_quality ** 2 / tp_id / v_density / 101325 * 1.033
798
            self.calculated_variable['l_dp_fric'] = l_dp_fric
799
            self.calculated_variable['v_dp_fric'] = v_dp_fric
800

  
801
            self.tp_c_cal()
802

  
803
            tp_C = self.calculated_variable['tp_C']
804
            tp_dp_fric = l_dp_fric + tp_C * (l_dp_fric * v_dp_fric) ** 0.5 + v_dp_fric
805

  
806
            self.calculated_variable['tp_dp_fric'] = tp_dp_fric
807

  
808
        except Exception as ex:
809
            from App import App
810
            from AppDocData import MessageType
811

  
812
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
813
                                                           sys.exc_info()[-1].tb_lineno)
814
            App.mainWnd().addMessage.emit(MessageType.Error, message)
815

  
816
    def tp_stat(self, row):
817
        try:
818
            tp_angle = self.geometry.item(row, 6).text()
819
            if is_not_blank(tp_angle):
820
                tp_angle = float(tp_angle)
821
            else:
822
                tp_angle = 0
823
            self.calculated_variable['tp_angle'] = tp_angle
824

  
825
            tp_mean_den = self.calculated_variable['tp_mean_den']
826
            tp_dp_stat = tp_mean_den * 9.81 * 1 * math.sin(tp_angle / 180 * 3.1415) / 101325 * 1.033
827

  
828
            self.calculated_variable['tp_dp_stat'] = tp_dp_stat
829
        except Exception as ex:
830
            from App import App
831
            from AppDocData import MessageType
832

  
833
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
834
                                                           sys.exc_info()[-1].tb_lineno)
835
            App.mainWnd().addMessage.emit(MessageType.Error, message)
836

  
837
    def momen(self):
838
        try:
839
            tp_dp_fric = self.calculated_variable['tp_dp_fric']
840
            tp_dp_stat = self.calculated_variable['tp_dp_stat']
841
            tp_massflux = self.calculated_variable['tp_massflux']
842
            tp_quality = self.calculated_variable['tp_quality']
843
            tp_pressure = self.calculated_variable['tp_pressure']
844
            v_density = self.calculated_variable['v_density']
845

  
846
            tp_pipe_total_drop = (tp_dp_fric + tp_dp_stat) / (
847
                (1 - (tp_massflux ** 2 * tp_quality / (tp_pressure / 1.033 * 101325) / v_density)))
848

  
849
            self.calculated_variable['tp_pipe_total_drop'] = tp_pipe_total_drop
850
            tp_dp_momen = tp_pipe_total_drop - tp_dp_fric - tp_dp_stat
851
        except Exception as ex:
852
            from App import App
853
            from AppDocData import MessageType
854

  
855
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
856
                                                           sys.exc_info()[-1].tb_lineno)
857
            App.mainWnd().addMessage.emit(MessageType.Error, message)
858

  
859
    def tp_dp_input(self):
860
        try:
861
            pass
862

  
863
            # ToDo
864
            # 2_DB 시트에 값 입력
865
        except Exception as ex:
866
            from App import App
867
            from AppDocData import MessageType
868

  
869
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
870
                                                           sys.exc_info()[-1].tb_lineno)
871
            App.mainWnd().addMessage.emit(MessageType.Error, message)
872

  
873
    def tp_v_density_cal(self):
874
        try:
875
            tp_pressure_ratio = self.calculated_variable['tp_pressure_ratio']
876

  
877
            # (1) vapor 를 kg/m3로 맞춤
878
            if is_not_blank(self.process['v_density']):
879
                density_unit = self.units['Density']
880
                if density_unit == 'kg/m3':
881
                    v_density = float(self.process['v_density']) * tp_pressure_ratio
882
                elif density_unit == 'lb/ft3':
883
                    v_density = float(self.process['v_density']) * 16.0185 * tp_pressure_ratio
884
            else:
885
                temperature_unit = self.units['Temperature']
886
                if temperature_unit == '℃':
887
                    v_temp = float(self.process['v_temp']) + 273.15
888
                elif temperature_unit == '℉':
889
                    v_temp = (float(self.process['v_temp']) - 32) / 1.8 + 273.15
890

  
891
                self.calculated_variable['v_temp'] = v_temp
892

  
893
                v_mw = float(self.process['v_mw'])
894

  
895
                v_z = float(self.process['v_z'])
896

  
897
                v_density = self.calculated_variable['tp_pressure'] * v_mw / 0.08206 / v_temp / v_z / 1.033
898

  
899
            self.calculated_variable['v_density'] = v_density
900

  
901
        except Exception as ex:
902
            from App import App
903
            from AppDocData import MessageType
904

  
905
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
906
                                                           sys.exc_info()[-1].tb_lineno)
907
            App.mainWnd().addMessage.emit(MessageType.Error, message)
908

  
909
    def regime_input(self):
910
        try:
911
            pass
912
            # ToDo
913
            # 2_DB 시트에 값 입력
914
        except Exception as ex:
915
            from App import App
916
            from AppDocData import MessageType
917

  
918
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
919
                                                           sys.exc_info()[-1].tb_lineno)
920
            App.mainWnd().addMessage.emit(MessageType.Error, message)
921

  
922
    def tp_ho_regime(self):
923
        try:
924
            l_dp_fric = self.calculated_variable['l_dp_fric']
925
            v_dp_fric = self.calculated_variable['v_dp_fric']
926

  
927
            hoX = (l_dp_fric / v_dp_fric) ** 0.5
928

  
929
            tp_massflux = self.calculated_variable['tp_massflux']
930
            tp_quality = self.calculated_variable['tp_quality']
931
            l_density = self.calculated_variable['l_density']
932
            v_density = self.calculated_variable['v_density']
933
            tp_id = self.calculated_variable['tp_id']
934
            l_visco = self.calculated_variable['l_viscosity']
935
            v_visco = self.calculated_variable['v_viscosity']
936

  
937
            hoFr = (tp_massflux * tp_quality / v_density) * (
938
                    v_density / ((l_density - v_density) * tp_id * 9.81)) ** 0.5
939
            hoFr1 = 1 / ((hoX ** 1.76) + 2 * (hoX ** 0.5) + 0.45)
940

  
941
            hoK = hoFr * (tp_massflux * (1 - tp_quality) * tp_id / l_visco) ** 0.5
942
            hoK1 = (0.13 * hoX ** -0.39 + 0.21 * hoX ** 0.39) ** -1.67
943

  
944
            hoT = ((l_dp_fric / 1.033 * 101325) / (9.81 * (l_density - v_density))) ** 0.5
945
            hoT1 = (0.72 + 0.05 * hoX ** 0.8) ** -0.5
946

  
947
            if hoFr1 > hoFr:
948
                # K와 X의 비교
949
                if hoK1 > hoK:
950
                    regime = 'Stratified'
951
                elif hoK1 < hoK:
952
                    regime = 'Wavy'
953
                YY = hoK / 1000
954
            elif hoFr1 < hoFr:
955
                if hoX < 1.6:
956
                    regime = 'Annular'
957
                    YY = hoFr
958
                else:
959
                    if hoT > hoT1:
960
                        regime = 'Bubble'
961
                        YY = hoT
962
                        if hoT < hoFr1:
963
                            YY = hoFr1
964
                    elif hoT < hoT1:
965
                        regime = 'Slug / Plug'
966
                        YY = hoT
967
                        if hoT < hoFr1:
968
                            YY = hoFr1
969

  
970
            xx = hoX
971

  
972
            self.regime_input()
973

  
974
        except Exception as ex:
975
            from App import App
976
            from AppDocData import MessageType
977

  
978
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
979
                                                           sys.exc_info()[-1].tb_lineno)
980
            App.mainWnd().addMessage.emit(MessageType.Error, message)
981

  
982
    def tp_vd_regime(self):
983
        try:
984
            l_vel = self.calculated_variable['l_vel']
985
            v_vel = self.calculated_variable['v_vel']
986

  
987
            a_o = 1.2903 * l_vel - 0.25806
988
            o_p = 0.984375 * l_vel - 0.39375
989

  
990
            if v_vel > o_p:
991
                regime = 'Annular'
992
            else:
993
                if v_vel > o_p:
994
                    regime = 'Oscillary'
995
                else:
996
                    regime = 'Bubble'
997

  
998
            XX = l_vel
999
            YY = v_vel
1000

  
1001
            self.regime_input()
1002
        except Exception as ex:
1003
            from App import App
1004
            from AppDocData import MessageType
1005

  
1006
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1007
                                                           sys.exc_info()[-1].tb_lineno)
1008
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1009

  
1010
    def tp_vu_regime(self):
1011
        try:
1012
            l_density = self.calculated_variable['l_density']
1013
            v_density = self.calculated_variable['v_density']
1014
            l_vel = self.calculated_variable['l_vel']
1015
            v_vel = self.calculated_variable['v_vel']
1016

  
1017
            xx = l_density * l_vel ** 2
1018
            YY = v_density * v_vel ** 2
1019

  
1020
            xbub = 32000 * (YY / 1.15) ** -1.4175
1021
            ybub = 7500 * (YY / 3.2) ** -0.3214
1022

  
1023
            # bubble
1024
            if YY < 3.2 and xx > xbub:
1025
                regime = 'Bubble'
1026
                self.regime_input()
1027
                return
1028

  
1029
            if 10 > YY > 3.2 and xx > ybub:
1030
                regime = 'Bubble'
1031
                self.regime_input()
1032
                return
1033

  
1034
            if 10 < YY < 100 and xx > 5200:
1035
                regime = 'Bubble'
1036
                self.regime_input()
1037
                return
1038

  
1039
            # churn
1040
            churn1 = 6.5 * (YY / 0.1) ** 0.4375
1041
            churn2 = 17.8 * (YY / 1) ** 0.7496
1042
            churn3 = 100 * (YY / 10) ** 1.4256
1043
            churn4 = 525 * (YY / 32) ** 3.9719
1044
            churn5 = 10 * (YY / 100) ** -2.5129
1045

  
1046
            if YY > 100 and xx < 10 and xx < churn5:
1047
                regime = 'Churn'
1048
                self.regime_input()
1049
                return
1050

  
1051
            if YY < 1 and xx < churn1:
1052
                regime = 'Churn'
1053
                self.regime_input()
1054
                return
1055

  
1056
            if YY < 10 and xx < churn2:
1057
                regime = 'Churn'
1058
                self.regime_input()
1059
                return
1060

  
1061
            if YY < 32 and xx < churn3:
1062
                regime = 'Churn'
1063
                self.regime_input()
1064
                return
1065

  
1066
            if YY < 57 and xx < churn4:
1067
                regime = 'Churn'
1068
                self.regime_input()
1069
                return
1070

  
1071
            if YY < 100 and xx < 5200 and xx < churn4:
1072
                regime = 'Churn'
1073
                self.regime_input()
1074
                return
1075

  
1076
            # Wispy Annular
1077
            wisa1 = 1150 * (YY / 1000) ** 0.2704
1078
            wisa2 = 1575 * (YY / 3200) ** 0.9016
1079

  
1080
            if 100 < YY < 1000 and xx > 1150:
1081
                regime = 'Wispy Annular'
1082
                self.regime_input()
1083
                return
1084

  
1085
            if 10000 < YY < 3200 and xx > wisa1:
1086
                regime = 'Wispy Annular'
1087
                self.regime_input()
1088
                return
1089

  
1090
            if YY > 3200 and xx > wisa2:
1091
                regime = 'Wispy Annular'
1092
                self.regime_input()
1093
                return
1094

  
1095
            # Annular
1096
            ann1 = 1150 * (YY / 1000) ** 0.2704
1097
            ann2 = 1575 * (YY / 3200) ** 0.9016
1098
            ann3 = 10 * (YY / 100) ** -2.5129
1099

  
1100
            if 100 < YY < 1000 and 10 < xx < 1150:
1101
                regime = 'Annular'
1102
                self.regime_input()
1103
                return
1104

  
1105
            if 1000 < YY < 3200 and xx < ann1:
1106
                regime = 'Annular'
1107
                self.regime_input()
1108
                return
1109

  
1110
            if YY > 3200 and xx < ann2:
1111
                regime = 'Annular'
1112
                self.regime_input()
1113
                return
1114

  
1115
            if 10 > xx > ann3 and YY > 100:
1116
                regime = 'Annular'
1117
                self.regime_input()
1118
                return
1119

  
1120
            # Bubbly Plug
1121
            bslug1 = 6.5 * (YY / 0.1) ** 0.4375
1122
            bslug2 = 17.8 * (YY / 1) ** 0.7496
1123
            bslug3 = 100 * (YY / 10) ** 1.4256
1124
            bslug4 = 525 * (YY / 32) ** 3.9719
1125
            bslug5 = 32000 * (YY / 1.15) ** -1.4175
1126
            bslug6 = 7500 * (YY / 3.2) ** -0.3214
1127

  
1128
            if YY < 1 and bslug1 < xx < bslug5:
1129
                if xx > 1000:
1130
                    regime = 'Bubbly Plug'
1131
                elif xx < 1000:
1132
                    regime = 'Plug'
1133
                self.regime_input()
1134
                return
1135

  
1136
            if YY < 3.2 and bslug1 < xx < bslug5:
1137
                if xx > 1000:
1138
                    regime = 'Bubbly Plug'
1139
                elif xx < 1000:
1140
                    regime = 'Plug'
1141
                self.regime_input()
1142
                return
1143

  
1144
            if YY < 10 and bslug2 < xx < bslug6:
1145
                if xx > 1000:
1146
                    regime = 'Bubbly Plug'
1147
                elif xx < 1000:
1148
                    regime = 'Plug'
1149
                self.regime_input()
1150
                return
1151

  
1152
            if YY < 32 and bslug3 < xx < 5200:
1153
                if xx > 1000:
1154
                    regime = 'Bubbly Plug'
1155
                elif xx < 1000:
1156
                    regime = 'Plug'
1157
                self.regime_input()
1158
                return
1159

  
1160
            if YY < 57 and bslug4 < xx < 5200:
1161
                if xx > 1000:
1162
                    regime = 'Bubbly Plug'
1163
                elif xx < 1000:
1164
                    regime = 'Plug'
1165
                self.regime_input()
1166
                return
1167

  
1168
        except Exception as ex:
1169
            from App import App
1170
            from AppDocData import MessageType
1171

  
1172
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1173
                                                           sys.exc_info()[-1].tb_lineno)
1174
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1175

  
1176
    def tp_regime(self):
1177
        try:
1178
            tp_angle = self.calculated_variable['tp_angle']
1179

  
1180
            if tp_angle == 0:
1181
                self.tp_ho_regime()
1182
            elif tp_angle < 0:
1183
                self.tp_vd_regime()
1184
            elif tp_angle > 0:
1185
                self.tp_vu_regime()
1186

  
1187
        except Exception as ex:
1188
            from App import App
1189
            from AppDocData import MessageType
1190

  
1191
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1192
                                                           sys.exc_info()[-1].tb_lineno)
1193
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1194

  
1195
    def tp_calc_end(self, row):
1196
        try:
1197
            # ToDo
1198
            # 2_DB 시트에 값 입력
1199

  
1200
            element = self.geometry.item(row, 0).text()
1201
            if element == 'Pipe':
1202
                tp_pressure = self.calculated_variable['tp_pressure']
1203
                tp_length = self.calculated_variable['tp_length']
1204
                tp_pipe_total_drop = self.calculated_variable['tp_pipe_total_drop']
1205

  
1206
                tp_pressure_ratio = (tp_pressure - tp_length * tp_pipe_total_drop) / tp_pressure
1207
                tp_pressure = tp_pressure - tp_length * tp_pipe_total_drop
1208
            else:
1209
                tp_pressure = self.calculated_variable['tp_pressure']
1210
                tp_element_dp = self.calculated_variable['tp_element_dp']
1211

  
1212
                tp_pressure_ratio = (tp_pressure - tp_element_dp) / tp_pressure
1213
                tp_pressure = tp_pressure - tp_element_dp
1214

  
1215
            self.calculated_variable['tp_pressure'] = tp_pressure
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)