From f87ebcf83c4a2a614e79b10039021cc5a0d56889 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Fri, 7 Apr 2023 20:20:33 +0530 Subject: Added progress bar, QtTimer and removed the plots --- src/frontEnd/Application.py | 142 ++++++++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 65 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 7588b1a1..44237d56 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -549,12 +549,69 @@ class Application(QtWidgets.QMainWindow): psutil.AccessDenied, psutil.ZombieProcess): pass return False + + def check_change_in_plotfile(self, currTime): + print("The function has executed") + try: + # if os.name == 'nt': + # proc = 'mintty' + # else: + # proc = 'xterm' + + # Edited by Sumanto Kar 25/08/2021 + if False and os.name != 'nt' and \ + self.checkIfProcessRunning('xterm') is False: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'Simulation was interrupted/failed. ' + 'Please close all the Ngspice windows ' + 'and then rerun the simulation.' + ) + self.msg.exec_() + return + + st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) + print(st.st_mtime, currTime - 1) + if st.st_mtime >= currTime - 1: + self.is_file_changed = True + self.timer.stop() + self.plot_simulation() + return + except Exception: + pass + + if self.is_file_changed is False: + self.timer.start() + + # Fail Safe ===> + self.count += 1 + if self.count >= 10: + print( + "Ngspice taking too long for simulation. " + "Check netlist file (*.cir.out) " + "to change simulation parameters." + ) + + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'Ngspice taking too long for simulation. ' + 'Check netlist file (*.cir.out) ' + 'to change simulation parameters.' + ) + self.msg.exec_() + + return def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] if self.projDir is not None: + currTime = time.time() # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( @@ -572,71 +629,11 @@ class Application(QtWidgets.QMainWindow): self.msg.exec_() return - currTime = time.time() - count = 0 - while True: - try: - # if os.name == 'nt': - # proc = 'mintty' - # else: - # proc = 'xterm' - - # Edited by Sumanto Kar 25/08/2021 - if os.name != 'nt' and \ - self.checkIfProcessRunning('xterm') is False: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Warning Message") - self.msg.showMessage( - 'Simulation was interrupted/failed. ' - 'Please close all the Ngspice windows ' - 'and then rerun the simulation.' - ) - self.msg.exec_() - return - - st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - if st.st_mtime >= currTime: - break - except Exception: - pass - time.sleep(1) - - # Fail Safe ===> - count += 1 - if count >= 10: - print( - "Ngspice taking too long for simulation. " - "Check netlist file (*.cir.out) " - "to change simulation parameters." - ) - - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Warning Message") - self.msg.showMessage( - 'Ngspice taking too long for simulation. ' - 'Check netlist file (*.cir.out) ' - 'to change simulation parameters.' - ) - self.msg.exec_() - - return - - # Calling Python Plotting - try: - self.obj_Mainview.obj_dockarea.plottingEditor() - except Exception as e: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Error Message") - self.msg.showMessage( - 'Error while opening python plotting Editor.' - ' Please look at console for more details.' - ) - self.msg.exec_() - print("Exception Message:", str(e), traceback.format_exc()) - self.obj_appconfig.print_error('Exception Message : ' + str(e)) + self.count = 0 + self.timer = QtCore.QTimer(self) + self.timer.setInterval(1000) + self.timer.timeout.connect(lambda: self.check_change_in_plotfile(currTime)) + self.timer.start() else: self.msg = QtWidgets.QErrorMessage() @@ -648,6 +645,21 @@ class Application(QtWidgets.QMainWindow): ) self.msg.exec_() + def plot_simulation(self): + try: + self.obj_Mainview.obj_dockarea.plottingEditor() + except Exception as e: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Error Message") + self.msg.showMessage( + 'Error while opening python plotting Editor.' + ' Please look at console for more details.' + ) + self.msg.exec_() + print("Exception Message:", str(e), traceback.format_exc()) + self.obj_appconfig.print_error('Exception Message : ' + str(e)) + def open_subcircuit(self): """ This function opens 'subcircuit' option in left-tool-bar. -- cgit From 8f7d5b170b587aa359f6df3b73f998bf8be9f008 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Sat, 8 Apr 2023 09:10:39 +0530 Subject: Hopefully fixed a bug which could have been a racing condition --- src/frontEnd/Application.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 44237d56..4ebb544c 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -83,6 +83,8 @@ class Application(QtWidgets.QMainWindow): self.systemTrayIcon.setIcon(QtGui.QIcon(init_path + 'images/logo.png')) self.systemTrayIcon.setVisible(True) + self.is_file_changed = False + def initToolBar(self): """ This function initializes Tool Bars. @@ -573,8 +575,10 @@ class Application(QtWidgets.QMainWindow): return st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - print(st.st_mtime, currTime - 1) - if st.st_mtime >= currTime - 1: + is_ngspice_running = self.checkIfProcessRunning("ngspice") + print("Ngspice is running:", is_ngspice_running) + print(st.st_mtime, currTime) + if st.st_mtime >= currTime and not is_ngspice_running: self.is_file_changed = True self.timer.stop() self.plot_simulation() -- cgit From c138ec3aebe4dc894600e0eabccf1659f2b5a838 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Wed, 3 May 2023 13:35:10 +0530 Subject: Changed ngspice simulation progressbar design --- src/frontEnd/Application.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 4ebb544c..730ba9d8 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -578,7 +578,7 @@ class Application(QtWidgets.QMainWindow): is_ngspice_running = self.checkIfProcessRunning("ngspice") print("Ngspice is running:", is_ngspice_running) print(st.st_mtime, currTime) - if st.st_mtime >= currTime and not is_ngspice_running: + if st.st_mtime >= currTime - 1 and not is_ngspice_running: self.is_file_changed = True self.timer.stop() self.plot_simulation() @@ -592,6 +592,7 @@ class Application(QtWidgets.QMainWindow): # Fail Safe ===> self.count += 1 if self.count >= 10: + self.timer.stop() print( "Ngspice taking too long for simulation. " "Check netlist file (*.cir.out) " -- cgit From 7ba6e484b01ee1e0f38a2b68c4abc8aed391b153 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 4 May 2023 09:36:47 +0530 Subject: Enabled cancel simulation button --- src/frontEnd/Application.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 730ba9d8..3c11045f 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -614,13 +614,14 @@ class Application(QtWidgets.QMainWindow): def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] + self.timer = QtCore.QTimer(self) if self.projDir is not None: currTime = time.time() # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir) is False: + self.projDir, self.timer) is False: print( "Netlist file (*.cir.out) not found." ) @@ -635,7 +636,6 @@ class Application(QtWidgets.QMainWindow): return self.count = 0 - self.timer = QtCore.QTimer(self) self.timer.setInterval(1000) self.timer.timeout.connect(lambda: self.check_change_in_plotfile(currTime)) self.timer.start() -- cgit From cf6bb2edf063ba6d3415434899e8a73a42755aa0 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 4 May 2023 19:26:04 +0530 Subject: Disabled multiple simulations --- src/frontEnd/Application.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 3c11045f..a34442b8 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -581,6 +581,7 @@ class Application(QtWidgets.QMainWindow): if st.st_mtime >= currTime - 1 and not is_ngspice_running: self.is_file_changed = True self.timer.stop() + self.plot_simulation() return except Exception: @@ -610,18 +611,30 @@ class Application(QtWidgets.QMainWindow): self.msg.exec_() return + + def enableButtons(self, state): + self.ngspice.setEnabled(state) + self.conversion.setEnabled(state) + self.closeproj.setEnabled(state) + self.wrkspce.setEnabled(state) def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] self.timer = QtCore.QTimer(self) + self.simulationEssentials = { + "timer": self.timer, + "enableButtons": self.enableButtons, + } + if self.projDir is not None: currTime = time.time() # Edited by Sumanto Kar 25/08/2021 + self.enableButtons(False) if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir, self.timer) is False: + self.projDir, self.simulationEssentials) is False: print( "Netlist file (*.cir.out) not found." ) -- cgit From 2de5fa0604c35a1508bca8bab318724da823633a Mon Sep 17 00:00:00 2001 From: Pranav P Date: Sun, 7 May 2023 17:01:26 +0530 Subject: Mentions whether simulation successful or not --- src/frontEnd/Application.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index a34442b8..d584c714 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -578,12 +578,16 @@ class Application(QtWidgets.QMainWindow): is_ngspice_running = self.checkIfProcessRunning("ngspice") print("Ngspice is running:", is_ngspice_running) print(st.st_mtime, currTime) - if st.st_mtime >= currTime - 1 and not is_ngspice_running: - self.is_file_changed = True - self.timer.stop() + if not is_ngspice_running: + if st.st_mtime >= currTime - 1: + self.is_file_changed = True + self.timer.stop() - self.plot_simulation() - return + self.plot_simulation() + return + else: + self.timer.stop() + return except Exception: pass @@ -618,14 +622,19 @@ class Application(QtWidgets.QMainWindow): self.closeproj.setEnabled(state) self.wrkspce.setEnabled(state) + def isSimulationSuccess(self): + return self.is_file_changed + def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] self.timer = QtCore.QTimer(self) + self.is_file_changed = False self.simulationEssentials = { "timer": self.timer, "enableButtons": self.enableButtons, + "isSimulationSuccess": self.isSimulationSuccess, } if self.projDir is not None: -- cgit From 9c0b9b9d9caa18f552fb764bea1dc685e17807ee Mon Sep 17 00:00:00 2001 From: Pranav P Date: Sun, 7 May 2023 17:17:33 +0530 Subject: Removed unnecessary print statements used for debugging --- src/frontEnd/Application.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index d584c714..0f8e7dac 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -553,7 +553,6 @@ class Application(QtWidgets.QMainWindow): return False def check_change_in_plotfile(self, currTime): - print("The function has executed") try: # if os.name == 'nt': # proc = 'mintty' @@ -576,8 +575,6 @@ class Application(QtWidgets.QMainWindow): st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) is_ngspice_running = self.checkIfProcessRunning("ngspice") - print("Ngspice is running:", is_ngspice_running) - print(st.st_mtime, currTime) if not is_ngspice_running: if st.st_mtime >= currTime - 1: self.is_file_changed = True -- cgit From 1c0b9197069c12f2a9b0c35be936e97d38c6a372 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Fri, 19 May 2023 11:16:58 +0530 Subject: Added redo simulation button to progressbar window --- src/frontEnd/Application.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 0f8e7dac..7457ba7d 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -621,6 +621,10 @@ class Application(QtWidgets.QMainWindow): def isSimulationSuccess(self): return self.is_file_changed + + def resetSimulationVariables(self): + self.count = 0 + self.currTime = 0 def open_ngspice(self): """This Function execute ngspice on current project.""" @@ -632,10 +636,11 @@ class Application(QtWidgets.QMainWindow): "timer": self.timer, "enableButtons": self.enableButtons, "isSimulationSuccess": self.isSimulationSuccess, + "resetSimulationVariables": self.resetSimulationVariables, } if self.projDir is not None: - currTime = time.time() + self.currTime = time.time() # Edited by Sumanto Kar 25/08/2021 self.enableButtons(False) @@ -656,7 +661,7 @@ class Application(QtWidgets.QMainWindow): self.count = 0 self.timer.setInterval(1000) - self.timer.timeout.connect(lambda: self.check_change_in_plotfile(currTime)) + self.timer.timeout.connect(lambda: self.check_change_in_plotfile(self.currTime)) self.timer.start() else: -- cgit From 7b36bfed265309672689cd6ddd04c9a24d115e9c Mon Sep 17 00:00:00 2001 From: Pranav P Date: Tue, 23 May 2023 17:11:33 +0530 Subject: Changed the polling approach to check ngspice simulation completion --- src/frontEnd/Application.py | 54 ++++----------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 7457ba7d..3b403279 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -559,59 +559,16 @@ class Application(QtWidgets.QMainWindow): # else: # proc = 'xterm' - # Edited by Sumanto Kar 25/08/2021 - if False and os.name != 'nt' and \ - self.checkIfProcessRunning('xterm') is False: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Warning Message") - self.msg.showMessage( - 'Simulation was interrupted/failed. ' - 'Please close all the Ngspice windows ' - 'and then rerun the simulation.' - ) - self.msg.exec_() - return - st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) is_ngspice_running = self.checkIfProcessRunning("ngspice") if not is_ngspice_running: + self.simulationCompleted = True if st.st_mtime >= currTime - 1: self.is_file_changed = True - self.timer.stop() - self.plot_simulation() - return - else: - self.timer.stop() - return + return except Exception: pass - - if self.is_file_changed is False: - self.timer.start() - - # Fail Safe ===> - self.count += 1 - if self.count >= 10: - self.timer.stop() - print( - "Ngspice taking too long for simulation. " - "Check netlist file (*.cir.out) " - "to change simulation parameters." - ) - - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Warning Message") - self.msg.showMessage( - 'Ngspice taking too long for simulation. ' - 'Check netlist file (*.cir.out) ' - 'to change simulation parameters.' - ) - self.msg.exec_() - - return def enableButtons(self, state): self.ngspice.setEnabled(state) @@ -629,14 +586,14 @@ class Application(QtWidgets.QMainWindow): def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] - self.timer = QtCore.QTimer(self) self.is_file_changed = False + self.simulationCompleted = False self.simulationEssentials = { - "timer": self.timer, "enableButtons": self.enableButtons, "isSimulationSuccess": self.isSimulationSuccess, "resetSimulationVariables": self.resetSimulationVariables, + "checkChangeInPlotFile": self.check_change_in_plotfile, } if self.projDir is not None: @@ -660,9 +617,6 @@ class Application(QtWidgets.QMainWindow): return self.count = 0 - self.timer.setInterval(1000) - self.timer.timeout.connect(lambda: self.check_change_in_plotfile(self.currTime)) - self.timer.start() else: self.msg = QtWidgets.QErrorMessage() -- cgit From 22570451ec4e2a86f489125ca540b7a86d682286 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Wed, 24 May 2023 12:14:06 +0530 Subject: Reduced passage of functions between objects via simulationEssentials --- src/frontEnd/Application.py | 76 ++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 43 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 3b403279..2eabcb12 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -83,7 +83,7 @@ class Application(QtWidgets.QMainWindow): self.systemTrayIcon.setIcon(QtGui.QIcon(init_path + 'images/logo.png')) self.systemTrayIcon.setVisible(True) - self.is_file_changed = False + self.isFileChanged = False def initToolBar(self): """ @@ -552,23 +552,37 @@ class Application(QtWidgets.QMainWindow): pass return False - def check_change_in_plotfile(self, currTime): - try: - # if os.name == 'nt': - # proc = 'mintty' - # else: - # proc = 'xterm' - - st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - is_ngspice_running = self.checkIfProcessRunning("ngspice") - if not is_ngspice_running: + def checkChangeInPlotFile(self, currTime, exitStatus): + self.enableButtons(True) + if exitStatus == QtCore.QProcess.NormalExit: + try: + # if os.name == 'nt': + # proc = 'mintty' + # else: + # proc = 'xterm' + + st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) self.simulationCompleted = True - if st.st_mtime >= currTime - 1: - self.is_file_changed = True - self.plot_simulation() + if st.st_mtime >= currTime: + self.isFileChanged = True + + try: + self.obj_Mainview.obj_dockarea.plottingEditor() + except Exception as e: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Error Message") + self.msg.showMessage( + 'Error while opening python plotting Editor.' + ' Please look at console for more details.' + ) + self.msg.exec_() + print("Exception Message:", str(e), traceback.format_exc()) + self.obj_appconfig.print_error('Exception Message : ' + str(e)) + return - except Exception: - pass + except Exception: + pass def enableButtons(self, state): self.ngspice.setEnabled(state) @@ -577,30 +591,23 @@ class Application(QtWidgets.QMainWindow): self.wrkspce.setEnabled(state) def isSimulationSuccess(self): - return self.is_file_changed - - def resetSimulationVariables(self): - self.count = 0 - self.currTime = 0 + return self.isFileChanged def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] - self.is_file_changed = False + self.isFileChanged = False self.simulationCompleted = False self.simulationEssentials = { "enableButtons": self.enableButtons, - "isSimulationSuccess": self.isSimulationSuccess, - "resetSimulationVariables": self.resetSimulationVariables, - "checkChangeInPlotFile": self.check_change_in_plotfile, + "checkChangeInPlotFile": self.checkChangeInPlotFile, } if self.projDir is not None: self.currTime = time.time() # Edited by Sumanto Kar 25/08/2021 - self.enableButtons(False) if self.obj_Mainview.obj_dockarea.ngspiceEditor( self.projDir, self.simulationEssentials) is False: print( @@ -616,8 +623,6 @@ class Application(QtWidgets.QMainWindow): self.msg.exec_() return - self.count = 0 - else: self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) @@ -628,21 +633,6 @@ class Application(QtWidgets.QMainWindow): ) self.msg.exec_() - def plot_simulation(self): - try: - self.obj_Mainview.obj_dockarea.plottingEditor() - except Exception as e: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Error Message") - self.msg.showMessage( - 'Error while opening python plotting Editor.' - ' Please look at console for more details.' - ) - self.msg.exec_() - print("Exception Message:", str(e), traceback.format_exc()) - self.obj_appconfig.print_error('Exception Message : ' + str(e)) - def open_subcircuit(self): """ This function opens 'subcircuit' option in left-tool-bar. -- cgit From 6ae708e34a0c38ee73acabf3af98deaac62e6cd6 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Wed, 24 May 2023 14:23:33 +0530 Subject: Changed the name progressBar to TerminalUi --- src/frontEnd/Application.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 2eabcb12..e768d6b8 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -599,7 +599,7 @@ class Application(QtWidgets.QMainWindow): self.isFileChanged = False self.simulationCompleted = False - self.simulationEssentials = { + simulationEssentials = { "enableButtons": self.enableButtons, "checkChangeInPlotFile": self.checkChangeInPlotFile, } @@ -609,7 +609,7 @@ class Application(QtWidgets.QMainWindow): # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir, self.simulationEssentials) is False: + self.projDir, simulationEssentials) is False: print( "Netlist file (*.cir.out) not found." ) -- cgit From 64d0d1771b0bc41710897860d7a395d8f5fb4600 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Wed, 24 May 2023 15:43:39 +0530 Subject: Readded old xterm check and commented it out --- src/frontEnd/Application.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index e768d6b8..b45509a7 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -561,6 +561,20 @@ class Application(QtWidgets.QMainWindow): # else: # proc = 'xterm' + # # Edited by Sumanto Kar 25/08/2021 + # if False and os.name != 'nt' and \ + # self.checkIfProcessRunning('xterm') is False: + # self.msg = QtWidgets.QErrorMessage() + # self.msg.setModal(True) + # self.msg.setWindowTitle("Warning Message") + # self.msg.showMessage( + # 'Simulation was interrupted/failed. ' + # 'Please close all the Ngspice windows ' + # 'and then rerun the simulation.' + # ) + # self.msg.exec_() + # return + st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) self.simulationCompleted = True if st.st_mtime >= currTime: -- cgit From 1129cf1035c1ac520d84c04b384f758e090be0c3 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 25 May 2023 14:44:03 +0530 Subject: Added sphinx docstring documentation to newly added functions and removed some unnecessary variables --- src/frontEnd/Application.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index b45509a7..140fd5f5 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -83,8 +83,6 @@ class Application(QtWidgets.QMainWindow): self.systemTrayIcon.setIcon(QtGui.QIcon(init_path + 'images/logo.png')) self.systemTrayIcon.setVisible(True) - self.isFileChanged = False - def initToolBar(self): """ This function initializes Tool Bars. @@ -553,6 +551,14 @@ class Application(QtWidgets.QMainWindow): return False def checkChangeInPlotFile(self, currTime, exitStatus): + """Checks whether there is a change in the analysis files(To see if simulation was successful) + and displays the plotter where graphs can be plotted. + + :param currTime: The time stamp of the analysis file before simulation starts + :type currTime: float + :param exitStatus: The exit status of the ngspice QProcess + :type exitStatus: class:`QtCore.QProcess.ExitStatus` + """ self.enableButtons(True) if exitStatus == QtCore.QProcess.NormalExit: try: @@ -576,9 +582,7 @@ class Application(QtWidgets.QMainWindow): # return st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - self.simulationCompleted = True if st.st_mtime >= currTime: - self.isFileChanged = True try: self.obj_Mainview.obj_dockarea.plottingEditor() @@ -604,14 +608,9 @@ class Application(QtWidgets.QMainWindow): self.closeproj.setEnabled(state) self.wrkspce.setEnabled(state) - def isSimulationSuccess(self): - return self.isFileChanged - def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] - self.isFileChanged = False - self.simulationCompleted = False simulationEssentials = { "enableButtons": self.enableButtons, @@ -619,7 +618,6 @@ class Application(QtWidgets.QMainWindow): } if self.projDir is not None: - self.currTime = time.time() # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( -- cgit From b0dc41fb3e6ae9fb0f29b4e44524250807d41e49 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 1 Jun 2023 11:43:06 +0530 Subject: Fixes for PR --- src/frontEnd/Application.py | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 140fd5f5..8375e0e3 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -12,9 +12,10 @@ # AUTHOR: Fahim Khan, fahim.elex@gmail.com # MAINTAINED: Rahul Paknikar, rahulp@cse.iitb.ac.in # Sumanto Kar, sumantokar@iitb.ac.in +# Pranav P, pranavsdreams@gmail.com # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Tuesday 13 September 2022 +# REVISION: Thursday 01 June 2023 # ========================================================================= import os @@ -550,7 +551,7 @@ class Application(QtWidgets.QMainWindow): pass return False - def checkChangeInPlotFile(self, currTime, exitStatus): + def checkChangeInPlotData(self, currTime, exitStatus): """Checks whether there is a change in the analysis files(To see if simulation was successful) and displays the plotter where graphs can be plotted. @@ -559,27 +560,9 @@ class Application(QtWidgets.QMainWindow): :param exitStatus: The exit status of the ngspice QProcess :type exitStatus: class:`QtCore.QProcess.ExitStatus` """ - self.enableButtons(True) + self.toggleToolbarButtons(True) if exitStatus == QtCore.QProcess.NormalExit: try: - # if os.name == 'nt': - # proc = 'mintty' - # else: - # proc = 'xterm' - - # # Edited by Sumanto Kar 25/08/2021 - # if False and os.name != 'nt' and \ - # self.checkIfProcessRunning('xterm') is False: - # self.msg = QtWidgets.QErrorMessage() - # self.msg.setModal(True) - # self.msg.setWindowTitle("Warning Message") - # self.msg.showMessage( - # 'Simulation was interrupted/failed. ' - # 'Please close all the Ngspice windows ' - # 'and then rerun the simulation.' - # ) - # self.msg.exec_() - # return st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) if st.st_mtime >= currTime: @@ -597,12 +580,14 @@ class Application(QtWidgets.QMainWindow): self.msg.exec_() print("Exception Message:", str(e), traceback.format_exc()) self.obj_appconfig.print_error('Exception Message : ' + str(e)) + + self.currTime = time.time() return except Exception: pass - def enableButtons(self, state): + def toggleToolbarButtons(self, state): self.ngspice.setEnabled(state) self.conversion.setEnabled(state) self.closeproj.setEnabled(state) @@ -613,12 +598,18 @@ class Application(QtWidgets.QMainWindow): self.projDir = self.obj_appconfig.current_project["ProjectName"] simulationEssentials = { - "enableButtons": self.enableButtons, - "checkChangeInPlotFile": self.checkChangeInPlotFile, + "toggleToolbarButtons": self.toggleToolbarButtons, + "checkChangeInPlotData": self.checkChangeInPlotData, } - + if self.projDir is not None: + self.currTime = time.time() + + process = self.obj_Mainview.obj_dockarea.qprocess + process.started.connect(lambda: self.toggleToolbarButtons(state=False)) + process.finished.connect(lambda exitCode, exitStatus: self.checkChangeInPlotData(self.currTime, exitStatus)) + # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( self.projDir, simulationEssentials) is False: @@ -634,7 +625,7 @@ class Application(QtWidgets.QMainWindow): ) self.msg.exec_() return - + else: self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) -- cgit From 9a01a2606665c521c1ee10fa94394127d5decbf3 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 1 Jun 2023 12:42:10 +0530 Subject: Changed style in accordance with flake8 --- src/frontEnd/Application.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 8375e0e3..a78f7cd8 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -550,12 +550,14 @@ class Application(QtWidgets.QMainWindow): psutil.AccessDenied, psutil.ZombieProcess): pass return False - + def checkChangeInPlotData(self, currTime, exitStatus): - """Checks whether there is a change in the analysis files(To see if simulation was successful) + """Checks whether there is a change in the analysis files. + (To see if simulation was successful) and displays the plotter where graphs can be plotted. - :param currTime: The time stamp of the analysis file before simulation starts + :param currTime: The time stamp of the analysis file + before simulation starts :type currTime: float :param exitStatus: The exit status of the ngspice QProcess :type exitStatus: class:`QtCore.QProcess.ExitStatus` @@ -578,15 +580,17 @@ class Application(QtWidgets.QMainWindow): ' Please look at console for more details.' ) self.msg.exec_() - print("Exception Message:", str(e), traceback.format_exc()) - self.obj_appconfig.print_error('Exception Message : ' + str(e)) - + print("Exception Message:", str(e), + traceback.format_exc()) + self.obj_appconfig.print_error('Exception Message : ' + + str(e)) + self.currTime = time.time() return except Exception: pass - + def toggleToolbarButtons(self, state): self.ngspice.setEnabled(state) self.conversion.setEnabled(state) @@ -601,14 +605,17 @@ class Application(QtWidgets.QMainWindow): "toggleToolbarButtons": self.toggleToolbarButtons, "checkChangeInPlotData": self.checkChangeInPlotData, } - + if self.projDir is not None: self.currTime = time.time() process = self.obj_Mainview.obj_dockarea.qprocess - process.started.connect(lambda: self.toggleToolbarButtons(state=False)) - process.finished.connect(lambda exitCode, exitStatus: self.checkChangeInPlotData(self.currTime, exitStatus)) + process.started.connect(lambda: + self.toggleToolbarButtons(state=False)) + process.finished.connect(lambda exitCode, exitStatus: + self.checkChangeInPlotData(self.currTime, + exitStatus)) # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( @@ -625,7 +632,7 @@ class Application(QtWidgets.QMainWindow): ) self.msg.exec_() return - + else: self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) -- cgit From fb53f8b67cb15802c1d5ddbe59cf880c1d98954f Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 1 Jun 2023 14:55:41 +0530 Subject: Changed title names of docker tabs --- src/frontEnd/Application.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index a78f7cd8..26a988ce 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -601,11 +601,6 @@ class Application(QtWidgets.QMainWindow): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] - simulationEssentials = { - "toggleToolbarButtons": self.toggleToolbarButtons, - "checkChangeInPlotData": self.checkChangeInPlotData, - } - if self.projDir is not None: self.currTime = time.time() @@ -619,7 +614,7 @@ class Application(QtWidgets.QMainWindow): # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir, simulationEssentials) is False: + self.projDir) is False: print( "Netlist file (*.cir.out) not found." ) -- cgit From d8a2de2ef6126654184a1924cd21d242bea1be18 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 1 Jun 2023 17:38:18 +0530 Subject: PR fixes --- src/frontEnd/Application.py | 72 ++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 44 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 26a988ce..d3025fe4 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -40,7 +40,6 @@ from frontEnd import Workspace from frontEnd import DockArea from PyQt5.Qt import QSize import shutil -import time import sys import psutil @@ -551,47 +550,37 @@ class Application(QtWidgets.QMainWindow): pass return False - def checkChangeInPlotData(self, currTime, exitStatus): +# @QtCore.pyqtSlot(int, QtCore.QProcess.ExitStatus) + def checkChangeInPlotData(self, exitCode): """Checks whether there is a change in the analysis files. (To see if simulation was successful) and displays the plotter where graphs can be plotted. - - :param currTime: The time stamp of the analysis file - before simulation starts - :type currTime: float - :param exitStatus: The exit status of the ngspice QProcess - :type exitStatus: class:`QtCore.QProcess.ExitStatus` + :param exitCode: The exit status of the ngspice QProcess + :type exitCode: int """ self.toggleToolbarButtons(True) - if exitStatus == QtCore.QProcess.NormalExit: + if exitCode == 0: try: - - st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - if st.st_mtime >= currTime: - - try: - self.obj_Mainview.obj_dockarea.plottingEditor() - except Exception as e: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Error Message") - self.msg.showMessage( - 'Error while opening python plotting Editor.' - ' Please look at console for more details.' - ) - self.msg.exec_() - print("Exception Message:", str(e), - traceback.format_exc()) - self.obj_appconfig.print_error('Exception Message : ' - + str(e)) - - self.currTime = time.time() - - return - except Exception: - pass + self.obj_Mainview.obj_dockarea.plottingEditor() + except Exception as e: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Error Message") + self.msg.showMessage( + 'Error while opening python plotting Editor.' + ' Please look at console for more details.' + ) + self.msg.exec_() + print("Exception Message:", str(e), traceback.format_exc()) + self.obj_appconfig.print_error('Exception Message : ' + + str(e)) def toggleToolbarButtons(self, state): + """This function is used to disable buttons related to simulation + during the ngspice simulation and to enable it back once the + simulation is completed + param: state: Decides whether to enable or disable the button + type: state: bool""" self.ngspice.setEnabled(state) self.conversion.setEnabled(state) self.closeproj.setEnabled(state) @@ -602,19 +591,14 @@ class Application(QtWidgets.QMainWindow): self.projDir = self.obj_appconfig.current_project["ProjectName"] if self.projDir is not None: - - self.currTime = time.time() - - process = self.obj_Mainview.obj_dockarea.qprocess - process.started.connect(lambda: - self.toggleToolbarButtons(state=False)) - process.finished.connect(lambda exitCode, exitStatus: - self.checkChangeInPlotData(self.currTime, - exitStatus)) + simulationEssentials = { + 'checkChangeInPlotData': self.checkChangeInPlotData, + 'toggleToolbarButtons': self.toggleToolbarButtons + } # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir) is False: + self.projDir, simulationEssentials) is False: print( "Netlist file (*.cir.out) not found." ) -- cgit From abf7ef8beebf78552d068ebeed1393fd79a81abc Mon Sep 17 00:00:00 2001 From: Pranav P Date: Sat, 3 Jun 2023 17:35:25 +0530 Subject: Got rid of simulationEssentials --- src/frontEnd/Application.py | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index d3025fe4..563ebb94 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -558,7 +558,11 @@ class Application(QtWidgets.QMainWindow): :param exitCode: The exit status of the ngspice QProcess :type exitCode: int """ - self.toggleToolbarButtons(True) + self.ngspice.setEnabled(True) + self.conversion.setEnabled(True) + self.closeproj.setEnabled(True) + self.wrkspce.setEnabled(True) + if exitCode == 0: try: self.obj_Mainview.obj_dockarea.plottingEditor() @@ -575,30 +579,36 @@ class Application(QtWidgets.QMainWindow): self.obj_appconfig.print_error('Exception Message : ' + str(e)) - def toggleToolbarButtons(self, state): + def startSimulation(self, process, function): """This function is used to disable buttons related to simulation - during the ngspice simulation and to enable it back once the - simulation is completed - param: state: Decides whether to enable or disable the button - type: state: bool""" - self.ngspice.setEnabled(state) - self.conversion.setEnabled(state) - self.closeproj.setEnabled(state) - self.wrkspce.setEnabled(state) + during the ngspice simulation and to connect the + `self.checkChangeInPlotData` function to finished signal if not + already connected. + param: process: The QProcess that runs the simulation + type: process: :class:`QtCore.QProcess`""" + self.ngspice.setEnabled(False) + self.conversion.setEnabled(False) + self.closeproj.setEnabled(False) + self.wrkspce.setEnabled(False) + + if process.isFinishConnected is False: + process.isFinishConnected = True + +# Calls the finished connect exactly once. + process.finished.connect( + lambda exitCode, exitStatus: + function(exitCode, exitStatus, self.checkChangeInPlotData) + ) def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] if self.projDir is not None: - simulationEssentials = { - 'checkChangeInPlotData': self.checkChangeInPlotData, - 'toggleToolbarButtons': self.toggleToolbarButtons - } # Edited by Sumanto Kar 25/08/2021 if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir, simulationEssentials) is False: + self.projDir, self.startSimulation) is False: print( "Netlist file (*.cir.out) not found." ) -- cgit From a16cf9dc1c365e8372335fab04d7f6c2114122ca Mon Sep 17 00:00:00 2001 From: Pranav P Date: Sat, 3 Jun 2023 17:55:40 +0530 Subject: Updated docstrings for sphinx documentation --- src/frontEnd/Application.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 563ebb94..ae29c657 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -550,11 +550,10 @@ class Application(QtWidgets.QMainWindow): pass return False -# @QtCore.pyqtSlot(int, QtCore.QProcess.ExitStatus) - def checkChangeInPlotData(self, exitCode): - """Checks whether there is a change in the analysis files. - (To see if simulation was successful) - and displays the plotter where graphs can be plotted. + def checkNgspiceProcessFinished(self, exitCode): + """Checks whether the QProcess that runs ngspice + finished successfully and displays the plotter + where graphs can be plotted. :param exitCode: The exit status of the ngspice QProcess :type exitCode: int """ @@ -582,10 +581,13 @@ class Application(QtWidgets.QMainWindow): def startSimulation(self, process, function): """This function is used to disable buttons related to simulation during the ngspice simulation and to connect the - `self.checkChangeInPlotData` function to finished signal if not + `self.checkNgspiceProcessFinished` function to finished signal if not already connected. - param: process: The QProcess that runs the simulation - type: process: :class:`QtCore.QProcess`""" + :param process: The QProcess that runs the simulation + :type process: :class:`QtCore.QProcess` + :param function: Used to call the finishSimulation function in + :class:`NgspiceWidget.NgspiceWidget` class + :type function: function""" self.ngspice.setEnabled(False) self.conversion.setEnabled(False) self.closeproj.setEnabled(False) @@ -597,7 +599,8 @@ class Application(QtWidgets.QMainWindow): # Calls the finished connect exactly once. process.finished.connect( lambda exitCode, exitStatus: - function(exitCode, exitStatus, self.checkChangeInPlotData) + function(exitCode, exitStatus, + self.checkNgspiceProcessFinished) ) def open_ngspice(self): -- cgit From c99a4951df139de96e80a51805a3b4d677336653 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Wed, 7 Jun 2023 16:26:35 +0530 Subject: sim. process switched to qt slot-signal mech. & report errors --- src/frontEnd/Application.py | 100 +++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 67 deletions(-) (limited to 'src/frontEnd/Application.py') diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index ae29c657..790bf779 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -10,15 +10,17 @@ # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com -# MAINTAINED: Rahul Paknikar, rahulp@cse.iitb.ac.in +# MAINTAINED: Rahul Paknikar, rahulp@iitb.ac.in # Sumanto Kar, sumantokar@iitb.ac.in # Pranav P, pranavsdreams@gmail.com # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Thursday 01 June 2023 +# REVISION: Wednesday 07 June 2023 # ========================================================================= import os +import sys +import shutil import traceback if os.name == 'nt': @@ -29,19 +31,16 @@ else: init_path = '../../' from PyQt5 import QtGui, QtCore, QtWidgets +from PyQt5.Qt import QSize from configuration.Appconfig import Appconfig +from frontEnd import ProjectExplorer +from frontEnd import Workspace +from frontEnd import DockArea from projManagement.openProject import OpenProjectInfo from projManagement.newProject import NewProjectInfo from projManagement.Kicad import Kicad from projManagement.Validation import Validation from projManagement import Worker -from frontEnd import ProjectExplorer -from frontEnd import Workspace -from frontEnd import DockArea -from PyQt5.Qt import QSize -import shutil -import sys -import psutil # Its our main window of application. @@ -49,6 +48,7 @@ import psutil class Application(QtWidgets.QMainWindow): """This class initializes all objects used in this file.""" global project_name + simulationEndSignal = QtCore.pyqtSignal(QtCore.QProcess.ExitStatus, int) def __init__(self, *args): """Initialize main Application window.""" @@ -59,6 +59,9 @@ class Application(QtWidgets.QMainWindow): # Flag for mode of operation. Default is set to offline mode. self.online_flag = False + # Set slot for simulation end signal to plot simulation data + self.simulationEndSignal.connect(self.plotSimulationData) + # Creating require Object self.obj_workspace = Workspace.Workspace() self.obj_Mainview = MainView() @@ -534,35 +537,17 @@ class Application(QtWidgets.QMainWindow): print("Current Project is : ", self.obj_appconfig.current_project) self.obj_Mainview.obj_dockarea.usermanual() - def checkIfProcessRunning(self, processName): - ''' - Check if there is any running process - that contains the given name processName. - ''' - # Iterate over the all the running process - for proc in psutil.process_iter(): - try: - # Check if process name contains the given name string. - if processName.lower() in proc.name().lower(): - return True - except (psutil.NoSuchProcess, - psutil.AccessDenied, psutil.ZombieProcess): - pass - return False - - def checkNgspiceProcessFinished(self, exitCode): - """Checks whether the QProcess that runs ngspice - finished successfully and displays the plotter - where graphs can be plotted. - :param exitCode: The exit status of the ngspice QProcess - :type exitCode: int + @QtCore.pyqtSlot(QtCore.QProcess.ExitStatus, int) + def plotSimulationData(self, exitCode, exitStatus): + """Enables interaction for new simulation and + displays the plotter dock where graphs can be plotted. """ self.ngspice.setEnabled(True) self.conversion.setEnabled(True) self.closeproj.setEnabled(True) self.wrkspce.setEnabled(True) - if exitCode == 0: + if exitStatus == QtCore.QProcess.NormalExit and exitCode == 0: try: self.obj_Mainview.obj_dockarea.plottingEditor() except Exception as e: @@ -570,61 +555,42 @@ class Application(QtWidgets.QMainWindow): self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( - 'Error while opening python plotting Editor.' - ' Please look at console for more details.' + 'Data could not be plotted. Please try again.' ) self.msg.exec_() print("Exception Message:", str(e), traceback.format_exc()) self.obj_appconfig.print_error('Exception Message : ' + str(e)) - def startSimulation(self, process, function): - """This function is used to disable buttons related to simulation - during the ngspice simulation and to connect the - `self.checkNgspiceProcessFinished` function to finished signal if not - already connected. - :param process: The QProcess that runs the simulation - :type process: :class:`QtCore.QProcess` - :param function: Used to call the finishSimulation function in - :class:`NgspiceWidget.NgspiceWidget` class - :type function: function""" - self.ngspice.setEnabled(False) - self.conversion.setEnabled(False) - self.closeproj.setEnabled(False) - self.wrkspce.setEnabled(False) - - if process.isFinishConnected is False: - process.isFinishConnected = True - -# Calls the finished connect exactly once. - process.finished.connect( - lambda exitCode, exitStatus: - function(exitCode, exitStatus, - self.checkNgspiceProcessFinished) - ) - def open_ngspice(self): """This Function execute ngspice on current project.""" - self.projDir = self.obj_appconfig.current_project["ProjectName"] + projDir = self.obj_appconfig.current_project["ProjectName"] - if self.projDir is not None: + if projDir is not None: + projName = os.path.basename(projDir) + ngspiceNetlist = os.path.join(projDir, projName + ".cir.out") - # Edited by Sumanto Kar 25/08/2021 - if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir, self.startSimulation) is False: + if not os.path.isfile(ngspiceNetlist): print( "Netlist file (*.cir.out) not found." ) - self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( - 'Netlist file (*.cir.out) not found.' + 'Netlist (*.cir.out) not found.' ) self.msg.exec_() return + self.obj_Mainview.obj_dockarea.ngspiceEditor( + projName, ngspiceNetlist, self.simulationEndSignal) + + self.ngspice.setEnabled(False) + self.conversion.setEnabled(False) + self.closeproj.setEnabled(False) + self.wrkspce.setEnabled(False) + else: self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) @@ -726,7 +692,7 @@ class Application(QtWidgets.QMainWindow): # Creating a command for Ngspice to Modelica converter self.cmd1 = " python3 ../ngspicetoModelica/NgspicetoModelica.py "\ - +self.ngspiceNetlist + + self.ngspiceNetlist self.obj_workThread1 = Worker.WorkerThread(self.cmd1) self.obj_workThread1.start() if self.obj_validation.validateTool("OMEdit"): -- cgit