135 |
135 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setIcon(QtGui.QIcon(':/images/OK.svg'))
|
136 |
136 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setText("Update")
|
137 |
137 |
self.ui.buttonBox.button(QDialogButtonBox.Cancel).setIcon(QtGui.QIcon(':/images/Cancel.svg'))
|
|
138 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
|
138 |
139 |
self.ui.btnSave.clicked.connect(self.onSavePapUpdateInfomation)
|
139 |
140 |
self.ui.btnSetCalculationCase.clicked.connect(self.onSettingCalculationCase)
|
140 |
141 |
self.ui.comboBox_select_PAP_Project.currentIndexChanged.connect(self.connect_api)
|
... | ... | |
392 |
393 |
def accept(self):
|
393 |
394 |
inst_Items = []
|
394 |
395 |
if self.ui.tableView_upload_item_list.model().rowCount() > 0:
|
|
396 |
app_doc_data = AppDocData.instance()
|
395 |
397 |
items = [item for item in App.mainWnd().graphicsView.scene.items() if type(item) is SymbolSvgItem]
|
396 |
398 |
|
397 |
399 |
for row in range(self.ui.tableView_upload_item_list.model().rowCount()):
|
... | ... | |
402 |
404 |
item = [item for item in items if str(item.uid) == uid_data]
|
403 |
405 |
|
404 |
406 |
if item:
|
|
407 |
if datacase_data == "N/A" or datacase_data=='':
|
|
408 |
continue
|
|
409 |
if item[0].type not in ["Valve", "Compressor", "Pump"]:
|
|
410 |
continue
|
405 |
411 |
symbolItem = item[0]
|
406 |
412 |
inst_Item = Inst_Item(itemNo =symbolItem.tag_no, type = symbolItem.type, dataSource = "HYTOS")
|
407 |
413 |
|
408 |
|
if symbolItem.type not in ["Valve", "Compressor", "Pump"]:
|
409 |
|
continue
|
410 |
414 |
|
411 |
|
streamLine = None
|
412 |
415 |
connectedItem_connectors = [x for x in symbolItem.connectors if x.connectedItem is not None]
|
413 |
416 |
in_connectors = [conn.connectedItem for conn in connectedItem_connectors
|
414 |
417 |
if conn.connectedItem and int(conn.connectedItem._conn_index) == 2]
|
|
418 |
inlet_streamLine = None
|
415 |
419 |
if in_connectors:
|
416 |
420 |
if type(in_connectors[0].parent) is QEngineeringStreamlineItem:
|
417 |
|
streamLine = in_connectors[0].parent
|
|
421 |
inlet_streamLine = in_connectors[0].parent
|
418 |
422 |
|
419 |
|
if symbolItem.type == "Valve":
|
420 |
|
if streamLine:
|
|
423 |
if symbolItem.type.upper() == "Valve".upper():
|
|
424 |
if inlet_streamLine:
|
421 |
425 |
suctp = 0
|
422 |
426 |
discp = 0
|
423 |
427 |
diffp = 0
|
424 |
|
if streamLine.data:
|
|
428 |
if inlet_streamLine.data:
|
425 |
429 |
if symbolItem.attribute:
|
426 |
|
suctp = round(symbolItem.attribute['Suct.P'], 3)
|
427 |
|
discp = round(symbolItem.attribute['Disc.P'], 3)
|
428 |
|
diffp = round(symbolItem.attribute['Diff.P'], 3)
|
|
430 |
if 'Suct.P' in symbolItem.attribute.keys():
|
|
431 |
suctp = round(symbolItem.attribute['Suct.P'], 3)
|
|
432 |
if 'Disc.P' in symbolItem.attribute.keys():
|
|
433 |
discp = round(symbolItem.attribute['Disc.P'], 3)
|
|
434 |
if 'Diff.P' in symbolItem.attribute.keys():
|
|
435 |
diffp = round(symbolItem.attribute['Diff.P'], 3)
|
|
436 |
|
429 |
437 |
if datacase_data == Valve_Datacase.Maximum_Flowrate_Case:
|
430 |
438 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMaxIn", suctp))
|
431 |
439 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMaxOut", discp))
|
... | ... | |
439 |
447 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "OperatingPressrueMinOut", discp))
|
440 |
448 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "DifferentialPressMin", diffp))
|
441 |
449 |
|
442 |
|
if streamLine.data.phase_type.upper() != 'Mixed'.upper():
|
443 |
|
flowrate_mass = streamLine.data.flowrate_mass
|
444 |
|
density = streamLine.data.density
|
445 |
|
viscosity = streamLine.data.viscosity
|
446 |
|
temperature = streamLine.data.temperature
|
447 |
|
molecular_weight = streamLine.data.molecular_weight
|
448 |
|
specific_heat_ratio = streamLine.data.specific_heat_ratio
|
449 |
|
compress_factor = streamLine.data.compress_factor
|
|
450 |
if inlet_streamLine.data.phase_type.upper() != 'Mixed'.upper():
|
|
451 |
flowrate_mass = inlet_streamLine.data.flowrate_mass
|
|
452 |
density = inlet_streamLine.data.density
|
|
453 |
viscosity = inlet_streamLine.data.viscosity
|
|
454 |
temperature = inlet_streamLine.data.temperature
|
|
455 |
molecular_weight = inlet_streamLine.data.molecular_weight
|
|
456 |
specific_heat_ratio = inlet_streamLine.data.specific_heat_ratio
|
|
457 |
compress_factor = inlet_streamLine.data.compress_factor
|
450 |
458 |
|
451 |
459 |
if datacase_data == Valve_Datacase.Maximum_Flowrate_Case:
|
452 |
|
inst_Item.attributes.append(Inst_Attribute("Inst_CV","FlowrateMax1", flowrate_mass))
|
453 |
|
inst_Item.attributes.append(Inst_Attribute("Inst_CV","DensityMax1", density))
|
|
460 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMax1", flowrate_mass))
|
|
461 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "DensityMax1", density))
|
454 |
462 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMax1", viscosity))
|
455 |
463 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureMax", temperature))
|
456 |
464 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "MolecularWeightNor", molecular_weight))
|
457 |
465 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "SpecificHeatRatio", specific_heat_ratio))
|
458 |
466 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "Compressibility", compress_factor))
|
459 |
467 |
elif datacase_data == Valve_Datacase.Normal_Flowrate_Case:
|
460 |
|
inst_Item.attributes.append(Inst_Attribute("Inst_CV","FlowrateNor1", flowrate_mass))
|
461 |
|
inst_Item.attributes.append(Inst_Attribute("Inst_CV","DensityNor1", density))
|
|
468 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateNor1", flowrate_mass))
|
|
469 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "DensityNor1", density))
|
462 |
470 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityNor1", viscosity))
|
463 |
471 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureNor", temperature))
|
464 |
472 |
elif datacase_data == Valve_Datacase.Minimum_Flowrate_Case:
|
465 |
|
inst_Item.attributes.append(Inst_Attribute("Inst_CV","FlowrateMin1", flowrate_mass))
|
466 |
|
inst_Item.attributes.append(Inst_Attribute("Inst_CV","DensityMin1", density))
|
|
473 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMin1", flowrate_mass))
|
|
474 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "DensityMin1", density))
|
467 |
475 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "ViscosityMin1", viscosity))
|
468 |
476 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "OperatingTemperatureMin", temperature))
|
469 |
477 |
else:
|
470 |
|
flowrate_volume = streamLine.data.flowrate_volume
|
471 |
|
density = streamLine.data.density
|
472 |
|
viscosity = streamLine.data.viscosity
|
473 |
|
temperature = streamLine.data.temperature
|
474 |
|
molecular_weight = streamLine.data.molecular_weight
|
475 |
|
specific_heat_ratio = streamLine.data.specific_heat_ratio
|
476 |
|
compress_factor = streamLine.data.compress_factor
|
|
478 |
flowrate_volume = inlet_streamLine.data.flowrate_volume
|
|
479 |
density = inlet_streamLine.data.density
|
|
480 |
viscosity = inlet_streamLine.data.viscosity
|
|
481 |
temperature = inlet_streamLine.data.temperature
|
|
482 |
molecular_weight = inlet_streamLine.data.molecular_weight
|
|
483 |
specific_heat_ratio = inlet_streamLine.data.specific_heat_ratio
|
|
484 |
compress_factor = inlet_streamLine.data.compress_factor
|
477 |
485 |
|
478 |
486 |
##vapor
|
479 |
|
vapor_flowrate_mass = streamLine.data.vapor_flowrate_mass
|
480 |
|
vapor_density = streamLine.data.vapor_density
|
481 |
|
vapor_viscosity = streamLine.data.vapor_viscosity
|
482 |
|
vapor_temperature = streamLine.data.vapor_temperature
|
483 |
|
vapor_molecular_weight = streamLine.data.vapor_molecular_weight
|
484 |
|
vapor_compress_factor = streamLine.data.vapor_compress_factor
|
|
487 |
vapor_flowrate_mass = inlet_streamLine.data.vapor_flowrate_mass
|
|
488 |
vapor_density = inlet_streamLine.data.vapor_density
|
|
489 |
vapor_viscosity = inlet_streamLine.data.vapor_viscosity
|
|
490 |
vapor_temperature = inlet_streamLine.data.vapor_temperature
|
|
491 |
vapor_molecular_weight = inlet_streamLine.data.vapor_molecular_weight
|
|
492 |
vapor_compress_factor = inlet_streamLine.data.vapor_compress_factor
|
485 |
493 |
|
486 |
494 |
##liquid
|
487 |
|
liquid_flowrate_mass = streamLine.data.liquid_flowrate_mass
|
488 |
|
liquid_density = streamLine.data.liquid_density
|
489 |
|
liquid_viscosity = streamLine.data.liquid_viscosity
|
|
495 |
liquid_flowrate_mass = inlet_streamLine.data.liquid_flowrate_mass
|
|
496 |
liquid_density = inlet_streamLine.data.liquid_density
|
|
497 |
liquid_viscosity = inlet_streamLine.data.liquid_viscosity
|
490 |
498 |
|
491 |
499 |
if datacase_data == Valve_Datacase.Maximum_Flowrate_Case:
|
492 |
500 |
inst_Item.attributes.append(Inst_Attribute("Inst_CV", "FlowrateMax1", vapor_flowrate_mass))
|
... | ... | |
517 |
525 |
dischargePress = 0
|
518 |
526 |
diffPressure = 0
|
519 |
527 |
if symbolItem.attribute:
|
520 |
|
inletPressure = round(symbolItem.attribute['Suct.P'], 3)
|
521 |
|
dischargePress = round(symbolItem.attribute['Disc.P'], 3)
|
522 |
|
diffPressure = round(symbolItem.attribute['Diff.P'], 3)
|
|
528 |
if 'Suct.P' in symbolItem.attribute.keys():
|
|
529 |
inletPressure = round(symbolItem.attribute['Suct.P'], 3)
|
|
530 |
if 'Disc.P' in symbolItem.attribute.keys():
|
|
531 |
dischargePress = round(symbolItem.attribute['Disc.P'], 3)
|
|
532 |
if 'Diff.P' in symbolItem.attribute.keys():
|
|
533 |
diffPressure = round(symbolItem.attribute['Diff.P'], 3)
|
523 |
534 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "InletPressure", inletPressure))
|
524 |
535 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "DischargePress", dischargePress))
|
525 |
536 |
inst_Item.attributes.append(Inst_Attribute("eq_rotating", "DiffPressure", diffPressure))
|
526 |
|
if streamLine:
|
527 |
|
if streamLine.data:
|
528 |
|
flowrate_mass = streamLine.data.flowrate_mass
|
529 |
|
flowrate_volume = streamLine.data.flowrate_volume
|
530 |
|
density = streamLine.data.density
|
531 |
|
viscosity = streamLine.data.viscosity
|
532 |
|
temperature = streamLine.data.temperature
|
533 |
|
molecular_weight = streamLine.data.molecular_weight
|
534 |
|
specific_heat_ratio = streamLine.data.specific_heat_ratio
|
535 |
|
compress_factor = streamLine.data.compress_factor
|
|
537 |
if inlet_streamLine:
|
|
538 |
if inlet_streamLine.data:
|
|
539 |
flowrate_mass = inlet_streamLine.data.flowrate_mass
|
|
540 |
flowrate_volume = inlet_streamLine.data.flowrate_volume
|
|
541 |
density = inlet_streamLine.data.density
|
|
542 |
viscosity = inlet_streamLine.data.viscosity
|
|
543 |
temperature = inlet_streamLine.data.temperature
|
|
544 |
molecular_weight = inlet_streamLine.data.molecular_weight
|
|
545 |
specific_heat_ratio = inlet_streamLine.data.specific_heat_ratio
|
|
546 |
compress_factor = inlet_streamLine.data.compress_factor
|
536 |
547 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "WeightFlow", flowrate_mass))
|
537 |
548 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "InletCapacity", flowrate_volume))
|
538 |
549 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "Inlet_Density", density))
|
... | ... | |
540 |
551 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "MolecularWeight", molecular_weight))
|
541 |
552 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "InletCpCv", specific_heat_ratio))
|
542 |
553 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "InletCompressibility", compress_factor))
|
543 |
|
|
544 |
554 |
inst_Item.attributes.append(Inst_Attribute("eq_compressor", "OperatingCase", datacase_data))
|
545 |
|
|
546 |
555 |
elif symbolItem.type == "Pump":
|
547 |
556 |
suctionPressRated = 0
|
548 |
557 |
dischargePressRated = 0
|
... | ... | |
551 |
560 |
nPSHaRated = 0
|
552 |
561 |
vaporPressRated = 0
|
553 |
562 |
if symbolItem.attribute:
|
554 |
|
suctionPressRated = round(symbolItem.attribute['Suct.P'], 3)
|
555 |
|
dischargePressRated = round(symbolItem.attribute['Disc.P'], 3)
|
556 |
|
differentialPressRated = round(symbolItem.attribute['Diff.P'], 3)
|
557 |
|
differentialHeadRated = round(symbolItem.attribute['Head'], 3)
|
558 |
|
nPSHaRated = round(symbolItem.attribute['NPSHa'], 3)
|
559 |
|
vaporPressRated = symbolItem.attribute['Vap. P']
|
|
563 |
if 'Suct.P' in symbolItem.attribute.keys():
|
|
564 |
suctionPressRated = round(symbolItem.attribute['Suct.P'], 3)
|
|
565 |
if 'Disc.P' in symbolItem.attribute.keys():
|
|
566 |
dischargePressRated = round(symbolItem.attribute['Disc.P'], 3)
|
|
567 |
if 'Diff.P' in symbolItem.attribute.keys():
|
|
568 |
differentialPressRated = round(symbolItem.attribute['Diff.P'], 3)
|
|
569 |
if 'Head' in symbolItem.attribute.keys():
|
|
570 |
differentialHeadRated = round(symbolItem.attribute['Head'], 3)
|
|
571 |
if 'NPSHa' in symbolItem.attribute.keys():
|
|
572 |
nPSHaRated = round(symbolItem.attribute['NPSHa'], 3)
|
|
573 |
if 'Vap. P' in symbolItem.attribute.keys():
|
|
574 |
vaporPressRated = symbolItem.attribute['Vap. P']
|
560 |
575 |
if datacase_data == Pump_Datacase.Rated_Flow_Case:
|
561 |
576 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "SuctionPressRated", suctionPressRated))
|
562 |
577 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "DischargePressRated", dischargePressRated))
|
... | ... | |
564 |
579 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "DifferentialHeadRated", differentialHeadRated))
|
565 |
580 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "NPSHaRated", nPSHaRated))
|
566 |
581 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "VaporPressRated", vaporPressRated))
|
567 |
|
elif datacase_data == Pump_Datacase.N_A:
|
|
582 |
elif datacase_data == Pump_Datacase.Maximum_Flow_Case:
|
568 |
583 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "SuctionPressMax", suctionPressRated))
|
569 |
584 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "DischargePressMax", dischargePressRated))
|
570 |
585 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "DifferentialPressMax", differentialPressRated))
|
... | ... | |
572 |
587 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "NPSHaMax", nPSHaRated))
|
573 |
588 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "VaporPressMax", vaporPressRated))
|
574 |
589 |
|
575 |
|
if streamLine:
|
576 |
|
if streamLine.data:
|
577 |
|
flowrate_volume = streamLine.data.flowrate_volume
|
578 |
|
density = streamLine.data.density
|
579 |
|
viscosity = streamLine.data.viscosity
|
580 |
|
temperature = streamLine.data.temperature
|
|
590 |
if inlet_streamLine:
|
|
591 |
if inlet_streamLine.data:
|
|
592 |
flowrate_volume = inlet_streamLine.data.flowrate_volume
|
|
593 |
density = inlet_streamLine.data.density
|
|
594 |
viscosity = inlet_streamLine.data.viscosity
|
|
595 |
temperature = inlet_streamLine.data.temperature
|
581 |
596 |
if datacase_data == Pump_Datacase.Rated_Flow_Case:
|
582 |
597 |
inst_Item.attributes.append(Inst_Attribute("eq_rotating", "DesignCapacity", flowrate_volume))
|
583 |
598 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "RelativeDensityRated", density))
|
584 |
599 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "ViscosityRated", viscosity))
|
585 |
600 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "PumpingTempRated", temperature))
|
586 |
|
elif datacase_data == Pump_Datacase.N_A:
|
|
601 |
elif datacase_data == Pump_Datacase.Maximum_Flow_Case:
|
587 |
602 |
inst_Item.attributes.append(Inst_Attribute("eq_rotating", "FlowMax", flowrate_volume))
|
588 |
603 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "RelativeDensityMax", density))
|
589 |
604 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "ViscosityMax", viscosity))
|
590 |
605 |
inst_Item.attributes.append(Inst_Attribute("eq_pump", "PumpingTempMax", temperature))
|
591 |
606 |
inst_Item.printf()
|
592 |
607 |
inst_Items.append(inst_Item)
|
593 |
|
else:
|
594 |
|
continue
|
595 |
|
|
596 |
|
QDialog.accept(self)
|
597 |
608 |
|
|
609 |
if len(inst_Items) > 0:
|
|
610 |
projectInfomation =[con for con in self.project_list
|
|
611 |
if con.Name == self.ui.comboBox_select_PAP_Project.currentText()]
|
|
612 |
if projectInfomation:
|
|
613 |
headers = {'Content-Type': 'application/json', 'charset': 'UTF-8', 'Accept': '*/*'}
|
|
614 |
end_point = f"{app_doc_data.API_HOST}/api/HytosToPAP?ProjectUID={projectInfomation[0].UID}"
|
|
615 |
items = []
|
|
616 |
for inst_Item in inst_Items:
|
|
617 |
item = inst_Item.json()
|
|
618 |
items.append(item)
|
|
619 |
response = requests.post(end_point, data=json.dumps(items),headers=headers)
|
|
620 |
if response.status_code == 201:
|
|
621 |
QMessageBox.information(self, self.tr('Information'), self.tr('Data upload successful.'))
|
|
622 |
else:
|
|
623 |
QMessageBox.information(self, self.tr('Information'), self.tr('Failed to upload data.'))
|
598 |
624 |
def reject(self):
|
599 |
625 |
QDialog.reject(self)
|