From c42c4267f9dd5763a0b7740aad8855faa452e9db Mon Sep 17 00:00:00 2001 From: brenda-br Date: Fri, 10 Mar 2023 11:03:13 +0530 Subject: Fix #67 Show Warning When Connection Not Properly Made and Some Minor Changes --- src/main/python/utils/Container.py | 18 ++++++++++++++++-- src/main/python/utils/Streams.py | 12 +++++++++--- src/main/python/utils/UnitOperations.py | 6 ++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/python/utils/Container.py b/src/main/python/utils/Container.py index c72026a..139346c 100644 --- a/src/main/python/utils/Container.py +++ b/src/main/python/utils/Container.py @@ -127,14 +127,26 @@ class Container(): def simulate(self,mode): self.disableInterfaceforSimulation(True) - + toAppend = '' for i in self.graphics.scene.items(): - if (isinstance(i, NodeItem)): + showConnectionWarning = False + if isinstance(i, NodeItem): try: i.dock_widget.clear_results() except AttributeError: pass + for ip in i.input: + if len(ip.in_lines) == 0: + showConnectionWarning = True + for op in i.output: + if len(op.out_lines) == 0: + showConnectionWarning = True + if showConnectionWarning: + if toAppend != '': + toAppend+='
' + toAppend+="Warning: "+i.name+" - Missing Socket Connection(s)." + #print("SIMULATE") #print(mode) self.compounds = compound_selected @@ -147,12 +159,14 @@ class Container(): if mode=='SM': self.msg.append("["+str(self.current_time())+"] Simulating in Sequential mode ... ") + self.msg.append(toAppend) self.flowsheet.simulate_SM(self.ip,self.op) self.msg_browser() self.result=self.flowsheet.result_data elif mode=='EQN': self.msg.append("["+str(self.current_time())+"] Simulating in equation mode ... ") + self.msg.append(toAppend) self.flowsheet.simulate_EQN(self.msg) self.result=self.flowsheet.result_data diff --git a/src/main/python/utils/Streams.py b/src/main/python/utils/Streams.py index 05ec014..fa557e6 100644 --- a/src/main/python/utils/Streams.py +++ b/src/main/python/utils/Streams.py @@ -154,10 +154,14 @@ class MaterialStream(): temp_val = self.variables['T']['value'] temp_unit = self.variables['T']['unit'] mixMolEntal_name = self.variables['H_p[1]']['name'] - mixMolEntal_val = round(float(self.variables['H_p[1]']['value']),4) + mixMolEntal_val = self.variables['H_p[1]']['value'] + if mixMolEntal_val != None: + mixMolEntal_val = round(float(self.variables['H_p[1]']['value']),4) mixMolEntal_unit = self.variables['H_p[1]']['unit'] mixMolEntro_name = self.variables['S_p[1]']['name'] - mixMolEntro_val = round(float(self.variables['S_p[1]']['value']),4) + mixMolEntro_val = self.variables['S_p[1]']['value'] + if mixMolEntro_val != None: + mixMolEntro_val = round(float(self.variables['S_p[1]']['value']),4) mixMolEntro_unit = self.variables['S_p[1]']['unit'] vapMolFrac_name = self.variables['xvap']['name'] vapMolFrac_val = self.variables['xvap']['value'] @@ -166,7 +170,9 @@ class MaterialStream(): mixMolFlo_val = self.variables['F_p[1]']['value'] mixMolFlo_unit = self.variables['F_p[1]']['unit'] mixMassFlo_name = self.variables['Fm_p[1]']['name'] - mixMassFlo_val = round(float(self.variables['Fm_p[1]']['value']),4) + mixMassFlo_val = self.variables['Fm_p[1]']['value'] + if mixMassFlo_val != None: + mixMassFlo_val = round(float(self.variables['Fm_p[1]']['value']),4) mixMassFlo_unit = self.variables['Fm_p[1]']['unit'] dict = {pressure_name:str(pressure_val)+' '+pressure_unit, diff --git a/src/main/python/utils/UnitOperations.py b/src/main/python/utils/UnitOperations.py index 2b16c7d..86a1ad7 100644 --- a/src/main/python/utils/UnitOperations.py +++ b/src/main/python/utils/UnitOperations.py @@ -177,8 +177,10 @@ class UnitOperation(): strcount += 1 else: #print("self.output_stms ", self.output_stms) - self.OM_data_eqn += ('connect(' + self.name + '.Out,' + self.output_stms[1].name + '.In);\n') - + try: + self.OM_data_eqn += ('connect(' + self.name + '.Out,' + self.output_stms[1].name + '.In);\n') + except: + pass if self.mode: self.OM_data_eqn += (self.name + '.' + self.mode + '=' + str(self.mode_val) + ';\n') -- cgit