프로젝트

일반

사용자정보

개정판 4211450a

ID4211450ab3ff20e9b5a173da950ee062b697d332
상위 46483342
하위 5403f008

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

issue #1059 : 계산 결과 리포트

Change-Id: I282f035a8afc5a4ee9e09685b07e37f02499c605

차이점 보기:

HYTOS/HYTOS/Drawing.py
22 22
        self.allItems = []
23 23
        self._hmbTable = None
24 24
        self._modified = False
25
        self._loops = []
26

  
27
    @property
28
    def loops(self):
29
        """getter of loops"""
30
        return self._loops
31

  
32
    @loops.setter
33
    def loops(self, value):
34
        """setter of loops"""
35
        self._loops = value
25 36

  
26 37
    @property
27 38
    def modified(self):
HYTOS/HYTOS/MainWindow.py
40 40
def is_blank(s):
41 41
    return not (s and s.strip())
42 42

  
43
def is_float(s):
44
    try:
45
        if s:
46
            float(s)
47
            return True
48
        else:
49
            return False
50
    except ValueError:
51
        return False
43 52

  
44 53
def set_item_properties(name, alignment, color=None):
45 54
    if name is None:
......
835 844
                    cmd = HydroCalculationCommand(self.graphicsView)
836 845
                    cmd.execute(None)
837 846
                    cmd.execute_second(None)
838
                    self.display_loops(cmd.loops)
847

  
848
                    app_doc_data.activeDrawing.loops = cmd.loops
849

  
850
                    self.display_loops()
839 851
                    self.display_output()
840 852

  
841 853
                    self.load_HMB()
......
877 889
                template = os.path.join(os.getenv('ALLUSERSPROFILE'), App.NAME, 'Report_Template.xlsx')
878 890
                if name and os.path.exists(template):
879 891
                    wb = openpyxl.load_workbook(template)
880
                    ws = wb.get_sheet_by_name('Page')
892

  
893
                    ws = wb.copy_worksheet(wb.get_sheet_by_name('Page'))
894
                    ws.title = 'Page (1)'
881 895

  
882 896
                    cal_image = openpyxl.drawing.image.Image(image_path)
883 897
                    x_scale, y_scale = 1, 1
......
885 899
                    cal_image.height *= y_scale
886 900
                    ws.add_image(cal_image, 'C4')
887 901

  
902
                    units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0]
903

  
888 904
                    """write sheet information"""
889 905
                    configs = app_doc_data.getConfigs('Sheet')
890 906
                    for config in configs:
......
907 923
                    ws['Z68'].value = str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
908 924
                    """up to here"""
909 925

  
910
                    # Output Pump, Compressor, Control Valve
926
                    # Output [Pump, Compressor, Control Valve]
911 927
                    ws['X1'].value = 'Loop_Deviation'
912 928
                    ws['X1'].font = Font(bold=True, underline='single', size=11)
913 929
                    ws['X2'].value = 'To Do ...'
914 930

  
931
                    loops = app_doc_data.activeDrawing.loops
932

  
933
                    start_row_no = 4
934
                    start_col_no = 24
935
                    # Pump
936
                    pumps = []
937
                    row_no = start_row_no
938
                    col_no = start_col_no
939
                    for loop in loops:
940
                        for item in loop.items:
941
                            parent = item.parent
942
                            if parent:
943
                                name = str(item).replace(
944
                                    '_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '')
945
                                if name in pumps:
946
                                    continue
947
                                if name[:3] == 'R_P' or name[:3] == 'L_P' or name[:3] == 'V_P':
948
                                    pumps.append(name)
949

  
950
                                    attr = item.parent.attribute
951
                                    ws.cell(row_no, col_no, attr['Tag_No']).font = Font(bold=True, underline='single',
952
                                                                                        size=11)
953

  
954
                                    row_no += 1
955
                                    ws.cell(row_no, col_no, 'Suct.P :')
956
                                    col_no += 2
957
                                    ws.cell(row_no, col_no, round(attr['Suct.P'], 3))
958
                                    col_no += 1
959
                                    ws.cell(row_no, col_no, '{}.g'.format(units['Pressure']))
960

  
961
                                    row_no += 1
962
                                    col_no = 24 if col_no == 27 else 28
963
                                    ws.cell(row_no, col_no, 'Disc.P :')
964
                                    col_no += 2
965
                                    ws.cell(row_no, col_no, round(attr['Disc.P'], 3))
966
                                    col_no += 1
967
                                    ws.cell(row_no, col_no, '{}.g'.format(units['Pressure']))
968

  
969
                                    row_no += 1
970
                                    col_no = 24 if col_no == 27 else 28
971
                                    ws.cell(row_no, col_no, 'Diff.P :')
972
                                    col_no += 2
973
                                    ws.cell(row_no, col_no, round(attr['Diff.P'], 3))
974
                                    col_no += 1
975
                                    ws.cell(row_no, col_no, units['Pressure'])
976

  
977
                                    row_no += 1
978
                                    col_no = 24 if col_no == 27 else 28
979
                                    ws.cell(row_no, col_no, 'Head :')
980
                                    col_no += 2
981
                                    ws.cell(row_no, col_no, round(attr['Head'], 3))
982
                                    col_no += 1
983
                                    ws.cell(row_no, col_no, units['Length'])
984

  
985
                                    row_no += 1
986
                                    col_no = 24 if col_no == 27 else 28
987
                                    ws.cell(row_no, col_no, 'NPSHa :')
988
                                    col_no += 2
989
                                    ws.cell(row_no, col_no, round(attr['NPSHa'], 3))
990
                                    col_no += 1
991
                                    ws.cell(row_no, col_no, units['Length'])
992

  
993
                                    row_no += 1
994
                                    col_no = 24 if col_no == 27 else 28
995
                                    ws.cell(row_no, col_no, 'Vap. P :')
996
                                    col_no += 2
997
                                    ws.cell(row_no, col_no, attr['Vap. P'])
998
                                    col_no += 1
999
                                    ws.cell(row_no, col_no, '{}.a'.format(units['Pressure']))
1000

  
1001
                                    row_no += 1
1002
                                    col_no = 24 if col_no == 27 else 28
1003
                                    ws.cell(row_no, col_no, 'HHP :')
1004
                                    col_no += 2
1005
                                    ws.cell(row_no, col_no, round(attr['HHP'], 3))
1006
                                    col_no += 1
1007
                                    ws.cell(row_no, col_no, units['Power'])
1008

  
1009
                                    col_no = 28 if col_no == 27 else 24
1010
                                    row_no = row_no - 7 if col_no == 28 else row_no + 2
1011

  
1012
                    start_row_no += math.ceil(len(pumps)) * 9
1013

  
1014
                    # Compressor
1015
                    compressors = []
1016
                    row_no = start_row_no
1017
                    col_no = start_col_no
1018
                    for loop in loops:
1019
                        for item in loop.items:
1020
                            parent = item.parent
1021
                            if parent:
1022
                                name = str(item).replace(
1023
                                    '_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '')
1024
                                if name in compressors:
1025
                                    continue
1026
                                if name[:3] == 'R_K' or name[:3] == 'L_K':
1027
                                    compressors.append(name)
1028

  
1029
                                    attr = item.parent.attribute
1030
                                    ws.cell(row_no, col_no, attr['Tag_No']).font = Font(bold=True, underline='single',
1031
                                                                                        size=11)
1032

  
1033
                                    row_no += 1
1034
                                    ws.cell(row_no, col_no, 'Suct.P :')
1035
                                    col_no += 2
1036
                                    ws.cell(row_no, col_no, round(attr['Suct.P'], 3))
1037
                                    col_no += 1
1038
                                    ws.cell(row_no, col_no, '{}.g'.format(units['Pressure']))
1039

  
1040
                                    row_no += 1
1041
                                    col_no = 24 if col_no == 27 else 28
1042
                                    ws.cell(row_no, col_no, 'Disc.P :')
1043
                                    col_no += 2
1044
                                    ws.cell(row_no, col_no, round(attr['Disc.P'], 3))
1045
                                    col_no += 1
1046
                                    ws.cell(row_no, col_no, '{}.g'.format(units['Pressure']))
1047

  
1048
                                    row_no += 1
1049
                                    col_no = 24 if col_no == 27 else 28
1050
                                    ws.cell(row_no, col_no, 'Diff.P :')
1051
                                    col_no += 2
1052
                                    ws.cell(row_no, col_no, round(attr['Diff.P'], 3))
1053
                                    col_no += 1
1054
                                    ws.cell(row_no, col_no, units['Pressure'])
1055

  
1056
                                    row_no += 1
1057
                                    col_no = 24 if col_no == 27 else 28
1058
                                    ws.cell(row_no, col_no, 'HHP :')
1059
                                    col_no += 2
1060
                                    ws.cell(row_no, col_no, round(attr['HHP'], 3))
1061
                                    col_no += 1
1062
                                    ws.cell(row_no, col_no, units['Power'])
1063

  
1064
                                    col_no = 28 if col_no == 27 else 24
1065
                                    row_no = row_no - 4 if col_no == 28 else row_no + 2
1066

  
1067
                    start_row_no += math.ceil(len(compressors)) * 9
1068

  
1069
                    # Control Valve
1070
                    control_valves = []
1071
                    row_no = start_row_no
1072
                    col_no = start_col_no
1073
                    for loop in loops:
1074
                        for item in loop.items:
1075
                            parent = item.parent
1076
                            if parent:
1077
                                name = str(item).replace(
1078
                                    '_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '')
1079
                                if name in control_valves:
1080
                                    continue
1081
                                if name[:3] == 'CV_':
1082
                                    control_valves.append(name)
1083

  
1084
                                    attr = item.parent.attribute
1085
                                    ws.cell(row_no, col_no, attr['Tag_No']).font = Font(bold=True, underline='single',
1086
                                                                                        size=11)
1087

  
1088
                                    row_no += 1
1089
                                    ws.cell(row_no, col_no, 'Inlet P :')
1090
                                    col_no += 2
1091
                                    ws.cell(row_no, col_no, round(attr['Suct.P'], 3))
1092
                                    col_no += 1
1093
                                    ws.cell(row_no, col_no, '{}.g'.format(units['Pressure']))
1094

  
1095
                                    row_no += 1
1096
                                    col_no = 24 if col_no == 27 else 28
1097
                                    ws.cell(row_no, col_no, 'Outlet P :')
1098
                                    col_no += 2
1099
                                    ws.cell(row_no, col_no, round(attr['Disc.P'], 3))
1100
                                    col_no += 1
1101
                                    ws.cell(row_no, col_no, '{}.g'.format(units['Pressure']))
1102

  
1103
                                    row_no += 1
1104
                                    col_no = 24 if col_no == 27 else 28
1105
                                    ws.cell(row_no, col_no, 'Diff.P :')
1106
                                    col_no += 2
1107
                                    ws.cell(row_no, col_no, round(attr['Diff.P'], 3))
1108
                                    col_no += 1
1109
                                    ws.cell(row_no, col_no, units['Pressure'])
1110

  
1111
                                    row_no += 1
1112
                                    col_no = 24 if col_no == 27 else 28
1113
                                    ws.cell(row_no, col_no, 'dP Ratio :')
1114
                                    col_no += 2
1115
                                    ws.cell(row_no, col_no, round(attr['dP Ratio'] * 100, 2))
1116
                                    col_no += 1
1117
                                    ws.cell(row_no, col_no, '%')
1118

  
1119
                                    col_no = 28 if col_no == 27 else 24
1120
                                    row_no = row_no - 4 if col_no == 28 else row_no + 2
1121

  
1122
                    '''
915 1123
                    symbols = [item for item in self.graphicsView.scene.items() if type(item) is SymbolSvgItem]
916 1124
                    if symbols:
917 1125
                        units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0]
......
1082 1290

  
1083 1291
                                col_no = 28 if col_no == 27 else 24
1084 1292
                                row_no = row_no - 4 if col_no == 28 else row_no + 2
1293
                    '''
1085 1294

  
1086 1295
                    # write hmb unit
1087
                    ws['B54'] = '-'
1088
                    ws['B55'] = units['Pipe_Diameter']
1089
                    ws['B56'] = units['Flowrate_Mass']
1090
                    ws['B57'] = units['Flowrate_Volume']
1091
                    ws['B58'] = units['Density']
1092
                    ws['B59'] = units['Viscosity']
1093
                    ws['B60'] = units['Temperature']  # Hidden
1094
                    ws['B61'] = ''  # Hidden
1095
                    ws['B62'] = ''  # Hidden
1096
                    ws['B63'] = ''  # Hidden
1097
                    ws['B64'] = units['Pipe_Diameter']  # Hidden
1098
                    ws['B65'] = units['Pipe_Diameter']  # Hidden
1099
                    ws['B66'] = ''  # Hidden
1100
                    ws['B67'] = units['Length']
1101
                    ws['B68'] = units['Length']
1102
                    ws['B69'] = units['Roughness']
1103
                    ws['B70'] = units['Velocity']  # Hidden
1104
                    ws['B71'] = '{}/100{})'.format(units['Pressure'], units['Length'])  # Hidden
1105
                    ws['B73'] = units['Velocity']
1106
                    ws['B74'] = ''  # Hidden
1107
                    ws['B75'] = ''  # Hidden
1108
                    ws['B76'] = '{}/100{}'.format(units['Pressure'], units['Length'])
1109
                    ws['B77'] = units['Pressure']
1110
                    ws['B78'] = units['Pressure']
1111
                    ws['B79'] = '{}(g)'.format(units['Pressure'])
1112

  
1113
                    has_mixed_type = False
1296
                    ws['B54'].value = '-'
1297
                    ws['B55'].value = units['Pipe_Diameter']
1298
                    ws['B56'].value = units['Flowrate_Mass']
1299
                    ws['B57'].value = units['Flowrate_Volume']
1300
                    ws['B58'].value = units['Density']
1301
                    ws['B59'].value = units['Viscosity']
1302
                    ws['B60'].value = units['Temperature']  # Hidden
1303
                    ws['B61'].value = ''  # Hidden
1304
                    ws['B62'].value = ''  # Hidden
1305
                    ws['B63'].value = ''  # Hidden
1306
                    ws['B64'].value = units['Pipe_Diameter']  # Hidden
1307
                    ws['B65'].value = units['Pipe_Diameter']  # Hidden
1308
                    ws['B66'].value = ''  # Hidden
1309
                    ws['B67'].value = units['Length']
1310
                    ws['B68'].value = units['Length']
1311
                    ws['B69'].value = units['Roughness']
1312
                    ws['B70'].value = units['Velocity']  # Hidden
1313
                    ws['B71'].value = '{}/100{})'.format(units['Pressure'], units['Length'])  # Hidden
1314
                    ws['B73'].value= units['Velocity']
1315
                    ws['B74'].value = ''  # Hidden
1316
                    ws['B75'].value = ''  # Hidden
1317
                    ws['B76'].value = '{}/100{}'.format(units['Pressure'], units['Length'])
1318
                    ws['B77'].value = units['Pressure']
1319
                    ws['B78'].value = units['Pressure']
1320
                    ws['B79'].value = '{}(g)'.format(units['Pressure'])
1321

  
1114 1322
                    # write hmb data
1115 1323
                    drawing = app_doc_data.activeDrawing
1116 1324
                    hmbs = drawing.hmbTable._hmbs
1117 1325
                    if hmbs is not None:
1118 1326
                        col_no = 3
1119 1327
                        for hmb in hmbs:
1120
                            if hmb.phase_type == 'Mixed':
1121
                                has_mixed_type = True
1122

  
1123 1328
                            row_no = 54
1124 1329
                            ws.cell(row_no, col_no, hmb.phase_type)
1125 1330
                            row_no += 1
......
1174 1379
                            col_no += 1
1175 1380

  
1176 1381
                    # two_phase
1177
                    ws = wb.get_sheet_by_name('Two_phase')
1178
                    if has_mixed_type:
1179
                        pass
1180
                    else:
1181
                        ws.sheet_state = 'hidden'
1382
                    if hmbs is not None:
1383
                        for hmb in hmbs:
1384
                            if hmb.phase_type == 'Mixed':
1385
                                lines = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringStreamlineItem and item.uid == hmb.components_uid]
1386
                                if lines:
1387
                                    ws = wb.copy_worksheet(wb.get_sheet_by_name('Two_phase'))
1388
                                    ws.title = 'Two Phase {}'.format(str(lines[0]))
1389

  
1390
                                    # Information
1391
                                    ws['B5'].value = 'File : Two_Phase'
1392
                                    ws['B6'].value = 'Line : {}'.format(lines[0].stream_no)
1393
                                    ws['G6'].value = 'Made by : {}'.format(configs[0].value)
1394

  
1395
                                    # Process Data
1396
                                    ws['C10'].value = units['Flowrate_Mass']
1397
                                    ws['D10'].value = units['Density']
1398
                                    ws['E10'].value = units['Viscosity']
1399
                                    ws['F10'].value = '{}(g)'.format(units['Pressure'])
1400
                                    ws['G10'].value = units['Temperature']
1401

  
1402
                                    ws['C11'].value = lines[0].data.liquid_flowrate_mass
1403
                                    ws['D11'].value = lines[0].data.liquid_density
1404
                                    ws['E11'].value = lines[0].data.liquid_viscosity
1405

  
1406
                                    ws['C12'].value = lines[0].data.vapor_flowrate_mass
1407
                                    ws['D12'].value = lines[0].data.vapor_density
1408
                                    ws['E12'].value = lines[0].data.vapor_viscosity
1409
                                    ws['F12'].value = lines[0].data.vapor_pressure
1410
                                    ws['G12'].value = lines[0].data.vapor_temperature
1411
                                    ws['H12'].value = lines[0].data.vapor_molecular_weight
1412
                                    ws['I12'].value = lines[0].data.vapor_compress_factor
1413

  
1414
                                    # Geometry Data
1415
                                    ws['D16'].value = units['Pipe_Diameter']
1416
                                    ws['E16'].value = units['Roughness']
1417
                                    ws['F16'].value = units['Length']
1418

  
1419
                                    row_no = 17
1420
                                    for geometry in lines[0].mixed_geometry:
1421
                                        col_no = 3
1422
                                        ws.cell(row_no, col_no, str(geometry[0]))  # Element
1423
                                        col_no += 1
1424
                                        ws.cell(row_no, col_no, float(geometry[3]) if is_float(geometry[3]) else None)  # ID
1425
                                        col_no += 1
1426
                                        ws.cell(row_no, col_no, float(geometry[4]) if is_float(geometry[4]) else None)  # Roughness
1427
                                        col_no += 1
1428
                                        ws.cell(row_no, col_no, float(geometry[5]) if is_float(geometry[5]) else None)  # Length
1429
                                        col_no += 1
1430
                                        ws.cell(row_no, col_no, float(geometry[6]) if is_float(geometry[6]) else None)  # Angle
1431
                                        col_no += 1
1432
                                        ws.cell(row_no, col_no, float(geometry[7]) if is_float(geometry[7]) else None)  # R/D
1433
                                        col_no += 1
1434
                                        ws.cell(row_no, col_no, float(geometry[9]) if is_float(geometry[9]) else None)  # K
1435

  
1436
                                        row_no += 1
1437

  
1438
                                    row_no = 37
1439
                                    data = lines[0].mixed_calculation_result
1440
                                    if data:
1441
                                        for no in range(data.no):
1442
                                            col_no = 12
1443
                                            ws.cell(row_no, col_no, str(data.element[no]))  # Element
1444
                                            col_no += 1
1445
                                            ws.cell(row_no, col_no, data.inside_diameter[no] if no in data.inside_diameter else None)
1446
                                            col_no += 1
1447
                                            ws.cell(row_no, col_no, data.length[no] if no in data.length else None)
1448
                                            col_no += 1
1449
                                            ws.cell(row_no, col_no, data.angle[no] if no in data.angle else None)
1450
                                            col_no += 1
1451
                                            ws.cell(row_no, col_no, data.k[no] if no in data.k else None)
1452
                                            col_no += 1
1453
                                            ws.cell(row_no, col_no, data.pressure[no] if no in data.pressure else None)
1454
                                            col_no += 1
1455
                                            ws.cell(row_no, col_no, data.void[no] if no in data.void else None)
1456
                                            col_no += 1
1457
                                            ws.cell(row_no, col_no, data.quality[no] if no in data.quality else None)
1458
                                            col_no += 1
1459
                                            ws.cell(row_no, col_no, data.mean_den[no] if no in data.mean_den else None)
1460
                                            col_no += 1
1461
                                            ws.cell(row_no, col_no, data.v_density[no] if no in data.v_density else None)
1462
                                            col_no += 1
1463
                                            ws.cell(row_no, col_no, data.homo_vel[no] if no in data.homo_vel else None)
1464
                                            col_no += 1
1465
                                            ws.cell(row_no, col_no, data.max_vel[no] if no in data.max_vel else None)
1466
                                            col_no += 1
1467
                                            ws.cell(row_no, col_no, data.ero_vel[no] if no in data.ero_vel else None)
1468
                                            col_no += 1
1469
                                            ws.cell(row_no, col_no, data.x[no] if no in data.x else None)
1470
                                            col_no += 1
1471
                                            ws.cell(row_no, col_no, data.y[no] if no in data.y else None)
1472
                                            col_no += 1
1473
                                            ws.cell(row_no, col_no, str(data.regime[no]) if no in data.regime else None)
1474
                                            col_no += 1
1475
                                            ws.cell(row_no, col_no, data.dp_fric[no] if no in data.dp_fric else None)
1476
                                            col_no += 1
1477
                                            ws.cell(row_no, col_no, data.dp_stat[no] if no in data.dp_stat else None)
1478
                                            col_no += 1
1479
                                            ws.cell(row_no, col_no, data.dp_momen[no] if no in data.dp_momen else None)
1480
                                            col_no += 1
1481
                                            ws.cell(row_no, col_no, data.total_length[no] if no in data.total_length else None)
1482

  
1483
                                            row_no += 1
1484

  
1485

  
1486

  
1487

  
1488
                    wb.get_sheet_by_name('Page').sheet_state = 'hidden'
1489
                    wb.get_sheet_by_name('Two_phase').sheet_state = 'hidden'
1182 1490

  
1183 1491
                    name_without_ext, ext = os.path.splitext(name)
1184 1492
                    save_file_name = name if ext.upper() == '.XLSX' else name + '.xlsx'
......
1216 1524
            drawing = AppDocData.instance().activeDrawing
1217 1525
            if drawing is None:
1218 1526
                return
1527

  
1219 1528
            self.clear_output()
1220 1529

  
1221 1530
            self.tableWidgetOutput.setColumnCount(3)
......
1226 1535
            self.tableWidgetOutput.setEditTriggers(QAbstractItemView.NoEditTriggers)
1227 1536
            self.tableWidgetOutput.horizontalHeader().setStretchLastSection(True)
1228 1537

  
1229
            symbols = [item for item in self.graphicsView.scene.items() if type(item) is SymbolSvgItem]
1230

  
1231
            if symbols:
1232
                units = [attr[1] for attr in drawing.attrs if attr[0] == 'Units'][0]
1233

  
1234
                pumps = [symbol for symbol in symbols if symbol.has_attribute() and (
1235
                        str(symbol.name)[:3] == 'R_P' or str(symbol.name)[:3] == 'L_P' or str(symbol.name)[
1236
                                                                                          :3] == 'V_P')]
1237

  
1238
                compressors = [symbol for symbol in symbols if symbol.has_attribute() and (
1239
                        str(symbol.name)[:3] == 'R_K' or str(symbol.name)[:3] == 'L_K')]
1240

  
1241
                control_valves = [symbol for symbol in symbols if
1242
                                  symbol.has_attribute() and str(symbol.name)[:3] == 'CV_']
1243

  
1244
                if pumps:
1245
                    for pump in pumps:
1246
                        attr = pump.attribute
1247
                        self.add_data(attr['Tag_No'], None, None, True)
1248
                        self.add_data('Suct.P :', round(attr['Suct.P'], 3),
1249
                                      '{}.g'.format(units['Pressure']))
1250
                        self.add_data('Disc.P :', round(attr['Disc.P'], 3),
1251
                                      '{}.g'.format(units['Pressure']))
1252
                        self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure'])
1253
                        self.add_data('Head :', round(attr['Head'], 3), units['Length'])
1254
                        self.add_data('NPSHa :', round(attr['NPSHa'], 3), units['Length'])
1255
                        self.add_data('Vap. P :', attr['Vap. P'], '{}.a'.format(units['Pressure']))
1256
                        self.add_data('HHP :', round(attr['HHP'], 3), units['Power'])
1257

  
1258
                if compressors:
1259
                    for compressor in compressors:
1260
                        attr = compressor.attribute
1261
                        self.add_data(attr['Tag_No'], None, None, True)
1262
                        self.add_data('Suct.P :', round(attr['Suct.P'], 3),
1263
                                      '{}.g'.format(units['Pressure']))
1264
                        self.add_data('Disc.P :', round(attr['Disc.P'], 3),
1265
                                      '{}.g'.format(units['Pressure']))
1266
                        self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure'])
1267
                        self.add_data('HHP :', round(attr['HHP'], 3), units['Power'])
1268

  
1269
                if control_valves:
1270
                    for control_valve in control_valves:
1271
                        attr = control_valve.attribute
1272
                        self.add_data(attr['Tag_No'], None, None, True)
1273
                        self.add_data('Inlet P :', round(attr['Suct.P'], 3),
1274
                                      '{}.g'.format(units['Pressure']))
1275
                        self.add_data('Outlet P :', round(attr['Disc.P'], 3),
1276
                                      '{}.g'.format(units['Pressure']))
1277
                        self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure'])
1278
                        self.add_data('dP Ratio :', round(attr['dP Ratio'] * 100, 2), '%')
1538
            units = [attr[1] for attr in drawing.attrs if attr[0] == 'Units'][0]
1539

  
1540
            loops = drawing.loops
1541
            names = []
1542
            # Pump
1543
            for loop in loops:
1544
                for item in loop.items:
1545
                    parent = item.parent
1546
                    if parent:
1547
                        name = str(item).replace('_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '')
1548
                        if name in names:
1549
                            continue
1550
                        if name[:3] == 'R_P' or name[:3] == 'L_P' or name[:3] == 'V_P':
1551
                            names.append(name)
1552

  
1553
                            attr = item.parent.attribute
1554
                            self.add_data(attr['Tag_No'], None, None, True)
1555
                            self.add_data('Suct.P :', round(attr['Suct.P'], 3),
1556
                                          '{}.g'.format(units['Pressure']))
1557
                            self.add_data('Disc.P :', round(attr['Disc.P'], 3),
1558
                                          '{}.g'.format(units['Pressure']))
1559
                            self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure'])
1560
                            self.add_data('Head :', round(attr['Head'], 3), units['Length'])
1561
                            self.add_data('NPSHa :', round(attr['NPSHa'], 3), units['Length'])
1562
                            self.add_data('Vap. P :', attr['Vap. P'], '{}.a'.format(units['Pressure']))
1563
                            self.add_data('HHP :', round(attr['HHP'], 3), units['Power'])
1564

  
1565
            # Compressor
1566
            for loop in loops:
1567
                for item in loop.items:
1568
                    parent = item.parent
1569
                    if parent:
1570
                        name = str(item).replace('_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '')
1571
                        if name in names:
1572
                            continue
1573
                        if name[:3] == 'R_K' or name[:3] == 'L_K':
1574
                            names.append(name)
1575

  
1576
                            attr = item.parent.attribute
1577
                            self.add_data(attr['Tag_No'], None, None, True)
1578
                            self.add_data('Suct.P :', round(attr['Suct.P'], 3),
1579
                                          '{}.g'.format(units['Pressure']))
1580
                            self.add_data('Disc.P :', round(attr['Disc.P'], 3),
1581
                                          '{}.g'.format(units['Pressure']))
1582
                            self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure'])
1583
                            self.add_data('HHP :', round(attr['HHP'], 3), units['Power'])
1584

  
1585
            # Control Valve
1586
            for loop in loops:
1587
                for item in loop.items:
1588
                    parent = item.parent
1589
                    if parent:
1590
                        name = str(item).replace('_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '')
1591
                        if name in names:
1592
                            continue
1593
                        if name[:3] == 'CV_':
1594
                            names.append(name)
1595

  
1596
                            attr = item.parent.attribute
1597
                            self.add_data(attr['Tag_No'], None, None, True)
1598
                            self.add_data('Inlet P :', round(attr['Suct.P'], 3),
1599
                                          '{}.g'.format(units['Pressure']))
1600
                            self.add_data('Outlet P :', round(attr['Disc.P'], 3),
1601
                                          '{}.g'.format(units['Pressure']))
1602
                            self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure'])
1603
                            self.add_data('dP Ratio :', round(attr['dP Ratio'] * 100, 2), '%')
1279 1604

  
1280 1605
        except Exception as ex:
1281 1606
            message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
1282 1607
                                                           sys.exc_info()[-1].tb_lineno)
1283 1608
            self.addMessage.emit(MessageType.Error, message)
1284 1609

  
1285
    def display_loops(self, loops):
1610
    def display_loops(self):
1286 1611
        """ display loops """
1287 1612
        drawing = AppDocData.instance().activeDrawing
1288 1613
        if drawing is None: return
1289 1614

  
1615
        loops = drawing.loops
1290 1616
        if loops:
1291 1617
            self.tableWidgetLoop.clear()
1292 1618
            self.tableWidgetLoop.setColumnCount(len(loops) * 4)
HYTOS/HYTOS/MainWindow_UI.py
32 32
        self.verticalLayout.setObjectName("verticalLayout")
33 33
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
34 34
        MainWindow.setCentralWidget(self.centralwidget)
35
        self.menubar = QtWidgets.QMenuBar(MainWindow)
36
        self.menubar.setGeometry(QtCore.QRect(0, 0, 905, 21))
37
        self.menubar.setObjectName("menubar")
38
        self.menu = QtWidgets.QMenu(self.menubar)
39
        self.menu.setObjectName("menu")
40
        self.menuTheme = QtWidgets.QMenu(self.menu)
41
        self.menuTheme.setObjectName("menuTheme")
42
        self.menuLanguage = QtWidgets.QMenu(self.menu)
43
        self.menuLanguage.setObjectName("menuLanguage")
44
        self.menu_3 = QtWidgets.QMenu(self.menubar)
45
        self.menu_3.setObjectName("menu_3")
46
        self.menuTool = QtWidgets.QMenu(self.menubar)
47
        self.menuTool.setObjectName("menuTool")
48
        self.menuAdmin = QtWidgets.QMenu(self.menubar)
49
        self.menuAdmin.setObjectName("menuAdmin")
50
        MainWindow.setMenuBar(self.menubar)
51 35
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
52 36
        self.statusbar.setObjectName("statusbar")
53 37
        MainWindow.setStatusBar(self.statusbar)
......
164 148
        self.gridLayout_7.addWidget(self.tableWidgetOutput, 0, 0, 1, 1)
165 149
        self.dockWidget.setWidget(self.dockWidgetContents_4)
166 150
        MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockWidget)
151
        self.menubar = QtWidgets.QMenuBar(MainWindow)
152
        self.menubar.setGeometry(QtCore.QRect(0, 0, 905, 21))
153
        self.menubar.setObjectName("menubar")
154
        self.menu = QtWidgets.QMenu(self.menubar)
155
        self.menu.setObjectName("menu")
156
        self.menuTheme = QtWidgets.QMenu(self.menu)
157
        self.menuTheme.setObjectName("menuTheme")
158
        self.menuLanguage = QtWidgets.QMenu(self.menu)
159
        self.menuLanguage.setObjectName("menuLanguage")
160
        self.menu_3 = QtWidgets.QMenu(self.menubar)
161
        self.menu_3.setObjectName("menu_3")
162
        self.menuTool = QtWidgets.QMenu(self.menubar)
163
        self.menuTool.setObjectName("menuTool")
164
        MainWindow.setMenuBar(self.menubar)
167 165
        self.actionClose = QtWidgets.QAction(MainWindow)
168 166
        icon2 = QtGui.QIcon()
169 167
        icon2.addPixmap(QtGui.QPixmap(":/images/Exit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
......
464 462
        font.setFamily("맑은 고딕")
465 463
        self.actionSymbol_Editor.setFont(font)
466 464
        self.actionSymbol_Editor.setObjectName("actionSymbol_Editor")
465
        self.toolBar.addAction(self.actionNew)
466
        self.toolBar.addAction(self.actionOpen)
467
        self.toolBar.addAction(self.actionSave)
468
        self.toolBar.addSeparator()
469
        self.toolBar.addAction(self.actionLine)
470
        self.toolBar.addAction(self.actionInitialize)
471
        self.toolBar.addSeparator()
472
        self.toolBar.addAction(self.actionCalculation)
473
        self.toolBar.addAction(self.actionGenerateReport)
474
        self.toolBar.addSeparator()
475
        self.toolBar.addAction(self.actionZoom)
476
        self.toolBar.addAction(self.actionFitWindow)
467 477
        self.menu.addAction(self.actionNew)
468 478
        self.menu.addAction(self.actionOpen)
469 479
        self.menu.addAction(self.actionSave)
......
481 491
        self.menuTool.addSeparator()
482 492
        self.menuTool.addAction(self.actionOptions)
483 493
        self.menuTool.addSeparator()
484
        self.menuAdmin.addAction(self.actionSymbol_Editor)
485 494
        self.menubar.addAction(self.menu.menuAction())
486 495
        self.menubar.addAction(self.menu_3.menuAction())
487 496
        self.menubar.addAction(self.menuTool.menuAction())
488
        self.menubar.addAction(self.menuAdmin.menuAction())
489
        self.toolBar.addAction(self.actionNew)
490
        self.toolBar.addAction(self.actionOpen)
491
        self.toolBar.addAction(self.actionSave)
492
        self.toolBar.addSeparator()
493
        self.toolBar.addAction(self.actionLine)
494
        self.toolBar.addAction(self.actionInitialize)
495
        self.toolBar.addSeparator()
496
        self.toolBar.addAction(self.actionCalculation)
497
        self.toolBar.addAction(self.actionGenerateReport)
498
        self.toolBar.addSeparator()
499
        self.toolBar.addAction(self.actionZoom)
500
        self.toolBar.addAction(self.actionFitWindow)
501 497

  
502 498
        self.retranslateUi(MainWindow)
503 499
        self.tabWidget.setCurrentIndex(0)
......
505 501

  
506 502
    def retranslateUi(self, MainWindow):
507 503
        _translate = QtCore.QCoreApplication.translate
508
        self.menu.setTitle(_translate("MainWindow", "File"))
509
        self.menuTheme.setTitle(_translate("MainWindow", "Theme"))
510
        self.menuLanguage.setTitle(_translate("MainWindow", "Language"))
511
        self.menu_3.setTitle(_translate("MainWindow", "View"))
512
        self.menuTool.setTitle(_translate("MainWindow", "Tools"))
513
        self.menuAdmin.setTitle(_translate("MainWindow", "Admin"))
514 504
        self.dockWidgetSymbolExplorer.setWindowTitle(_translate("MainWindow", "Symbol Explorer"))
515 505
        self.dockWidgetDrawingExplorer.setWindowTitle(_translate("MainWindow", "Drawing Explorer"))
516 506
        self.treeWidgetDrawingList.setSortingEnabled(True)
......
521 511
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabLogs), _translate("MainWindow", "Logs"))
522 512
        self.toolBar.setWindowTitle(_translate("MainWindow", "Main Toolbar"))
523 513
        self.dockWidget.setWindowTitle(_translate("MainWindow", "Output Explorer"))
514
        self.menu.setTitle(_translate("MainWindow", "File"))
515
        self.menuTheme.setTitle(_translate("MainWindow", "Theme"))
516
        self.menuLanguage.setTitle(_translate("MainWindow", "Language"))
517
        self.menu_3.setTitle(_translate("MainWindow", "View"))
518
        self.menuTool.setTitle(_translate("MainWindow", "Tools"))
524 519
        self.actionClose.setText(_translate("MainWindow", "Exit"))
525 520
        self.actionClose.setToolTip(_translate("MainWindow", "Exit"))
526 521
        self.actionRecognition.setText(_translate("MainWindow", "Recognize Eng. Info."))
HYTOS/HYTOS/PressureVariation.py
48 48
        self.ui = PressureVariation_UI.Ui_Dialog()
49 49
        self.ui.setupUi(self)
50 50
        self.units = None
51

  
51
        self.item = None
52 52
        self.init_units()
53 53
        self.initialize()
54 54

  
55
    def show_dialog(self, data):
55
    def show_dialog(self, item):
56 56
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
57 57

  
58
        self.load_data(data)
58
        self.item = item
59
        self.load_data()
59 60

  
60 61
        return self.exec_()
61 62

  
......
110 111
        self.ui.tableWidget.resizeRowsToContents()
111 112
        self.ui.tableWidget.resizeColumnsToContents()
112 113

  
113
    def load_data(self, data):
114
    def load_data(self):
115
        data = self.item.mixed_calculation_result
114 116
        for no in range(data.no):
115 117
            element = data.element[no] if no in data.element else None
116 118
            inside_diameter = round(data.inside_diameter[no], 3) if no in data.inside_diameter else None
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py
55 55
            self._stream_no_text = None
56 56

  
57 57
            self._fittings = None
58
            self._geometry = None
58
            self._mixed_geometry = None
59
            self._mixed_calculation_result = None
59 60

  
60 61
            self.transfer = Transfer()
61 62
            self.setZValue(QEngineeringStreamlineItem.ZVALUE)
......
82 83
        self._fittings = value
83 84

  
84 85
    @property
85
    def geometry(self):
86
    def mixed_geometry(self):
86 87
        """ return fittings """
87
        return self._geometry
88
        return self._mixed_geometry
88 89

  
89
    @geometry.setter
90
    def geometry(self, value):
90
    @mixed_geometry.setter
91
    def mixed_geometry(self, value):
91 92
        """ set fittings with given value """
92
        self._geometry = value
93
        self._mixed_geometry = value
94

  
95
    @property
96
    def mixed_calculation_result(self):
97
        return self._mixed_calculation_result
98

  
99
    @mixed_calculation_result.setter
100
    def mixed_calculation_result(self, value):
101
        self._mixed_calculation_result = value
93 102

  
94 103
    @property
95 104
    def stream_no(self):
......
247 256
        self._pt = None
248 257
        self.isCreated = False
249 258

  
250
    def set_geometry(self):
259
    def set_mixed_geometry(self):
251 260
        from AppDocData import AppDocData
252 261

  
253
        geometry = []
262
        mixed_geometry = []
254 263

  
255 264
        app_doc_data = AppDocData.instance()
256 265
        geometry_input = app_doc_data.get_geometry_input(self.uid)
257 266
        for row in geometry_input:
258
            geometry.append((row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9]))
267
            mixed_geometry.append((row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9]))
259 268

  
260
        self.geometry = geometry
269
        self.mixed_geometry = mixed_geometry
261 270

  
262 271
    def set_fittings(self):
263 272
        from AppDocData import AppDocData
......
907 916
                        res.append((sql, tuple(param)))
908 917

  
909 918
            # save geometry to database
910
            if self.geometry:
911
                for row in self.geometry:
919
            if self.mixed_geometry:
920
                for row in self.mixed_geometry:
912 921
                    cols = ['UID', 'Components_UID', 'Element', 'Nominal_Pipe_Size', 'Schedule_No', 'Inside_Pipe_Size',
913 922
                            'Roughness', 'Length', 'Angle', 'RPD', 'D1_D2', 'k']
914 923
                    values = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
......
959 968
            item.build_connectors(connectorItems, pointsUids)
960 969
            item.build_path()
961 970
            item.set_fittings()
962
            item.set_geometry()
971
            item.set_mixed_geometry()
963 972
            item.update()
964 973

  
965 974
        except Exception as ex:
HYTOS/HYTOS/StreamDataDialog.py
497 497
        table.resizeColumnsToContents()
498 498
        table.resizeRowsToContents()
499 499

  
500
    def show_result_dialog(self, result):
500
    def show_result_dialog(self):
501 501
        from PressureVariation import QPressureVariation
502 502

  
503 503
        dlg = QPressureVariation()
504
        dlg.show_dialog(result)
504
        dlg.show_dialog(self.item)
505 505

  
506 506
    def show_copy_stream_dialog(self):
507 507
        from CopyStreamData import QCopyStreamData
......
534 534
                process['v_viscosity']):
535 535
                if is_not_blank(process['v_density']):
536 536
                    if is_not_blank(process['tp_pressure']):
537
                        result = Calculation_2Phase(self.item, process, self.ui.tableWidget_GeometryData_Mixed)
538
                        self.show_result_dialog(result)
537
                        self.item.mixed_calculation_result = Calculation_2Phase(self.item, process, self.ui.tableWidget_GeometryData_Mixed)
538
                        self.show_result_dialog()
539 539
                    else:
540 540
                        QMessageBox.information(self, self.tr("Notice"), self.tr("Please input the [Start pressure] !"))
541 541
                        return
542 542
                else:
543 543
                    if is_not_blank(process['tp_pressure']) and is_not_blank(process['v_temp']) and is_not_blank(
544 544
                            process['v_mw']) and is_not_blank(process['v_z']):
545
                        result = Calculation_2Phase(self.item, process, self.ui.tableWidget_GeometryData_Mixed)
546
                        self.show_result_dialog(result)
545
                        self.item.mixed_calculation_result = Calculation_2Phase(self.item, process, self.ui.tableWidget_GeometryData_Mixed)
546
                        self.show_result_dialog()
547 547
                    else:
548 548
                        QMessageBox.information(self, self.tr("Notice"), self.tr("Please input [Vapor property] !"))
549 549
                        return
......
1175 1175
    def load_geometry(self):
1176 1176
        from AppDocData import AppDocData
1177 1177
        try:
1178
            geometry = self.item.geometry
1178
            geometry = self.item.mixed_geometry
1179 1179
            if geometry:
1180 1180
                for row in geometry:
1181 1181
                    row_count = self.ui.tableWidget_GeometryData_Mixed.rowCount()
......
1456 1456
                        element, nominal_pipe_size, schedule_no, inside_pipe_size, roughness, length, angle, rpd, d1_d2,
1457 1457
                        k))
1458 1458

  
1459
        self.item.geometry = geometry
1459
        self.item.mixed_geometry = geometry
1460 1460

  
1461 1461
    def accept(self):
1462 1462
        self.update_HMB()
HYTOS/HYTOS/UI/MainWindow.ui
35 35
    </item>
36 36
   </layout>
37 37
  </widget>
38
  <widget class="QMenuBar" name="menubar">
39
   <property name="geometry">
40
    <rect>
41
     <x>0</x>
42
     <y>0</y>
43
     <width>905</width>
44
     <height>21</height>
45
    </rect>
46
   </property>
47
   <widget class="QMenu" name="menu">
48
    <property name="title">
49
     <string>File</string>
50
    </property>
51
    <widget class="QMenu" name="menuTheme">
52
     <property name="title">
53
      <string>Theme</string>
54
     </property>
55
    </widget>
56
    <widget class="QMenu" name="menuLanguage">
57
     <property name="title">
58
      <string>Language</string>
59
     </property>
60
    </widget>
61
    <addaction name="actionNew"/>
62
    <addaction name="actionOpen"/>
63
    <addaction name="actionSave"/>
64
    <addaction name="separator"/>
65
    <addaction name="actionConfiguration"/>
66
    <addaction name="separator"/>
67
    <addaction name="menuTheme"/>
68
    <addaction name="menuLanguage"/>
69
    <addaction name="separator"/>
70
    <addaction name="actionClose"/>
71
   </widget>
72
   <widget class="QMenu" name="menu_3">
73
    <property name="title">
74
     <string>View</string>
75
    </property>
76
    <addaction name="actionZoom"/>
77
    <addaction name="actionFitWindow"/>
78
   </widget>
79
   <widget class="QMenu" name="menuTool">
80
    <property name="title">
81
     <string>Tools</string>
82
    </property>
83
    <addaction name="actionLine"/>
84
    <addaction name="actionInitialize"/>
85
    <addaction name="separator"/>
86
    <addaction name="actionOptions"/>
87
    <addaction name="separator"/>
88
   </widget>
89
   <widget class="QMenu" name="menuAdmin">
90
    <property name="title">
91
     <string>Admin</string>
92
    </property>
93
    <addaction name="actionSymbol_Editor"/>
94
   </widget>
95
   <addaction name="menu"/>
96
   <addaction name="menu_3"/>
97
   <addaction name="menuTool"/>
98
   <addaction name="menuAdmin"/>
99
  </widget>
100 38
  <widget class="QStatusBar" name="statusbar"/>
101 39
  <widget class="QDockWidget" name="dockWidgetSymbolExplorer">
102 40
   <property name="minimumSize">
......
323 261
    </layout>
324 262
   </widget>
325 263
  </widget>
264
  <widget class="QMenuBar" name="menubar">
265
   <property name="geometry">
266
    <rect>
267
     <x>0</x>
268
     <y>0</y>
269
     <width>905</width>
270
     <height>21</height>
271
    </rect>
272
   </property>
273
   <widget class="QMenu" name="menu">
274
    <property name="title">
275
     <string>File</string>
276
    </property>
277
    <widget class="QMenu" name="menuTheme">
278
     <property name="title">
279
      <string>Theme</string>
280
     </property>
281
    </widget>
282
    <widget class="QMenu" name="menuLanguage">
283
     <property name="title">
284
      <string>Language</string>
285
     </property>
286
    </widget>
287
    <addaction name="actionNew"/>
288
    <addaction name="actionOpen"/>
289
    <addaction name="actionSave"/>
290
    <addaction name="separator"/>
291
    <addaction name="actionConfiguration"/>
292
    <addaction name="separator"/>
293
    <addaction name="menuTheme"/>
294
    <addaction name="menuLanguage"/>
295
    <addaction name="separator"/>
296
    <addaction name="actionClose"/>
297
   </widget>
298
   <widget class="QMenu" name="menu_3">
299
    <property name="title">
300
     <string>View</string>
301
    </property>
302
    <addaction name="actionZoom"/>
303
    <addaction name="actionFitWindow"/>
304
   </widget>
305
   <widget class="QMenu" name="menuTool">
306
    <property name="title">
307
     <string>Tools</string>
308
    </property>
309
    <addaction name="actionLine"/>
310
    <addaction name="actionInitialize"/>
311
    <addaction name="separator"/>
312
    <addaction name="actionOptions"/>
313
    <addaction name="separator"/>
314
   </widget>
315
   <addaction name="menu"/>
316
   <addaction name="menu_3"/>
317
   <addaction name="menuTool"/>
318
  </widget>
326 319
  <action name="actionClose">
327 320
   <property name="icon">
328 321
    <iconset resource="../res/Resource.qrc">

내보내기 Unified diff

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