8 |
8 |
'''
|
9 |
9 |
@brief HMB data
|
10 |
10 |
'''
|
|
11 |
|
|
12 |
|
11 |
13 |
class HMBData:
|
12 |
14 |
def __init__(self, uid=None):
|
13 |
|
self._uid = None
|
14 |
|
self._components_uid = None
|
15 |
|
self._stream_no = None
|
16 |
|
self._phase_type = None
|
17 |
|
self._flowrate_mass = None
|
18 |
|
self._flowrate_volume = None
|
19 |
|
self._density = None
|
20 |
|
self._viscosity = None
|
21 |
|
self._temperature = None
|
22 |
|
self._molecular_weight = None
|
23 |
|
self._specific_heat_ratio = None
|
24 |
|
self._compress_factor = None
|
25 |
|
self._nominal_pipe_size = None
|
26 |
|
self._inside_pipe_size = None
|
27 |
|
self._schedule_no = None
|
28 |
|
self._straight_length = None
|
29 |
|
self._equivalent_length_input = None
|
30 |
|
self._fitting_length = None
|
31 |
|
self._fitting_K = None
|
32 |
|
self._equivalent_length_cal = None
|
33 |
|
self._roughness = None
|
34 |
|
self._limitation_velocity = None
|
35 |
|
self._limitation_pressure_drop = None
|
36 |
|
self._velocity = None
|
37 |
|
self._reynolds = None
|
38 |
|
self._friction_factor = None
|
39 |
|
self._pressure_drop = None
|
40 |
|
self._pressure_drop_friction = None
|
41 |
|
self._pressure_drop_static = None
|
42 |
|
self._pressure_pipe_end_point = None
|
43 |
|
self._power = None
|
44 |
|
self.isDeleted = False
|
|
15 |
self._uid = None
|
|
16 |
self._components_uid = None
|
|
17 |
self._stream_no = None
|
|
18 |
self._phase_type = None
|
|
19 |
self._flowrate_mass = None
|
|
20 |
self._flowrate_volume = None
|
|
21 |
self._density = None
|
|
22 |
self._viscosity = None
|
|
23 |
self._temperature = None
|
|
24 |
self._molecular_weight = None
|
|
25 |
self._specific_heat_ratio = None
|
|
26 |
self._compress_factor = None
|
|
27 |
self._nominal_pipe_size = None
|
|
28 |
self._inside_pipe_size = None
|
|
29 |
self._schedule_no = None
|
|
30 |
self._straight_length = None
|
|
31 |
self._equivalent_length_input = None
|
|
32 |
self._fitting_length = None
|
|
33 |
self._fitting_K = None
|
|
34 |
self._equivalent_length_cal = None
|
|
35 |
self._roughness = None
|
|
36 |
self._limitation_velocity = None
|
|
37 |
self._limitation_pressure_drop = None
|
|
38 |
self._velocity = None
|
|
39 |
self._reynolds = None
|
|
40 |
self._friction_factor = None
|
|
41 |
self._pressure_drop = None
|
|
42 |
self._pressure_drop_friction = None
|
|
43 |
self._pressure_drop_static = None
|
|
44 |
self._pressure_pipe_end_point = None
|
|
45 |
self._power = None
|
|
46 |
self.isDeleted = False
|
45 |
47 |
|
46 |
48 |
'''
|
47 |
49 |
@author humkyung
|
48 |
50 |
@date 2018.07.12
|
49 |
51 |
'''
|
|
52 |
|
50 |
53 |
@property
|
51 |
54 |
def uid(self):
|
52 |
55 |
return self._uid
|
... | ... | |
55 |
58 |
@author humkyung
|
56 |
59 |
@date 2018.07.12
|
57 |
60 |
'''
|
|
61 |
|
58 |
62 |
@uid.setter
|
59 |
63 |
def uid(self, value):
|
60 |
64 |
self._uid = value
|
61 |
65 |
|
62 |
|
|
63 |
66 |
'''
|
64 |
67 |
@author humkyung
|
65 |
68 |
@date 2018.07.12
|
66 |
69 |
'''
|
|
70 |
|
67 |
71 |
@property
|
68 |
72 |
def components_uid(self):
|
69 |
73 |
return self._components_uid
|
... | ... | |
72 |
76 |
@author humkyung
|
73 |
77 |
@date 2018.07.12
|
74 |
78 |
'''
|
|
79 |
|
75 |
80 |
@components_uid.setter
|
76 |
81 |
def components_uid(self, value):
|
77 |
82 |
self._components_uid = value
|
... | ... | |
80 |
85 |
@author humkyung
|
81 |
86 |
@date 2018.07.12
|
82 |
87 |
'''
|
|
88 |
|
83 |
89 |
@property
|
84 |
90 |
def stream_no(self):
|
85 |
91 |
return self._stream_no
|
... | ... | |
88 |
94 |
@author humkyung
|
89 |
95 |
@date 2018.07.12
|
90 |
96 |
'''
|
|
97 |
|
91 |
98 |
@stream_no.setter
|
92 |
99 |
def stream_no(self, value):
|
93 |
100 |
if value:
|
... | ... | |
101 |
108 |
def phase_type(self, value):
|
102 |
109 |
if value:
|
103 |
110 |
self._phase_type = value
|
104 |
|
|
|
111 |
|
105 |
112 |
@property
|
106 |
113 |
def flowrate_mass(self):
|
107 |
114 |
return self._flowrate_mass
|
... | ... | |
207 |
214 |
def equivalent_length_input(self, value):
|
208 |
215 |
self._equivalent_length_input = float(value) if value else None
|
209 |
216 |
|
210 |
|
|
211 |
217 |
@property
|
212 |
218 |
def fitting_length(self):
|
213 |
219 |
return self._fitting_length
|
... | ... | |
216 |
222 |
def fitting_length(self, value):
|
217 |
223 |
self._fitting_length = float(value) if value else None
|
218 |
224 |
|
219 |
|
|
220 |
225 |
@property
|
221 |
226 |
def fitting_K(self):
|
222 |
227 |
return self._fitting_K
|
... | ... | |
303 |
308 |
|
304 |
309 |
@pressure_drop_static.setter
|
305 |
310 |
def pressure_drop_static(self, value):
|
306 |
|
self._pressure_drop_static = float(value) if value else None
|
|
311 |
self._pressure_drop_static = float(value) if value is not None else None
|
307 |
312 |
|
308 |
313 |
@property
|
309 |
314 |
def pressure_pipe_end_point(self):
|
... | ... | |
311 |
316 |
|
312 |
317 |
@pressure_pipe_end_point.setter
|
313 |
318 |
def pressure_pipe_end_point(self, value):
|
314 |
|
self._pressure_pipe_end_point = float(value) if value else None
|
|
319 |
self._pressure_pipe_end_point = float(value) if value is not None else None
|
315 |
320 |
|
316 |
321 |
@property
|
317 |
322 |
def power(self):
|
... | ... | |
319 |
324 |
|
320 |
325 |
@power.setter
|
321 |
326 |
def power(self, value):
|
322 |
|
self._power = float(value) if value else None
|
|
327 |
self._power = float(value) if value is not None else None
|
323 |
328 |
|
324 |
329 |
def fromRow(row):
|
325 |
330 |
hmb = HMBData()
|
... | ... | |
357 |
362 |
|
358 |
363 |
return hmb
|
359 |
364 |
|
|
365 |
|
360 |
366 |
class HMBTable:
|
361 |
367 |
'''
|
362 |
368 |
@brief constructor
|
363 |
369 |
@author humkyung
|
364 |
370 |
@date 2018.07.12
|
365 |
371 |
'''
|
|
372 |
|
366 |
373 |
def __init__(self):
|
367 |
374 |
self._hmbs = None
|
368 |
375 |
|
... | ... | |
370 |
377 |
def new_data():
|
371 |
378 |
# 새로운 HMB 데이타를 생성한다.
|
372 |
379 |
hmb = HMBData()
|
373 |
|
|
|
380 |
|
374 |
381 |
hmb.isDeleted = False
|
375 |
382 |
return hmb
|
376 |
383 |
|
... | ... | |
379 |
386 |
@author yeonjin
|
380 |
387 |
@date 2019.08.19
|
381 |
388 |
'''
|
|
389 |
|
382 |
390 |
def deleteByUID(self, uid):
|
383 |
391 |
hmbs = self._hmbs
|
384 |
|
if hmbs is not None:
|
|
392 |
if hmbs is not None:
|
385 |
393 |
for hmb in hmbs:
|
386 |
394 |
if str(hmb.components_uid) == str(uid):
|
387 |
395 |
hmb.isDeleted = True
|
388 |
396 |
break
|
389 |
397 |
|
390 |
|
|
391 |
398 |
def add(self, components_uid, stream_no):
|
392 |
399 |
import uuid
|
393 |
400 |
|
394 |
401 |
hmb = HMBData()
|
395 |
|
hmb.uid = str(uuid.uuid4())
|
|
402 |
hmb.uid = str(uuid.uuid4())
|
396 |
403 |
hmb.components_uid = components_uid
|
397 |
404 |
hmb.stream_no = stream_no
|
398 |
405 |
hmb.isDeleted = False
|
... | ... | |
400 |
407 |
self.append(hmb)
|
401 |
408 |
|
402 |
409 |
def updateByUID(self, components_uid, values):
|
403 |
|
try:
|
|
410 |
try:
|
404 |
411 |
for hmb in self._hmbs:
|
405 |
412 |
if hmb.components_uid == components_uid:
|
406 |
413 |
if 'Phase_Type' in values:
|
... | ... | |
410 |
417 |
if 'Flowrate_Volume' in values:
|
411 |
418 |
hmb.flowrate_volume = values['Flowrate_Volume']
|
412 |
419 |
if 'Viscosity' in values:
|
413 |
|
hmb.viscosity = values['Viscosity']
|
414 |
|
if 'Density' in values:
|
415 |
|
hmb.density = values['Density']
|
416 |
|
if 'Temperature' in values:
|
|
420 |
hmb.viscosity = values['Viscosity']
|
|
421 |
if 'Density' in values:
|
|
422 |
hmb.density = values['Density']
|
|
423 |
if 'Temperature' in values:
|
417 |
424 |
hmb.temperature = values['Temperature']
|
418 |
|
if 'Molecular_Weight' in values:
|
|
425 |
if 'Molecular_Weight' in values:
|
419 |
426 |
hmb.molecular_weight = values['Molecular_Weight']
|
420 |
427 |
if 'Specific_Heat_Ratio' in values:
|
421 |
428 |
hmb.specific_heat_ratio = values['Specific_Heat_Ratio']
|
... | ... | |
455 |
462 |
hmb.pressure_drop_friction = values['Pressure_Drop_Friction']
|
456 |
463 |
if 'Pressure_Drop_Static' in values:
|
457 |
464 |
hmb.pressure_drop_static = values['Pressure_Drop_Static']
|
458 |
|
if 'Pressure_Pipe_End_Point' in values:
|
|
465 |
if 'Pressure_Pipe_End_Point' in values:
|
459 |
466 |
hmb.pressure_pipe_end_point = values['Pressure_Pipe_End_Point']
|
460 |
467 |
if 'Power' in values:
|
461 |
468 |
hmb.power = values['Power']
|
... | ... | |
464 |
471 |
except Exception as ex:
|
465 |
472 |
from App import App
|
466 |
473 |
from AppDocData import MessageType
|
467 |
|
|
468 |
|
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
|
|
474 |
|
|
475 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
476 |
sys.exc_info()[-1].tb_lineno)
|
469 |
477 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
478 |
|
470 |
479 |
'''
|
471 |
480 |
@brief load hmb data from database
|
472 |
481 |
@author humkyung
|
473 |
482 |
@date 2018.07.12
|
474 |
483 |
'''
|
|
484 |
|
475 |
485 |
def load_data_by_drawing(self, drawing):
|
476 |
486 |
from App import App
|
477 |
487 |
from AppDocData import AppDocData
|
... | ... | |
532 |
542 |
|
533 |
543 |
# Roll back any change if something goes wrong
|
534 |
544 |
conn.rollback()
|
535 |
|
|
536 |
|
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
|
|
545 |
|
|
546 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
547 |
sys.exc_info()[-1].tb_lineno)
|
537 |
548 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
538 |
549 |
|
539 |
550 |
return self._hmbs
|
540 |
|
|
|
551 |
|
541 |
552 |
'''
|
542 |
553 |
@brief save hmb data
|
543 |
554 |
@author humkyung
|
544 |
555 |
@date 2018.07.12
|
545 |
556 |
'''
|
|
557 |
|
546 |
558 |
def saveData(self):
|
547 |
559 |
import uuid
|
548 |
560 |
from App import App
|
... | ... | |
561 |
573 |
|
562 |
574 |
for data in self._hmbs:
|
563 |
575 |
if data.isDeleted == False:
|
564 |
|
cols = ['UID', 'Components_UID', 'Stream_No', 'Phase_Type', 'Flowrate_Mass', 'Flowrate_Volume', 'Density', 'Viscosity',
|
565 |
|
'Temperature', 'Molecular_Weight', 'Specific_Heat_Ratio', 'Compress_Factor', 'Nominal_Pipe_Size', 'Inside_Pipe_Size',
|
566 |
|
'Schedule_No', 'Straight_Length', 'Equivalent_Length_Input', 'Fitting_Length', 'Fitting_K', 'Equivalent_Length_Cal', 'Roughness', 'Limitation_Velocity', 'Limitation_Pressure_Drop',
|
567 |
|
'Velocity', 'Reynolds', 'Friction_Factor', 'Pressure_Drop', 'Pressure_Drop_Friction', 'Pressure_Drop_Static', 'Pressure_Pipe_End_Point', 'Power']
|
568 |
|
values = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
|
569 |
|
param = (str(data.uid), str(data.components_uid), data.stream_no, data.phase_type, data.flowrate_mass, data.flowrate_volume, data.density,
|
570 |
|
data.viscosity, data.temperature, data.molecular_weight, data.specific_heat_ratio, data.compress_factor, data.nominal_pipe_size,
|
571 |
|
data.inside_pipe_size, data.schedule_no, data.straight_length, data.equivalent_length_input, data.fitting_length, data.fitting_K, data.equivalent_length_cal, data.roughness, data.limitation_velocity,
|
572 |
|
data.limitation_pressure_drop, data.velocity, data.reynolds, data.friction_factor, data.pressure_drop, data.pressure_drop_friction,
|
573 |
|
data.pressure_drop_static, data.pressure_pipe_end_point, data.power)
|
574 |
|
|
575 |
|
sql = 'insert or replace into HMB({}) values({})'.format(','.join(cols), ','.join(values))
|
|
576 |
cols = ['UID', 'Components_UID', 'Stream_No', 'Phase_Type', 'Flowrate_Mass', 'Flowrate_Volume',
|
|
577 |
'Density', 'Viscosity',
|
|
578 |
'Temperature', 'Molecular_Weight', 'Specific_Heat_Ratio', 'Compress_Factor',
|
|
579 |
'Nominal_Pipe_Size', 'Inside_Pipe_Size',
|
|
580 |
'Schedule_No', 'Straight_Length', 'Equivalent_Length_Input', 'Fitting_Length',
|
|
581 |
'Fitting_K', 'Equivalent_Length_Cal', 'Roughness', 'Limitation_Velocity',
|
|
582 |
'Limitation_Pressure_Drop',
|
|
583 |
'Velocity', 'Reynolds', 'Friction_Factor', 'Pressure_Drop', 'Pressure_Drop_Friction',
|
|
584 |
'Pressure_Drop_Static', 'Pressure_Pipe_End_Point', 'Power']
|
|
585 |
values = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
|
|
586 |
'?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
|
|
587 |
param = (
|
|
588 |
str(data.uid), str(data.components_uid), data.stream_no, data.phase_type, data.flowrate_mass,
|
|
589 |
data.flowrate_volume, data.density,
|
|
590 |
data.viscosity, data.temperature, data.molecular_weight, data.specific_heat_ratio,
|
|
591 |
data.compress_factor, data.nominal_pipe_size,
|
|
592 |
data.inside_pipe_size, data.schedule_no, data.straight_length, data.equivalent_length_input,
|
|
593 |
data.fitting_length, data.fitting_K, data.equivalent_length_cal, data.roughness,
|
|
594 |
data.limitation_velocity,
|
|
595 |
data.limitation_pressure_drop, data.velocity, data.reynolds, data.friction_factor,
|
|
596 |
data.pressure_drop, data.pressure_drop_friction,
|
|
597 |
data.pressure_drop_static, data.pressure_pipe_end_point, data.power)
|
|
598 |
|
|
599 |
sql = 'insert or replace into HMB({}) values({})'.format(','.join(cols), ','.join(values))
|
576 |
600 |
cursor.execute(sql, param)
|
577 |
601 |
else:
|
578 |
602 |
sql = "delete from HMB where uid=?"
|
... | ... | |
587 |
611 |
|
588 |
612 |
# Roll back any change if something goes wrong
|
589 |
613 |
conn.rollback()
|
590 |
|
|
591 |
|
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
|
|
614 |
|
|
615 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
616 |
sys.exc_info()[-1].tb_lineno)
|
592 |
617 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
593 |
618 |
|
594 |
619 |
'''
|
... | ... | |
596 |
621 |
@author humkyung
|
597 |
622 |
@date 2018.07.12
|
598 |
623 |
'''
|
|
624 |
|
599 |
625 |
def streamNos(self):
|
600 |
626 |
return set([hmb.stream_no for hmb in self._hmbs if hmb.isDeleted == False]) if self._hmbs is not None else {}
|
601 |
627 |
|
... | ... | |
604 |
630 |
@author humkyung
|
605 |
631 |
@date 2018.07.12
|
606 |
632 |
'''
|
|
633 |
|
607 |
634 |
def dataOfStreamNo(self, streamNo):
|
608 |
|
return [hmb for hmb in self._hmbs if hmb.streamNo == streamNo and hmb.isDeleted == False] if self._hmbs is not None else None
|
|
635 |
return [hmb for hmb in self._hmbs if
|
|
636 |
hmb.streamNo == streamNo and hmb.isDeleted == False] if self._hmbs is not None else None
|
609 |
637 |
|
610 |
638 |
'''
|
611 |
639 |
@brief append hmb data
|
612 |
640 |
@author humkyung
|
613 |
641 |
@date 2018.07.12
|
614 |
642 |
'''
|
|
643 |
|
615 |
644 |
def append(self, hmbData):
|
616 |
645 |
if self._hmbs is None:
|
617 |
646 |
self._hmbs = []
|
... | ... | |
623 |
652 |
@author humkyung
|
624 |
653 |
@date 2018.07.12
|
625 |
654 |
'''
|
|
655 |
|
626 |
656 |
def reset(self):
|
627 |
657 |
if self._hmbs is not None:
|
628 |
658 |
del self._hmbs
|
... | ... | |
633 |
663 |
""" get hmb data has given stream no """
|
634 |
664 |
|
635 |
665 |
matches = [data for data in self._hmbs if data._components_uid == component_uid]
|
636 |
|
return matches[0] if matches else None
|
|
666 |
return matches[0] if matches else None
|