From d476d2e053f937c0060f696312f301591e4f43ea Mon Sep 17 00:00:00 2001 From: brenda-br Date: Thu, 23 Feb 2023 22:14:39 +0530 Subject: Restructure Code -1 --- src/main/python/utils/Container.py | 250 +++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 src/main/python/utils/Container.py (limited to 'src/main/python/utils/Container.py') diff --git a/src/main/python/utils/Container.py b/src/main/python/utils/Container.py new file mode 100644 index 0000000..486169f --- /dev/null +++ b/src/main/python/utils/Container.py @@ -0,0 +1,250 @@ +from collections import defaultdict +import datetime +import pickle +import os,sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from python.OMChem.Flowsheet import Flowsheet +from python.utils.ComponentSelector import * +from python.utils.Graphics import NodeItem, Graphics, dock_widget_lst +from python.DockWidgets.DockWidget import DockWidget + +class Container(): + def __init__(self,msgbrowser, graphicsView): + self.unit_operations = [] + self.thermo_package = None + self.compounds = None + self.flowsheet = None + self.conn = defaultdict(list) + self.op=defaultdict(list) + self.ip=defaultdict(list) + self.msg = msgbrowser + self.graphicsView = graphicsView + self.msg.setText("") + self.opl=[] + self.result=[] + self.graphics = Graphics(self.unit_operations, self.graphicsView) + self.scene = self.graphics.get_scene() + + def current_time(self): + now = datetime.datetime.now() + time = str(now.hour) + ":" + str(now.minute) + ":" +str(now.second) + return time + + def add_unit_operation(self, obj): + box = None + self.obj = obj + self.scene = self.graphics.get_scene() + box = self.graphics.create_node_item(self.obj, self) + if box is not None: + self.scene.addItem(box) + box.setPos(2500-30, 2500-30) + + if(obj in self.unit_operations): + pass + else: + self.unit_operations.append(obj) + data = self.unit_operations[:] + data.append(compound_selected) + push('Undo', data) + self.msg.append("["+str(self.current_time())+"] "+obj.name+" is instantiated .""") + + ''' + Deletes the selected item from the canvas and also the objects created for that type. + ''' + def delete(self,l): + for item in l: + self.scene.removeItem(item) + for i in dock_widget_lst: + if i.name == item.name: + i.hide() + del i + break + + if hasattr(item,'input'): + for x in item.input: + if x.new_line: + self.scene.removeItem(x.new_line) + del x.new_line + if x.other_line: + self.scene.removeItem(x.other_line) + del x.other_line + if hasattr(item,'output'): + for x in item.output: + if x.new_line: + self.scene.removeItem(x.new_line) + del x.new_line + if x.other_line: + self.scene.removeItem(x.other_line) + del x.other_line + if hasattr(item,'obj'): + self.unit_operations.remove(item.obj) + for k in list(self.conn): + if item.obj==k: + del self.conn[k] + elif item.obj in self.conn[k]: + self.conn[k].remove(item.obj) + self.msg.append("["+str(self.current_time())+"] "+item.obj.name+" is deleted .""") + del item.obj + del item + + clean_file('Redo') + data = self.unit_operations[:] + data.append(compound_selected) + push('Undo', data) + + def fetch_object(self,name): + for i in self.unit_operations: + if(i.name==name): + return i + + def add_compounds(self,comp): + self.compounds = comp + + def update_compounds(self): + self.graphics.update_compounds() + + def add_thermo_package(self,thermo): + self.thermo_package = thermo + + def msg_browser(self): + std = self.flowsheet.stdout.decode("utf-8") + if(std): + stdout = str(std) + stdout = stdout.replace("\n","
") + self.msg.append(""+stdout+"") + + stde = self.flowsheet.stderr.decode("utf-8") + if(stde): + stdout = str(stde) + stdout = stdout.replace("\n","
") + self.msg.append(""+stdout+"") + + def simulate(self,mode): + + self.disableInterfaceforSimulation(True) + + for i in self.graphics.scene.items(): + if (isinstance(i, NodeItem)): + try: + i.dock_widget.clear_results() + except AttributeError: + pass + + #print("SIMULATE") + #print(mode) + self.compounds = compound_selected + self.flowsheet = Flowsheet() + self.flowsheet.add_compound_list([c[:c.index('(')] for c in self.compounds]) + #print("######## connection master#########\n",self.conn) + for i in self.unit_operations : + self.flowsheet.add_unit_operations(i) + + + if mode=='SM': + self.msg.append("["+str(self.current_time())+"] Simulating in Sequential mode ... ") + 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.flowsheet.simulate_EQN(self.msg) + self.result=self.flowsheet.result_data + + if(len(self.result)== 4): + #self.msg_browser() + self.msg.append("["+str(self.current_time())+"] Simulation Successful.") + else: + self.msg.append("["+str(self.current_time())+"] Simulation Failed.") + #print("under Eqn mode simulation") + + if(len(self.result)== 4): + DockWidget.show_result(NodeItem.get_dock_widget()) + + for i in self.graphics.scene.items(): + if (isinstance(i, NodeItem) and i.type == 'MaterialStream'): + i.update_tooltip_selectedVar() + no_input_lines = len(i.input[0].in_lines) + no_output_lines = len(i.output[0].out_lines) + if(no_input_lines>0): #Checks if material stream is input or output stream if it is output stream it continues + i.obj.disableInputDataTab(i.dock_widget) + + self.disableInterfaceforSimulation(False) + + def enableToolbar(self,status): + self.graphicsView.parent().parent().actionNew.setProperty('enabled',status) + self.graphicsView.parent().parent().actionZoomIn.setProperty('enabled',status) + self.graphicsView.parent().parent().actionZoomOut.setProperty('enabled',status) + self.graphicsView.parent().parent().actionResetZoom.setProperty('enabled',status) + self.graphicsView.parent().parent().actionEquationOriented.setProperty('enabled',status) + self.graphicsView.parent().parent().actionTerminate.setProperty('enabled',not status) + self.graphicsView.parent().parent().actionSelectCompounds.setProperty('enabled',status) + + def disableInterfaceforSimulation(self,status): + self.graphicsView.parent().parent().menubar.setProperty('enabled',not status) + self.enableToolbar(not status) + self.graphicsView.parent().parent().dockWidget.setProperty('enabled',not status) + self.graphicsView.setInteractive(not status) + if status: + QApplication.instance().setOverrideCursor(QCursor(Qt.WaitCursor)) + else: + QApplication.instance().restoreOverrideCursor() + QApplication.instance().setOverrideCursor(QCursor(Qt.ArrowCursor)) + +def flat_list(lst): + flat_lst=[] + for sublist in lst: + for item in sublist: + flat_lst.append(item) + return flat_lst + +def push(file_name, data): + with open(f"{file_name}.dat", "ab") as obj: + pickle.dump(data, obj) + +def clean_file(file_name): + with open(f"{file_name}.dat", "wb") as clean: + pass + +def pop(file_name): + last_command = None + if os.stat(f"{file_name}.dat").st_size != 0: + commands = [] + with open(f"{file_name}.dat", "rb") as objs: + while True: + try: + command = pickle.load(objs) + commands.append(command) + except EOFError: + break + + last_command = commands[-1] + commands.remove(commands[-1]) + if len(commands) != 0: + with open(f"{file_name}.dat", "wb") as updated_data: + for i in range(len(commands)): + pickle.dump(commands[i], updated_data) + else: + clean_file(file_name) + + return last_command + +def get_last_list(file_name): + commands = [] + if os.stat(f"{file_name}.dat").st_size != 0: + with open(f"{file_name}.dat", "rb") as objs: + while True: + try: + command = pickle.load(objs) + commands.append(command) + except EOFError: + break + if len(commands) is not 0: + return commands[-1] + else: + return None -- cgit From 7af3526e105cc330422f8742ec5edec1c4a0a98f Mon Sep 17 00:00:00 2001 From: brenda-br Date: Thu, 2 Mar 2023 15:49:11 +0530 Subject: Restructuring Finalized for App Bundling --- src/main/python/utils/Container.py | 250 ------------------------------------- 1 file changed, 250 deletions(-) delete mode 100644 src/main/python/utils/Container.py (limited to 'src/main/python/utils/Container.py') diff --git a/src/main/python/utils/Container.py b/src/main/python/utils/Container.py deleted file mode 100644 index 486169f..0000000 --- a/src/main/python/utils/Container.py +++ /dev/null @@ -1,250 +0,0 @@ -from collections import defaultdict -import datetime -import pickle -import os,sys - -current = os.path.dirname(os.path.realpath(__file__)) -parent = os.path.dirname(current) -parentPath = os.path.dirname(parent) -sys.path.append(parentPath) - -from python.OMChem.Flowsheet import Flowsheet -from python.utils.ComponentSelector import * -from python.utils.Graphics import NodeItem, Graphics, dock_widget_lst -from python.DockWidgets.DockWidget import DockWidget - -class Container(): - def __init__(self,msgbrowser, graphicsView): - self.unit_operations = [] - self.thermo_package = None - self.compounds = None - self.flowsheet = None - self.conn = defaultdict(list) - self.op=defaultdict(list) - self.ip=defaultdict(list) - self.msg = msgbrowser - self.graphicsView = graphicsView - self.msg.setText("") - self.opl=[] - self.result=[] - self.graphics = Graphics(self.unit_operations, self.graphicsView) - self.scene = self.graphics.get_scene() - - def current_time(self): - now = datetime.datetime.now() - time = str(now.hour) + ":" + str(now.minute) + ":" +str(now.second) - return time - - def add_unit_operation(self, obj): - box = None - self.obj = obj - self.scene = self.graphics.get_scene() - box = self.graphics.create_node_item(self.obj, self) - if box is not None: - self.scene.addItem(box) - box.setPos(2500-30, 2500-30) - - if(obj in self.unit_operations): - pass - else: - self.unit_operations.append(obj) - data = self.unit_operations[:] - data.append(compound_selected) - push('Undo', data) - self.msg.append("["+str(self.current_time())+"] "+obj.name+" is instantiated .""") - - ''' - Deletes the selected item from the canvas and also the objects created for that type. - ''' - def delete(self,l): - for item in l: - self.scene.removeItem(item) - for i in dock_widget_lst: - if i.name == item.name: - i.hide() - del i - break - - if hasattr(item,'input'): - for x in item.input: - if x.new_line: - self.scene.removeItem(x.new_line) - del x.new_line - if x.other_line: - self.scene.removeItem(x.other_line) - del x.other_line - if hasattr(item,'output'): - for x in item.output: - if x.new_line: - self.scene.removeItem(x.new_line) - del x.new_line - if x.other_line: - self.scene.removeItem(x.other_line) - del x.other_line - if hasattr(item,'obj'): - self.unit_operations.remove(item.obj) - for k in list(self.conn): - if item.obj==k: - del self.conn[k] - elif item.obj in self.conn[k]: - self.conn[k].remove(item.obj) - self.msg.append("["+str(self.current_time())+"] "+item.obj.name+" is deleted .""") - del item.obj - del item - - clean_file('Redo') - data = self.unit_operations[:] - data.append(compound_selected) - push('Undo', data) - - def fetch_object(self,name): - for i in self.unit_operations: - if(i.name==name): - return i - - def add_compounds(self,comp): - self.compounds = comp - - def update_compounds(self): - self.graphics.update_compounds() - - def add_thermo_package(self,thermo): - self.thermo_package = thermo - - def msg_browser(self): - std = self.flowsheet.stdout.decode("utf-8") - if(std): - stdout = str(std) - stdout = stdout.replace("\n","
") - self.msg.append(""+stdout+"") - - stde = self.flowsheet.stderr.decode("utf-8") - if(stde): - stdout = str(stde) - stdout = stdout.replace("\n","
") - self.msg.append(""+stdout+"") - - def simulate(self,mode): - - self.disableInterfaceforSimulation(True) - - for i in self.graphics.scene.items(): - if (isinstance(i, NodeItem)): - try: - i.dock_widget.clear_results() - except AttributeError: - pass - - #print("SIMULATE") - #print(mode) - self.compounds = compound_selected - self.flowsheet = Flowsheet() - self.flowsheet.add_compound_list([c[:c.index('(')] for c in self.compounds]) - #print("######## connection master#########\n",self.conn) - for i in self.unit_operations : - self.flowsheet.add_unit_operations(i) - - - if mode=='SM': - self.msg.append("["+str(self.current_time())+"] Simulating in Sequential mode ... ") - 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.flowsheet.simulate_EQN(self.msg) - self.result=self.flowsheet.result_data - - if(len(self.result)== 4): - #self.msg_browser() - self.msg.append("["+str(self.current_time())+"] Simulation Successful.") - else: - self.msg.append("["+str(self.current_time())+"] Simulation Failed.") - #print("under Eqn mode simulation") - - if(len(self.result)== 4): - DockWidget.show_result(NodeItem.get_dock_widget()) - - for i in self.graphics.scene.items(): - if (isinstance(i, NodeItem) and i.type == 'MaterialStream'): - i.update_tooltip_selectedVar() - no_input_lines = len(i.input[0].in_lines) - no_output_lines = len(i.output[0].out_lines) - if(no_input_lines>0): #Checks if material stream is input or output stream if it is output stream it continues - i.obj.disableInputDataTab(i.dock_widget) - - self.disableInterfaceforSimulation(False) - - def enableToolbar(self,status): - self.graphicsView.parent().parent().actionNew.setProperty('enabled',status) - self.graphicsView.parent().parent().actionZoomIn.setProperty('enabled',status) - self.graphicsView.parent().parent().actionZoomOut.setProperty('enabled',status) - self.graphicsView.parent().parent().actionResetZoom.setProperty('enabled',status) - self.graphicsView.parent().parent().actionEquationOriented.setProperty('enabled',status) - self.graphicsView.parent().parent().actionTerminate.setProperty('enabled',not status) - self.graphicsView.parent().parent().actionSelectCompounds.setProperty('enabled',status) - - def disableInterfaceforSimulation(self,status): - self.graphicsView.parent().parent().menubar.setProperty('enabled',not status) - self.enableToolbar(not status) - self.graphicsView.parent().parent().dockWidget.setProperty('enabled',not status) - self.graphicsView.setInteractive(not status) - if status: - QApplication.instance().setOverrideCursor(QCursor(Qt.WaitCursor)) - else: - QApplication.instance().restoreOverrideCursor() - QApplication.instance().setOverrideCursor(QCursor(Qt.ArrowCursor)) - -def flat_list(lst): - flat_lst=[] - for sublist in lst: - for item in sublist: - flat_lst.append(item) - return flat_lst - -def push(file_name, data): - with open(f"{file_name}.dat", "ab") as obj: - pickle.dump(data, obj) - -def clean_file(file_name): - with open(f"{file_name}.dat", "wb") as clean: - pass - -def pop(file_name): - last_command = None - if os.stat(f"{file_name}.dat").st_size != 0: - commands = [] - with open(f"{file_name}.dat", "rb") as objs: - while True: - try: - command = pickle.load(objs) - commands.append(command) - except EOFError: - break - - last_command = commands[-1] - commands.remove(commands[-1]) - if len(commands) != 0: - with open(f"{file_name}.dat", "wb") as updated_data: - for i in range(len(commands)): - pickle.dump(commands[i], updated_data) - else: - clean_file(file_name) - - return last_command - -def get_last_list(file_name): - commands = [] - if os.stat(f"{file_name}.dat").st_size != 0: - with open(f"{file_name}.dat", "rb") as objs: - while True: - try: - command = pickle.load(objs) - commands.append(command) - except EOFError: - break - if len(commands) is not 0: - return commands[-1] - else: - return None -- cgit From 3cbdd4238867bc860282f7cf702d73b5be6e3f86 Mon Sep 17 00:00:00 2001 From: brenda-br Date: Sat, 4 Mar 2023 11:32:15 +0530 Subject: Revert "Restructuring Finalized for App Bundling" This reverts commit 7af3526e105cc330422f8742ec5edec1c4a0a98f. --- src/main/python/utils/Container.py | 250 +++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 src/main/python/utils/Container.py (limited to 'src/main/python/utils/Container.py') diff --git a/src/main/python/utils/Container.py b/src/main/python/utils/Container.py new file mode 100644 index 0000000..486169f --- /dev/null +++ b/src/main/python/utils/Container.py @@ -0,0 +1,250 @@ +from collections import defaultdict +import datetime +import pickle +import os,sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from python.OMChem.Flowsheet import Flowsheet +from python.utils.ComponentSelector import * +from python.utils.Graphics import NodeItem, Graphics, dock_widget_lst +from python.DockWidgets.DockWidget import DockWidget + +class Container(): + def __init__(self,msgbrowser, graphicsView): + self.unit_operations = [] + self.thermo_package = None + self.compounds = None + self.flowsheet = None + self.conn = defaultdict(list) + self.op=defaultdict(list) + self.ip=defaultdict(list) + self.msg = msgbrowser + self.graphicsView = graphicsView + self.msg.setText("") + self.opl=[] + self.result=[] + self.graphics = Graphics(self.unit_operations, self.graphicsView) + self.scene = self.graphics.get_scene() + + def current_time(self): + now = datetime.datetime.now() + time = str(now.hour) + ":" + str(now.minute) + ":" +str(now.second) + return time + + def add_unit_operation(self, obj): + box = None + self.obj = obj + self.scene = self.graphics.get_scene() + box = self.graphics.create_node_item(self.obj, self) + if box is not None: + self.scene.addItem(box) + box.setPos(2500-30, 2500-30) + + if(obj in self.unit_operations): + pass + else: + self.unit_operations.append(obj) + data = self.unit_operations[:] + data.append(compound_selected) + push('Undo', data) + self.msg.append("["+str(self.current_time())+"] "+obj.name+" is instantiated .""") + + ''' + Deletes the selected item from the canvas and also the objects created for that type. + ''' + def delete(self,l): + for item in l: + self.scene.removeItem(item) + for i in dock_widget_lst: + if i.name == item.name: + i.hide() + del i + break + + if hasattr(item,'input'): + for x in item.input: + if x.new_line: + self.scene.removeItem(x.new_line) + del x.new_line + if x.other_line: + self.scene.removeItem(x.other_line) + del x.other_line + if hasattr(item,'output'): + for x in item.output: + if x.new_line: + self.scene.removeItem(x.new_line) + del x.new_line + if x.other_line: + self.scene.removeItem(x.other_line) + del x.other_line + if hasattr(item,'obj'): + self.unit_operations.remove(item.obj) + for k in list(self.conn): + if item.obj==k: + del self.conn[k] + elif item.obj in self.conn[k]: + self.conn[k].remove(item.obj) + self.msg.append("["+str(self.current_time())+"] "+item.obj.name+" is deleted .""") + del item.obj + del item + + clean_file('Redo') + data = self.unit_operations[:] + data.append(compound_selected) + push('Undo', data) + + def fetch_object(self,name): + for i in self.unit_operations: + if(i.name==name): + return i + + def add_compounds(self,comp): + self.compounds = comp + + def update_compounds(self): + self.graphics.update_compounds() + + def add_thermo_package(self,thermo): + self.thermo_package = thermo + + def msg_browser(self): + std = self.flowsheet.stdout.decode("utf-8") + if(std): + stdout = str(std) + stdout = stdout.replace("\n","
") + self.msg.append(""+stdout+"") + + stde = self.flowsheet.stderr.decode("utf-8") + if(stde): + stdout = str(stde) + stdout = stdout.replace("\n","
") + self.msg.append(""+stdout+"") + + def simulate(self,mode): + + self.disableInterfaceforSimulation(True) + + for i in self.graphics.scene.items(): + if (isinstance(i, NodeItem)): + try: + i.dock_widget.clear_results() + except AttributeError: + pass + + #print("SIMULATE") + #print(mode) + self.compounds = compound_selected + self.flowsheet = Flowsheet() + self.flowsheet.add_compound_list([c[:c.index('(')] for c in self.compounds]) + #print("######## connection master#########\n",self.conn) + for i in self.unit_operations : + self.flowsheet.add_unit_operations(i) + + + if mode=='SM': + self.msg.append("["+str(self.current_time())+"] Simulating in Sequential mode ... ") + 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.flowsheet.simulate_EQN(self.msg) + self.result=self.flowsheet.result_data + + if(len(self.result)== 4): + #self.msg_browser() + self.msg.append("["+str(self.current_time())+"] Simulation Successful.") + else: + self.msg.append("["+str(self.current_time())+"] Simulation Failed.") + #print("under Eqn mode simulation") + + if(len(self.result)== 4): + DockWidget.show_result(NodeItem.get_dock_widget()) + + for i in self.graphics.scene.items(): + if (isinstance(i, NodeItem) and i.type == 'MaterialStream'): + i.update_tooltip_selectedVar() + no_input_lines = len(i.input[0].in_lines) + no_output_lines = len(i.output[0].out_lines) + if(no_input_lines>0): #Checks if material stream is input or output stream if it is output stream it continues + i.obj.disableInputDataTab(i.dock_widget) + + self.disableInterfaceforSimulation(False) + + def enableToolbar(self,status): + self.graphicsView.parent().parent().actionNew.setProperty('enabled',status) + self.graphicsView.parent().parent().actionZoomIn.setProperty('enabled',status) + self.graphicsView.parent().parent().actionZoomOut.setProperty('enabled',status) + self.graphicsView.parent().parent().actionResetZoom.setProperty('enabled',status) + self.graphicsView.parent().parent().actionEquationOriented.setProperty('enabled',status) + self.graphicsView.parent().parent().actionTerminate.setProperty('enabled',not status) + self.graphicsView.parent().parent().actionSelectCompounds.setProperty('enabled',status) + + def disableInterfaceforSimulation(self,status): + self.graphicsView.parent().parent().menubar.setProperty('enabled',not status) + self.enableToolbar(not status) + self.graphicsView.parent().parent().dockWidget.setProperty('enabled',not status) + self.graphicsView.setInteractive(not status) + if status: + QApplication.instance().setOverrideCursor(QCursor(Qt.WaitCursor)) + else: + QApplication.instance().restoreOverrideCursor() + QApplication.instance().setOverrideCursor(QCursor(Qt.ArrowCursor)) + +def flat_list(lst): + flat_lst=[] + for sublist in lst: + for item in sublist: + flat_lst.append(item) + return flat_lst + +def push(file_name, data): + with open(f"{file_name}.dat", "ab") as obj: + pickle.dump(data, obj) + +def clean_file(file_name): + with open(f"{file_name}.dat", "wb") as clean: + pass + +def pop(file_name): + last_command = None + if os.stat(f"{file_name}.dat").st_size != 0: + commands = [] + with open(f"{file_name}.dat", "rb") as objs: + while True: + try: + command = pickle.load(objs) + commands.append(command) + except EOFError: + break + + last_command = commands[-1] + commands.remove(commands[-1]) + if len(commands) != 0: + with open(f"{file_name}.dat", "wb") as updated_data: + for i in range(len(commands)): + pickle.dump(commands[i], updated_data) + else: + clean_file(file_name) + + return last_command + +def get_last_list(file_name): + commands = [] + if os.stat(f"{file_name}.dat").st_size != 0: + with open(f"{file_name}.dat", "rb") as objs: + while True: + try: + command = pickle.load(objs) + commands.append(command) + except EOFError: + break + if len(commands) is not 0: + return commands[-1] + else: + return None -- cgit From 3971305571c9180d0de081f00b388b3aba3d23ba Mon Sep 17 00:00:00 2001 From: brenda-br Date: Fri, 3 Mar 2023 16:17:50 +0530 Subject: Disabling Undo Redo --- src/main/python/utils/Container.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/python/utils/Container.py') diff --git a/src/main/python/utils/Container.py b/src/main/python/utils/Container.py index 486169f..c72026a 100644 --- a/src/main/python/utils/Container.py +++ b/src/main/python/utils/Container.py @@ -50,7 +50,7 @@ class Container(): self.unit_operations.append(obj) data = self.unit_operations[:] data.append(compound_selected) - push('Undo', data) + #push('Undo', data) self.msg.append("["+str(self.current_time())+"] "+obj.name+" is instantiated .""") ''' @@ -92,10 +92,10 @@ class Container(): del item.obj del item - clean_file('Redo') - data = self.unit_operations[:] - data.append(compound_selected) - push('Undo', data) + # clean_file('Redo') + # data = self.unit_operations[:] + # data.append(compound_selected) + # push('Undo', data) def fetch_object(self,name): for i in self.unit_operations: -- cgit 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 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/main/python/utils/Container.py') 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 -- cgit