개정판 97846ba5
issue #000 Export_To_PAP.py 수정
1. PAP로 Export 될 데이터 샘플 생성중.
Change-Id: I6e552aa3f4e56ba8c38750f03ed2401574460daa
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
40 | 40 |
Error = 2 |
41 | 41 |
Information = 3 |
42 | 42 |
|
43 |
class Inst_Item: |
|
44 |
def __init__(self, itemNo, type, dataSource): |
|
45 |
self.itemNo = itemNo |
|
46 |
self.type = type |
|
47 |
self.dataSource = dataSource |
|
48 |
self.attributes = [] |
|
49 |
def printf(self): |
|
50 |
for attr in self.attributes: |
|
51 |
print(f"""{attr.table}.{attr.column} : {attr.value} """) |
|
52 |
|
|
53 |
class Inst_Attribute: |
|
54 |
def __init__(self, name, column, value): |
|
55 |
self.table = name |
|
56 |
self.column = column |
|
57 |
self.value = value |
|
58 |
|
|
43 | 59 |
class PAPUploadInformation: |
44 | 60 |
def __init__(self,param_project_uid = '', |
45 | 61 |
param_projectno = '', |
HYTOS/HYTOS/Export_To_PAP.py | ||
---|---|---|
6 | 6 |
from PyQt5.QtGui import QMovie |
7 | 7 |
from PyQt5.QtCore import * |
8 | 8 |
from SymbolSvgItem import SymbolSvgItem |
9 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
|
9 | 10 |
import os |
10 | 11 |
import asyncio |
11 | 12 |
import aiohttp |
... | ... | |
83 | 84 |
self.UID = '' |
84 | 85 |
self.Name = '' |
85 | 86 |
|
87 |
# const class |
|
88 |
class Valve_Datacase(): |
|
89 |
Maximum_Flowrate_Case = "Maximum Flowrate Case" |
|
90 |
Normal_Flowrate_Case = "Normal Flowrate Case" |
|
91 |
Minimum_Flowrate_Case = "Minimum Flowrate Case" |
|
92 |
N_A = "N/A" |
|
93 |
|
|
94 |
class Pump_Datacase(): |
|
95 |
Rated_Flow_Case = "Rated Flow Case" |
|
96 |
Maximum_Flow_Case = "Maximum Flow Case" |
|
97 |
N_A = "N/A" |
|
98 |
|
|
99 |
class Compressor_Datacase(): |
|
100 |
Design_Case = "Design Case" |
|
101 |
N_A = "N/A" |
|
86 | 102 |
|
87 | 103 |
class MappingsDelegate(QStyledItemDelegate): |
88 |
def __init__(self, parent=None, papInfomationItem=None): |
|
104 |
def __init__(self, parent=None, papInfomationItem=None, export_to_pap_main =None):
|
|
89 | 105 |
QStyledItemDelegate.__init__(self, parent) |
90 | 106 |
self.papInfomationItem = papInfomationItem |
107 |
self.export_to_pap_main = export_to_pap_main |
|
91 | 108 |
|
92 | 109 |
def createEditor(self, parent, option, index): |
93 | 110 |
editor = None |
... | ... | |
97 | 114 |
datacase = [] |
98 | 115 |
editor = QComboBox(parent) |
99 | 116 |
if item.text() == "Pump": |
100 |
datacase = ["Rated Flow Case", "Maximum Flow Case","N/A"]
|
|
117 |
datacase =self.export_to_pap_main.pump_datacase
|
|
101 | 118 |
elif item.text() == "Compressor": |
102 |
datacase = ["Design Case", "N/A"]
|
|
119 |
datacase =self.export_to_pap_main.compressor_datacase
|
|
103 | 120 |
editor.setEditable(True) |
104 | 121 |
elif item.text() == "Valve": |
105 |
datacase = ["Maximum Flowrate Case", "Normal Flowrate Case", "Minimum Flowrate Case","N/A"]
|
|
122 |
datacase =self.export_to_pap_main.valve_datacase
|
|
106 | 123 |
else: |
107 | 124 |
pass |
108 | 125 |
editor.addItems([str(datacase[_index]) for _index in range(len(datacase))]) |
109 | 126 |
|
110 | 127 |
return editor if editor else super(MappingsDelegate, self).createEditor(parent, option, index) |
111 | 128 |
|
129 |
|
|
112 | 130 |
class QExport_To_PAP(QDialog): |
113 | 131 |
def __init__(self): |
114 | 132 |
QDialog.__init__(self) |
... | ... | |
128 | 146 |
self.project_list = [] |
129 | 147 |
self.papInfomation = app_doc_data.getPAPInfomations() |
130 | 148 |
self.papInfomationItem = app_doc_data.getPAPInfomationItems() |
131 |
#self.schema_PAPUploadInfomationtable() |
|
149 |
self.pump_datacase = [Pump_Datacase.Rated_Flow_Case, |
|
150 |
Pump_Datacase.Maximum_Flow_Case, |
|
151 |
Pump_Datacase.N_A] |
|
152 |
self.compressor_datacase = [Compressor_Datacase.Design_Case, |
|
153 |
Compressor_Datacase.N_A] |
|
154 |
self.valve_datacase = [Valve_Datacase.Maximum_Flowrate_Case, |
|
155 |
Valve_Datacase.Normal_Flowrate_Case, |
|
156 |
Valve_Datacase.Minimum_Flowrate_Case, |
|
157 |
Valve_Datacase.N_A] |
|
132 | 158 |
self.send_api(end_point = "/api/Projects", method= "GET") |
133 | 159 |
self.data_load() |
134 | 160 |
|
... | ... | |
275 | 301 |
self.selection_model = self.ui.tableView_upload_item_list.selectionModel() |
276 | 302 |
# Set Selection Model |
277 | 303 |
self.ui.tableView_upload_item_list.setSortingEnabled(True) |
278 |
self.ui.tableView_upload_item_list.setItemDelegate(MappingsDelegate(self.ui.tableView_upload_item_list, select_papinfomation)) |
|
304 |
self.ui.tableView_upload_item_list.setItemDelegate(MappingsDelegate(self.ui.tableView_upload_item_list, select_papinfomation, self))
|
|
279 | 305 |
self.ui.tableView_upload_item_list.setColumnHidden(0, True) |
280 | 306 |
self.ui.tableView_upload_item_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) |
281 | 307 |
|
... | ... | |
344 | 370 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
345 | 371 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
346 | 372 |
|
347 |
|
|
348 |
|
|
349 | 373 |
async def run_connection(self, projectNo): |
350 | 374 |
task = asyncio.create_task(self.connection(projectNo)) |
351 | 375 |
result = await task |
... | ... | |
357 | 381 |
QTimer.singleShot(500, self.close_animation) |
358 | 382 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
359 | 383 |
|
360 |
|
|
361 | 384 |
@asyncio.coroutine |
362 | 385 |
async def connection(self,projectNo): |
363 | 386 |
app_doc_data = AppDocData.instance() |
... | ... | |
367 | 390 |
return await resp.json() |
368 | 391 |
|
369 | 392 |
def accept(self): |
393 |
inst_Items = [] |
|
394 |
if self.ui.tableView_upload_item_list.model().rowCount() > 0: |
|
395 |
items = [item for item in App.mainWnd().graphicsView.scene.items() if type(item) is SymbolSvgItem] |
|
396 |
|
|
397 |
for row in range(self.ui.tableView_upload_item_list.model().rowCount()): |
|
398 |
index = self.ui.tableView_upload_item_list.model().index(row, 0) |
|
399 |
uid_data = self.ui.tableView_upload_item_list.model().data(index, Qt.DisplayRole) |
|
400 |
datacase_index = self.ui.tableView_upload_item_list.model().index(row, 3) |
|
401 |
datacase_data = self.ui.tableView_upload_item_list.model().data(datacase_index, Qt.DisplayRole) |
|
402 |
item = [item for item in items if str(item.uid) == uid_data] |
|
403 |
|
|
404 |
if item: |
|
405 |
symbolItem = item[0] |
|
406 |
ItemNo = symbolItem.tag_no |
|
407 |
DataSource = "HYTOS" |
|
408 |
if symbolItem.type not in ["Valve", "Compressor", "Pump"]: |
|
409 |
continue |
|
410 |
|
|
411 |
inst_item = Inst_Item(ItemNo, symbolItem.type, DataSource) |
|
412 |
connectedItem_connectors = [x for x in symbolItem.connectors if x.connectedItem is not None] |
|
413 |
in_connectors = [conn.connectedItem for conn in connectedItem_connectors |
|
414 |
if conn.connectedItem and int(conn.connectedItem._conn_index) == 2] |
|
415 |
if symbolItem.type == "Valve": |
|
416 |
if in_connectors: |
|
417 |
if type(in_connectors[0].parent) is QEngineeringStreamlineItem: |
|
418 |
streamLine = in_connectors[0].parent |
|
419 |
if streamLine.data: |
|
420 |
streamLine_hmb_data = streamLine.data |
|
421 |
suctp = 0 |
|
422 |
discp = 0 |
|
423 |
diffp = 0 |
|
424 |
if symbolItem.attribute: |
|
425 |
suctp = round(symbolItem.attribute['Suct.P'], 3) |
|
426 |
discp = round(symbolItem.attribute['Disc.P'], 3) |
|
427 |
diffp = round(symbolItem.attribute['Diff.P'], 3) |
|
428 |
if streamLine_hmb_data.phase_type.upper() != 'Mixed'.upper(): |
|
429 |
flowrate_mass = streamLine_hmb_data.flowrate_mass |
|
430 |
density = streamLine_hmb_data.density |
|
431 |
|
|
432 |
viscosity = streamLine_hmb_data.viscosity |
|
433 |
temperature = streamLine_hmb_data.temperature |
|
434 |
molecular_weight = streamLine_hmb_data.molecular_weight |
|
435 |
specific_heat_ratio = streamLine_hmb_data.specific_heat_ratio |
|
436 |
compress_factor = streamLine_hmb_data.compress_factor |
|
437 |
|
|
438 |
if datacase_data == Valve_Datacase.Maximum_Flowrate_Case: |
|
439 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","OperatingPressrueMaxIn", suctp)) |
|
440 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","OperatingPressrueMaxOut", discp)) |
|
441 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","DifferentialPressMax",diffp)) |
|
442 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","FlowrateMax1", flowrate_mass)) |
|
443 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","DensityMax1", density)) |
|
444 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMax1", viscosity)) |
|
445 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureMax", temperature)) |
|
446 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "MolecularWeightNor", molecular_weight)) |
|
447 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "SpecificHeatRatio", specific_heat_ratio)) |
|
448 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "Compressibility", compress_factor)) |
|
449 |
elif datacase_data == Valve_Datacase.Normal_Flowrate_Case: |
|
450 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","OperatingPressrueNorIn", suctp)) |
|
451 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","OperatingPressrueNorOut",discp)) |
|
452 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","DifferentialPressNor", diffp)) |
|
453 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","FlowrateNor1", flowrate_mass)) |
|
454 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","DensityNor1", density)) |
|
455 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityNor1", viscosity)) |
|
456 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureNor", temperature)) |
|
457 |
elif datacase_data == Valve_Datacase.Minimum_Flowrate_Case: |
|
458 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","OperatingPressrueMinIn", suctp)) |
|
459 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","OperatingPressrueMinOut",discp)) |
|
460 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","DifferentialPressMin", diffp)) |
|
461 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","FlowrateMin1", flowrate_mass)) |
|
462 |
inst_item.attributes.append(Inst_Attribute("Inst_CV","DensityMin1", density)) |
|
463 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMin1", viscosity)) |
|
464 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureMin", temperature)) |
|
465 |
else: |
|
466 |
flowrate_volume = streamLine_hmb_data.flowrate_volume |
|
467 |
density = streamLine_hmb_data.density |
|
468 |
viscosity = streamLine_hmb_data.viscosity |
|
469 |
temperature = streamLine_hmb_data.temperature |
|
470 |
molecular_weight = streamLine_hmb_data.molecular_weight |
|
471 |
specific_heat_ratio = streamLine_hmb_data.specific_heat_ratio |
|
472 |
compress_factor = streamLine_hmb_data.compress_factor |
|
473 |
|
|
474 |
##vapor |
|
475 |
vapor_flowrate_mass = streamLine_hmb_data.vapor_flowrate_mass |
|
476 |
vapor_density = streamLine_hmb_data.vapor_density |
|
477 |
vapor_viscosity = streamLine_hmb_data.vapor_viscosity |
|
478 |
vapor_temperature = streamLine_hmb_data.vapor_temperature |
|
479 |
vapor_molecular_weight = streamLine_hmb_data.vapor_molecular_weight |
|
480 |
vapor_compress_factor = streamLine_hmb_data.vapor_compress_factor |
|
481 |
|
|
482 |
##liquid |
|
483 |
liquid_flowrate_mass = streamLine_hmb_data.liquid_flowrate_mass |
|
484 |
liquid_density = streamLine_hmb_data.liquid_density |
|
485 |
liquid_viscosity = streamLine_hmb_data.liquid_viscosity |
|
486 |
|
|
487 |
if datacase_data == Valve_Datacase.Maximum_Flowrate_Case: |
|
488 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMaxIn", suctp)) |
|
489 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMaxOut", discp)) |
|
490 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DifferentialPressMax", diffp)) |
|
491 |
|
|
492 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMax1", vapor_flowrate_mass)) |
|
493 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DensityMax1", vapor_density)) |
|
494 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMax1", vapor_viscosity)) |
|
495 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureMax", vapor_temperature)) |
|
496 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "MolecularWeightNor", vapor_molecular_weight)) |
|
497 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "Compressibility", vapor_compress_factor)) |
|
498 |
|
|
499 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMax2", liquid_flowrate_mass)) |
|
500 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DensityMax2", liquid_density)) |
|
501 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMax2", liquid_viscosity)) |
|
502 |
elif datacase_data == Valve_Datacase.Normal_Flowrate_Case: |
|
503 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueNorIn", suctp)) |
|
504 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueNorOut", discp)) |
|
505 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DifferentialPressNor", diffp)) |
|
506 |
|
|
507 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateNor1", vapor_flowrate_mass)) |
|
508 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DensityNor1", vapor_density)) |
|
509 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityNor1", vapor_viscosity)) |
|
510 |
|
|
511 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateNor2", liquid_flowrate_mass)) |
|
512 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DensityNor2", liquid_density)) |
|
513 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityNor2", liquid_viscosity)) |
|
514 |
elif datacase_data == Valve_Datacase.Minimum_Flowrate_Case: |
|
515 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMinIn", suctp)) |
|
516 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMinOut", discp)) |
|
517 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DifferentialPressMin", diffp)) |
|
518 |
|
|
519 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMin1", vapor_flowrate_mass)) |
|
520 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DensityMin1", vapor_density)) |
|
521 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMin1", vapor_viscosity)) |
|
522 |
|
|
523 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMin2", liquid_flowrate_mass)) |
|
524 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "DensityMin2", liquid_density)) |
|
525 |
inst_item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMin2", liquid_viscosity)) |
|
526 |
inst_Items.append(inst_item) |
|
527 |
elif symbolItem.type == "Compressor": |
|
528 |
inletPressure = 0 |
|
529 |
dischargePress = 0 |
|
530 |
diffPressure = 0 |
|
531 |
if symbolItem.attribute: |
|
532 |
attr = symbolItem.attribute |
|
533 |
if len(attr) > 0: |
|
534 |
inletPressure = round(attr['Suct.P'], 3) |
|
535 |
dischargePress = round(attr['Disc.P'], 3) |
|
536 |
diffPressure = round(attr['Diff.P'], 3) |
|
537 |
|
|
538 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "InletPressure", inletPressure)) |
|
539 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "DischargePress", dischargePress)) |
|
540 |
inst_item.attributes.append(Inst_Attribute("eq_rotating", "DiffPressure", diffPressure)) |
|
541 |
|
|
542 |
if in_connectors: |
|
543 |
if type(in_connectors[0].parent) is QEngineeringStreamlineItem: |
|
544 |
streamLine = in_connectors[0].parent |
|
545 |
if streamLine.data: |
|
546 |
flowrate_mass = streamLine_hmb_data.flowrate_mass |
|
547 |
flowrate_volume = streamLine_hmb_data.flowrate_volume |
|
548 |
density = streamLine_hmb_data.density |
|
549 |
viscosity = streamLine_hmb_data.viscosity |
|
550 |
temperature = streamLine_hmb_data.temperature |
|
551 |
molecular_weight = streamLine_hmb_data.molecular_weight |
|
552 |
specific_heat_ratio = streamLine_hmb_data.specific_heat_ratio |
|
553 |
compress_factor = streamLine_hmb_data.compress_factor |
|
554 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "WeightFlow", flowrate_mass)) |
|
555 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "InletCapacity", flowrate_volume)) |
|
556 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "Inlet_Density", density)) |
|
557 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "InletTemp", temperature)) |
|
558 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "MolecularWeight", molecular_weight)) |
|
559 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "InletCpCv", specific_heat_ratio)) |
|
560 |
inst_item.attributes.append(Inst_Attribute("eq_compressor", "InletCompressibility", compress_factor)) |
|
561 |
elif symbolItem.type == "Pump": |
|
562 |
suctionPressRated = 0 |
|
563 |
dischargePressRated = 0 |
|
564 |
differentialPressRated = 0 |
|
565 |
differentialHeadRated = 0 |
|
566 |
nPSHaRated = 0 |
|
567 |
vaporPressRated = 0 |
|
568 |
if symbolItem.attribute: |
|
569 |
attr = symbolItem.attribute |
|
570 |
if len(attr) > 0: |
|
571 |
suctionPressRated = round(attr['Suct.P'], 3) |
|
572 |
dischargePressRated = round(attr['Disc.P'], 3) |
|
573 |
differentialPressRated = round(attr['Diff.P'], 3) |
|
574 |
differentialHeadRated = round(attr['Head'], 3) |
|
575 |
nPSHaRated = round(attr['NPSHa'], 3) |
|
576 |
vaporPressRated = attr['Vap. P'] |
|
577 |
|
|
578 |
inst_item.attributes.append( |
|
579 |
Inst_Attribute("eq_compressor", "InletPressure", inletPressure)) |
|
580 |
inst_item.attributes.append( |
|
581 |
Inst_Attribute("eq_compressor", "DischargePress", dischargePress)) |
|
582 |
inst_item.attributes.append(Inst_Attribute("eq_rotating", "DiffPressure", diffPressure)) |
|
583 |
|
|
584 |
if in_connectors: |
|
585 |
if type(in_connectors[0].parent) is QEngineeringStreamlineItem: |
|
586 |
streamLine = in_connectors[0].parent |
|
587 |
if streamLine.data: |
|
588 |
flowrate_volume = streamLine_hmb_data.flowrate_volume |
|
589 |
density = streamLine_hmb_data.density |
|
590 |
viscosity = streamLine_hmb_data.viscosity |
|
591 |
temperature = streamLine_hmb_data.temperature |
|
592 |
|
|
593 |
inst_item.printf() |
|
594 |
else: |
|
595 |
continue |
|
596 |
|
|
370 | 597 |
QDialog.accept(self) |
371 | 598 |
|
372 | 599 |
def reject(self): |
내보내기 Unified diff