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') 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') 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 ++- src/frontEnd/icons/dark_mode.png | Bin 0 -> 951 bytes src/frontEnd/icons/light_mode.png | Bin 0 -> 989 bytes 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/frontEnd/icons/dark_mode.png create mode 100644 src/frontEnd/icons/light_mode.png (limited to 'src/frontEnd') 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) " diff --git a/src/frontEnd/icons/dark_mode.png b/src/frontEnd/icons/dark_mode.png new file mode 100644 index 00000000..a29b53f6 Binary files /dev/null and b/src/frontEnd/icons/dark_mode.png differ diff --git a/src/frontEnd/icons/light_mode.png b/src/frontEnd/icons/light_mode.png new file mode 100644 index 00000000..b40872c4 Binary files /dev/null and b/src/frontEnd/icons/light_mode.png differ -- 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 ++-- src/frontEnd/DockArea.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/frontEnd') 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() diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 461240b9..4cab6261 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -117,9 +117,10 @@ class DockArea(QtWidgets.QMainWindow): ) count = count + 1 - def ngspiceEditor(self, projDir): + def ngspiceEditor(self, projDir, timer): """ This function creates widget for Ngspice window.""" self.projDir = projDir + self.qTimer = timer self.projName = os.path.basename(self.projDir) self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") @@ -133,7 +134,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, self.projDir) + NgspiceWidget(self.ngspiceNetlist, self.projDir, self.qTimer) ) # Adding to main Layout -- 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 ++++++++++++++- src/frontEnd/DockArea.py | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/frontEnd') 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." ) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 4cab6261..cf21199d 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -117,10 +117,10 @@ class DockArea(QtWidgets.QMainWindow): ) count = count + 1 - def ngspiceEditor(self, projDir, timer): + def ngspiceEditor(self, projDir, simulationEssentials): """ This function creates widget for Ngspice window.""" self.projDir = projDir - self.qTimer = timer + self.simulationEssentials = simulationEssentials self.projName = os.path.basename(self.projDir) self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") @@ -134,7 +134,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, self.projDir, self.qTimer) + NgspiceWidget(self.ngspiceNetlist, self.projDir, self.simulationEssentials) ) # Adding to main Layout -- 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') 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') 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 5ade06b5d3559b1d01dafdfabcb71f169bfd633c Mon Sep 17 00:00:00 2001 From: Pranav P Date: Mon, 15 May 2023 19:53:05 +0530 Subject: Changed simulation status colour and dark mode icon path --- src/frontEnd/icons/dark_mode.png | Bin 951 -> 0 bytes src/frontEnd/icons/light_mode.png | Bin 989 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/frontEnd/icons/dark_mode.png delete mode 100644 src/frontEnd/icons/light_mode.png (limited to 'src/frontEnd') diff --git a/src/frontEnd/icons/dark_mode.png b/src/frontEnd/icons/dark_mode.png deleted file mode 100644 index a29b53f6..00000000 Binary files a/src/frontEnd/icons/dark_mode.png and /dev/null differ diff --git a/src/frontEnd/icons/light_mode.png b/src/frontEnd/icons/light_mode.png deleted file mode 100644 index b40872c4..00000000 Binary files a/src/frontEnd/icons/light_mode.png and /dev/null differ -- 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') 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 ++++----------------------------------------- src/frontEnd/DockArea.py | 3 +-- 2 files changed, 5 insertions(+), 52 deletions(-) (limited to 'src/frontEnd') 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() diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index cf21199d..acf5b3d1 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -120,7 +120,6 @@ class DockArea(QtWidgets.QMainWindow): def ngspiceEditor(self, projDir, simulationEssentials): """ This function creates widget for Ngspice window.""" self.projDir = projDir - self.simulationEssentials = simulationEssentials self.projName = os.path.basename(self.projDir) self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") @@ -134,7 +133,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, self.projDir, self.simulationEssentials) + NgspiceWidget(self.ngspiceNetlist, self.projDir, simulationEssentials) ) # Adding to main Layout -- 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 ++++++++++++++++++++------------------------- src/frontEnd/DockArea.py | 2 +- 2 files changed, 34 insertions(+), 44 deletions(-) (limited to 'src/frontEnd') 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. diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index acf5b3d1..2a14b978 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -133,7 +133,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, self.projDir, simulationEssentials) + NgspiceWidget(self.ngspiceNetlist, simulationEssentials) ) # Adding to main Layout -- 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 +- src/frontEnd/TerminalUi.py | 154 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 src/frontEnd/TerminalUi.py (limited to 'src/frontEnd') 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." ) diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py new file mode 100644 index 00000000..b5f7a836 --- /dev/null +++ b/src/frontEnd/TerminalUi.py @@ -0,0 +1,154 @@ +from PyQt5 import QtCore, QtGui, QtWidgets +import os + + +class Ui_Form(object): + def __init__(self, qProcess): + self.qProcess = qProcess + self.iconDir = "../../images" + # super().__init__() + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(1244, 644) + self.verticalLayoutWidget = QtWidgets.QWidget(Form) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 1131, 471)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) + self.verticalLayout.setContentsMargins(15, 15, 15, 15) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) + self.horizontalLayout.setSpacing(6) + self.horizontalLayout.setObjectName("horizontalLayout") + self.terminalUi = QtWidgets.QProgressBar(self.verticalLayoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.terminalUi.sizePolicy().hasHeightForWidth()) + self.terminalUi.setSizePolicy(sizePolicy) + self.terminalUi.setMaximumSize(QtCore.QSize(16777215, 35)) + self.terminalUi.setStyleSheet("QProgressBar::chunk {\n" +" background-color: rgb(54,158,225);\n" +"}") + self.terminalUi.setMaximum(0) + self.terminalUi.setProperty("value", -1) + self.terminalUi.setFormat("") + self.terminalUi.setObjectName("progressBar") + self.horizontalLayout.addWidget(self.terminalUi) + self.redo_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) + self.redo_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) + self.redo_simulation_button.setObjectName("redo_simulation_button") + self.horizontalLayout.addWidget(self.redo_simulation_button) + self.cancel_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) + self.cancel_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) + self.cancel_simulation_button.setObjectName("cancel_simulation_button") + self.horizontalLayout.addWidget(self.cancel_simulation_button) + self.light_dark_mode_button = QtWidgets.QPushButton(self.verticalLayoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.light_dark_mode_button.sizePolicy().hasHeightForWidth()) + self.light_dark_mode_button.setSizePolicy(sizePolicy) + self.light_dark_mode_button.setMaximumSize(QtCore.QSize(35, 35)) + self.light_dark_mode_button.setText("") + self.light_dark_mode_button.setObjectName("light_dark_mode_button") + self.horizontalLayout.addWidget(self.light_dark_mode_button) + self.verticalLayout.addLayout(self.horizontalLayout) + self.simulationConsole = QtWidgets.QTextEdit(self.verticalLayoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.simulationConsole.sizePolicy().hasHeightForWidth()) + self.simulationConsole.setSizePolicy(sizePolicy) + self.simulationConsole.setMinimumSize(QtCore.QSize(0, 400)) + self.simulationConsole.setStyleSheet("QTextEdit {\n" +" background-color: rgb(36, 31, 49);\n" +" color: white;\n" +"}") + self.simulationConsole.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + self.simulationConsole.setObjectName("simulationConsole") + self.verticalLayout.addWidget(self.simulationConsole) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.redo_simulation_button.setText(_translate("Form", "Redo Simulation")) + self.cancel_simulation_button.setText(_translate("Form", "Cancel Simulation")) + self.simulationConsole.setHtml(_translate("Form", "\n" +"\n" +"

The quick brown fox jumped over the lazy dog

")) + + self.simulationConsole.setText("") + + self.dark_color = True + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, 'light_mode.png'))) + self.light_dark_mode_button.clicked.connect(self.changeColor) + + self.cancel_simulation_button.clicked.connect(self.cancelSimulation) + self.redo_simulation_button.clicked.connect(self.redoSimulation) + + def writeIntoConsole(self, consoleLog): + self.simulationConsole.insertPlainText(consoleLog) + + def writeSimulationStatusToConsole(self, isSuccess): + failedFormat = '{}' + successFormat = '{}' + + if self.qProcess.exitStatus() == QtCore.QProcess.NormalExit: + if isSuccess: + self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) + else: + self.simulationConsole.append(failedFormat.format("Simulation Failed!")) + + def scrollConsoleToBottom(self): + scrollLength = self.simulationConsole.verticalScrollBar().maximum() + self.simulationConsole.verticalScrollBar().setValue(scrollLength) + + def showProgressRunning(self): + self.terminalUi.setMaximum(0) + self.terminalUi.setProperty("value", -1) + + def showProgressCompleted(self): + self.terminalUi.setMaximum(100) + self.terminalUi.setProperty("value", 100) + + def cancelSimulation(self): + if (self.qProcess.state() == QtCore.QProcess.NotRunning): + return + cancelFormat = '{}' + self.qProcess.kill() + self.showProgressCompleted() + self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!")) + self.scrollConsoleToBottom() + + def setNgspiceArgs(self, args): + self.args = args + + def redoSimulation(self): + if (self.qProcess.state() == QtCore.QProcess.Running): + return + self.showProgressRunning() + self.simulationConsole.setText("") + self.qProcess.start('ngspice', self.args) + + def changeColor(self): + if self.dark_color is True: + self.simulationConsole.setStyleSheet("QTextEdit {\n" + " background-color: white;\n" + " color: black;\n" + "}") + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "dark_mode.png"))) + self.dark_color = False + else: + self.simulationConsole.setStyleSheet("QTextEdit {\n" + " background-color: rgb(36, 31, 49);\n" + " color: white;\n" + "}") + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) + self.dark_color = True \ No newline at end of file -- cgit From 3fc177d796b0e2591a016b153cd29e8db3364e8d Mon Sep 17 00:00:00 2001 From: Pranav P Date: Wed, 24 May 2023 15:32:21 +0530 Subject: Reduced the number of methods in TerminalUi --- src/frontEnd/TerminalUi.py | 57 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'src/frontEnd') diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index b5f7a836..4d6e6d23 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -3,8 +3,9 @@ import os class Ui_Form(object): - def __init__(self, qProcess): + def __init__(self, qProcess, args): self.qProcess = qProcess + self.args = args self.iconDir = "../../images" # super().__init__() def setupUi(self, Form): @@ -21,21 +22,21 @@ class Ui_Form(object): self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout.setSpacing(6) self.horizontalLayout.setObjectName("horizontalLayout") - self.terminalUi = QtWidgets.QProgressBar(self.verticalLayoutWidget) + self.progressBar = QtWidgets.QProgressBar(self.verticalLayoutWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.terminalUi.sizePolicy().hasHeightForWidth()) - self.terminalUi.setSizePolicy(sizePolicy) - self.terminalUi.setMaximumSize(QtCore.QSize(16777215, 35)) - self.terminalUi.setStyleSheet("QProgressBar::chunk {\n" + sizePolicy.setHeightForWidth(self.progressBar.sizePolicy().hasHeightForWidth()) + self.progressBar.setSizePolicy(sizePolicy) + self.progressBar.setMaximumSize(QtCore.QSize(16777215, 35)) + self.progressBar.setStyleSheet("QProgressBar::chunk {\n" " background-color: rgb(54,158,225);\n" "}") - self.terminalUi.setMaximum(0) - self.terminalUi.setProperty("value", -1) - self.terminalUi.setFormat("") - self.terminalUi.setObjectName("progressBar") - self.horizontalLayout.addWidget(self.terminalUi) + self.progressBar.setMaximum(0) + self.progressBar.setProperty("value", -1) + self.progressBar.setFormat("") + self.progressBar.setObjectName("progressBar") + self.horizontalLayout.addWidget(self.progressBar) self.redo_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) self.redo_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) self.redo_simulation_button.setObjectName("redo_simulation_button") @@ -93,9 +94,6 @@ class Ui_Form(object): self.cancel_simulation_button.clicked.connect(self.cancelSimulation) self.redo_simulation_button.clicked.connect(self.redoSimulation) - def writeIntoConsole(self, consoleLog): - self.simulationConsole.insertPlainText(consoleLog) - def writeSimulationStatusToConsole(self, isSuccess): failedFormat = '{}' successFormat = '{}' @@ -105,35 +103,34 @@ class Ui_Form(object): self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) else: self.simulationConsole.append(failedFormat.format("Simulation Failed!")) - - def scrollConsoleToBottom(self): - scrollLength = self.simulationConsole.verticalScrollBar().maximum() - self.simulationConsole.verticalScrollBar().setValue(scrollLength) - - def showProgressRunning(self): - self.terminalUi.setMaximum(0) - self.terminalUi.setProperty("value", -1) def showProgressCompleted(self): - self.terminalUi.setMaximum(100) - self.terminalUi.setProperty("value", 100) + self.progressBar.setMaximum(100) + self.progressBar.setProperty("value", 100) def cancelSimulation(self): if (self.qProcess.state() == QtCore.QProcess.NotRunning): return cancelFormat = '{}' self.qProcess.kill() - self.showProgressCompleted() - self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!")) - self.scrollConsoleToBottom() + + #To show progressBar completed + self.progressBar.setMaximum(100) + self.progressBar.setProperty("value", 100) - def setNgspiceArgs(self, args): - self.args = args + self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!")) + self.simulationConsole.verticalScrollBar().setValue( + self.simulationConsole.verticalScrollBar().maximum() + ) def redoSimulation(self): if (self.qProcess.state() == QtCore.QProcess.Running): return - self.showProgressRunning() + + #To make the progressbar running + self.progressBar.setMaximum(0) + self.progressBar.setProperty("value", -1) + self.simulationConsole.setText("") self.qProcess.start('ngspice', self.args) -- 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') 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 ++++++++---------- src/frontEnd/TerminalUi.py | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src/frontEnd') 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( diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index 4d6e6d23..ecf93ee2 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -95,6 +95,12 @@ class Ui_Form(object): self.redo_simulation_button.clicked.connect(self.redoSimulation) def writeSimulationStatusToConsole(self, isSuccess): + """Writes simulation status to the console with appropriate style + to the :class:`Form_Ui` console. + + :param isSuccess: A boolean flag used to indicate whether the simulation was a success or not + :type isSuccess: bool + """ failedFormat = '{}' successFormat = '{}' @@ -103,12 +109,10 @@ class Ui_Form(object): self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) else: self.simulationConsole.append(failedFormat.format("Simulation Failed!")) - - def showProgressCompleted(self): - self.progressBar.setMaximum(100) - self.progressBar.setProperty("value", 100) def cancelSimulation(self): + """This function cancels the ongoing ngspice simulation. + """ if (self.qProcess.state() == QtCore.QProcess.NotRunning): return cancelFormat = '{}' @@ -124,6 +128,8 @@ class Ui_Form(object): ) def redoSimulation(self): + """This function reruns the ngspice simulation + """ if (self.qProcess.state() == QtCore.QProcess.Running): return @@ -135,6 +141,8 @@ class Ui_Form(object): self.qProcess.start('ngspice', self.args) def changeColor(self): + """Toggles the :class:`Ui_Form` console between dark mode and light mode + """ if self.dark_color is True: self.simulationConsole.setStyleSheet("QTextEdit {\n" " background-color: white;\n" -- cgit From 111e990dbfce47c53eba5cbe85fc1fbcbe5fe76d Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 25 May 2023 17:32:05 +0530 Subject: Now loads TerminalUi from ui file --- src/frontEnd/TerminalUi.py | 116 ++++++++------------------------ src/frontEnd/TerminalUi.ui | 163 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+), 89 deletions(-) create mode 100644 src/frontEnd/TerminalUi.ui (limited to 'src/frontEnd') diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index ecf93ee2..2d6493d7 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -1,98 +1,36 @@ -from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5 import QtCore, QtGui, QtWidgets, uic import os - -class Ui_Form(object): +class TerminalUi(QtWidgets.QMainWindow): def __init__(self, qProcess, args): + super(TerminalUi, self).__init__() + + #Other variables + self.darkColor = True self.qProcess = qProcess self.args = args self.iconDir = "../../images" - # super().__init__() - def setupUi(self, Form): - Form.setObjectName("Form") - Form.resize(1244, 644) - self.verticalLayoutWidget = QtWidgets.QWidget(Form) - self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 1131, 471)) - self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") - self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) - self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) - self.verticalLayout.setContentsMargins(15, 15, 15, 15) - self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout = QtWidgets.QHBoxLayout() - self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) - self.horizontalLayout.setSpacing(6) - self.horizontalLayout.setObjectName("horizontalLayout") - self.progressBar = QtWidgets.QProgressBar(self.verticalLayoutWidget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.progressBar.sizePolicy().hasHeightForWidth()) - self.progressBar.setSizePolicy(sizePolicy) - self.progressBar.setMaximumSize(QtCore.QSize(16777215, 35)) - self.progressBar.setStyleSheet("QProgressBar::chunk {\n" -" background-color: rgb(54,158,225);\n" -"}") - self.progressBar.setMaximum(0) - self.progressBar.setProperty("value", -1) - self.progressBar.setFormat("") - self.progressBar.setObjectName("progressBar") - self.horizontalLayout.addWidget(self.progressBar) - self.redo_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.redo_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) - self.redo_simulation_button.setObjectName("redo_simulation_button") - self.horizontalLayout.addWidget(self.redo_simulation_button) - self.cancel_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.cancel_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) - self.cancel_simulation_button.setObjectName("cancel_simulation_button") - self.horizontalLayout.addWidget(self.cancel_simulation_button) - self.light_dark_mode_button = QtWidgets.QPushButton(self.verticalLayoutWidget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.light_dark_mode_button.sizePolicy().hasHeightForWidth()) - self.light_dark_mode_button.setSizePolicy(sizePolicy) - self.light_dark_mode_button.setMaximumSize(QtCore.QSize(35, 35)) - self.light_dark_mode_button.setText("") - self.light_dark_mode_button.setObjectName("light_dark_mode_button") - self.horizontalLayout.addWidget(self.light_dark_mode_button) - self.verticalLayout.addLayout(self.horizontalLayout) - self.simulationConsole = QtWidgets.QTextEdit(self.verticalLayoutWidget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.simulationConsole.sizePolicy().hasHeightForWidth()) - self.simulationConsole.setSizePolicy(sizePolicy) - self.simulationConsole.setMinimumSize(QtCore.QSize(0, 400)) - self.simulationConsole.setStyleSheet("QTextEdit {\n" -" background-color: rgb(36, 31, 49);\n" -" color: white;\n" -"}") - self.simulationConsole.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) - self.simulationConsole.setObjectName("simulationConsole") - self.verticalLayout.addWidget(self.simulationConsole) - self.retranslateUi(Form) - QtCore.QMetaObject.connectSlotsByName(Form) + # def setupUi(self, Form): + #Load the ui file + uic.loadUi("TerminalUi.ui", self) - def retranslateUi(self, Form): - _translate = QtCore.QCoreApplication.translate - Form.setWindowTitle(_translate("Form", "Form")) - self.redo_simulation_button.setText(_translate("Form", "Redo Simulation")) - self.cancel_simulation_button.setText(_translate("Form", "Cancel Simulation")) - self.simulationConsole.setHtml(_translate("Form", "\n" -"\n" -"

The quick brown fox jumped over the lazy dog

")) + #Define Our Widgets + self.progressBar = self.findChild(QtWidgets.QProgressBar, "progressBar") + self.simulationConsole = self.findChild(QtWidgets.QTextEdit, "simulationConsole") - self.simulationConsole.setText("") + self.lightDarkModeButton = self.findChild(QtWidgets.QPushButton, "lightDarkModeButton") + self.cancelSimulationButton = self.findChild(QtWidgets.QPushButton, "cancelSimulationButton") + self.redoSimulationButton = self.findChild(QtWidgets.QPushButton, "redoSimulationButton") - self.dark_color = True - self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, 'light_mode.png'))) - self.light_dark_mode_button.clicked.connect(self.changeColor) + #Add functionalities to Widgets + self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, 'light_mode.png'))) + self.lightDarkModeButton.clicked.connect(self.changeColor) + self.cancelSimulationButton.clicked.connect(self.cancelSimulation) + self.redoSimulationButton.clicked.connect(self.redoSimulation) - self.cancel_simulation_button.clicked.connect(self.cancelSimulation) - self.redo_simulation_button.clicked.connect(self.redoSimulation) + #show app + self.show() def writeSimulationStatusToConsole(self, isSuccess): """Writes simulation status to the console with appropriate style @@ -143,17 +81,17 @@ class Ui_Form(object): def changeColor(self): """Toggles the :class:`Ui_Form` console between dark mode and light mode """ - if self.dark_color is True: + if self.darkColor is True: self.simulationConsole.setStyleSheet("QTextEdit {\n" " background-color: white;\n" " color: black;\n" "}") - self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "dark_mode.png"))) - self.dark_color = False + self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "dark_mode.png"))) + self.darkColor = False else: self.simulationConsole.setStyleSheet("QTextEdit {\n" " background-color: rgb(36, 31, 49);\n" " color: white;\n" "}") - self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) - self.dark_color = True \ No newline at end of file + self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) + self.darkColor = True \ No newline at end of file diff --git a/src/frontEnd/TerminalUi.ui b/src/frontEnd/TerminalUi.ui new file mode 100644 index 00000000..9039984d --- /dev/null +++ b/src/frontEnd/TerminalUi.ui @@ -0,0 +1,163 @@ + + + TerminalUi + + + + 0 + 0 + 1244 + 644 + + + + Form + + + + + 10 + 10 + 1131 + 471 + + + + + QLayout::SetDefaultConstraint + + + 15 + + + 15 + + + 15 + + + 15 + + + + + 6 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 35 + + + + QProgressBar::chunk { + background-color: rgb(54,158,225); +} + + + 0 + + + -1 + + + + + + + + + + + 16777215 + 35 + + + + Resimulate + + + + + + + + 16777215 + 35 + + + + Cancel Simulation + + + + + + + + 0 + 0 + + + + + 35 + 35 + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 400 + + + + QTextEdit { + background-color: rgb(36, 31, 49); + color: white; +} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + Qt::NoTextInteraction + + + + + + + + + -- 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 +++++++++++++++++-------------------------- src/frontEnd/DockArea.py | 4 +++- src/frontEnd/TerminalUi.py | 6 +++--- 3 files changed, 23 insertions(+), 30 deletions(-) (limited to 'src/frontEnd') 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) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 2a14b978..493e7f49 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -35,6 +35,8 @@ class DockArea(QtWidgets.QMainWindow): QtWidgets.QMainWindow.__init__(self) self.obj_appconfig = Appconfig() + self.qprocess = QtCore.QProcess(self) + for dockName in dockList: dock[dockName] = QtWidgets.QDockWidget(dockName) self.welcomeWidget = QtWidgets.QWidget() @@ -133,7 +135,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, simulationEssentials) + NgspiceWidget(self.ngspiceNetlist, self.qprocess) ) # Adding to main Layout diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index 2d6493d7..ddae32f3 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -39,8 +39,8 @@ class TerminalUi(QtWidgets.QMainWindow): :param isSuccess: A boolean flag used to indicate whether the simulation was a success or not :type isSuccess: bool """ - failedFormat = '{}' - successFormat = '{}' + failedFormat = '{}' + successFormat = '{}' if self.qProcess.exitStatus() == QtCore.QProcess.NormalExit: if isSuccess: @@ -53,7 +53,7 @@ class TerminalUi(QtWidgets.QMainWindow): """ if (self.qProcess.state() == QtCore.QProcess.NotRunning): return - cancelFormat = '{}' + cancelFormat = '{}' self.qProcess.kill() #To show progressBar completed -- 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 ++++++----- src/frontEnd/TerminalUi.py | 115 ++++++++++++++++++++++++++++++-------------- 2 files changed, 98 insertions(+), 46 deletions(-) (limited to 'src/frontEnd') 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) diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index ddae32f3..21b5b557 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -1,52 +1,81 @@ from PyQt5 import QtCore, QtGui, QtWidgets, uic import os + class TerminalUi(QtWidgets.QMainWindow): def __init__(self, qProcess, args): super(TerminalUi, self).__init__() - #Other variables +# Other variables self.darkColor = True self.qProcess = qProcess self.args = args self.iconDir = "../../images" - # def setupUi(self, Form): - #Load the ui file +# Load the ui file uic.loadUi("TerminalUi.ui", self) - #Define Our Widgets - self.progressBar = self.findChild(QtWidgets.QProgressBar, "progressBar") - self.simulationConsole = self.findChild(QtWidgets.QTextEdit, "simulationConsole") +# Define Our Widgets + self.progressBar = self.findChild( + QtWidgets.QProgressBar, + "progressBar" + ) + self.simulationConsole = self.findChild( + QtWidgets.QTextEdit, + "simulationConsole" + ) - self.lightDarkModeButton = self.findChild(QtWidgets.QPushButton, "lightDarkModeButton") - self.cancelSimulationButton = self.findChild(QtWidgets.QPushButton, "cancelSimulationButton") - self.redoSimulationButton = self.findChild(QtWidgets.QPushButton, "redoSimulationButton") + self.lightDarkModeButton = self.findChild( + QtWidgets.QPushButton, + "lightDarkModeButton" + ) + self.cancelSimulationButton = self.findChild( + QtWidgets.QPushButton, + "cancelSimulationButton" + ) + self.redoSimulationButton = self.findChild( + QtWidgets.QPushButton, + "redoSimulationButton" + ) - #Add functionalities to Widgets - self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, 'light_mode.png'))) +# Add functionalities to Widgets + self.lightDarkModeButton.setIcon( + QtGui.QIcon( + os.path.join( + self.iconDir, + 'light_mode.png' + ) + ) + ) self.lightDarkModeButton.clicked.connect(self.changeColor) self.cancelSimulationButton.clicked.connect(self.cancelSimulation) self.redoSimulationButton.clicked.connect(self.redoSimulation) - #show app +# show app self.show() def writeSimulationStatusToConsole(self, isSuccess): """Writes simulation status to the console with appropriate style to the :class:`Form_Ui` console. - - :param isSuccess: A boolean flag used to indicate whether the simulation was a success or not + + :param isSuccess: A boolean flag used to indicate whether the + simulation was a success or not :type isSuccess: bool """ - failedFormat = '{}' - successFormat = '{}' + failedFormat = ' \ + {} \ + ' + successFormat = ' \ + {} \ + ' if self.qProcess.exitStatus() == QtCore.QProcess.NormalExit: if isSuccess: - self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) + self.simulationConsole.append( + successFormat.format("Simulation Completed Successfully!")) else: - self.simulationConsole.append(failedFormat.format("Simulation Failed!")) + self.simulationConsole.append( + failedFormat.format("Simulation Failed!")) def cancelSimulation(self): """This function cancels the ongoing ngspice simulation. @@ -55,12 +84,13 @@ class TerminalUi(QtWidgets.QMainWindow): return cancelFormat = '{}' self.qProcess.kill() - - #To show progressBar completed + +# To show progressBar completed self.progressBar.setMaximum(100) self.progressBar.setProperty("value", 100) - self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!")) + self.simulationConsole.append( + cancelFormat.format("Simulation Cancelled!")) self.simulationConsole.verticalScrollBar().setValue( self.simulationConsole.verticalScrollBar().maximum() ) @@ -70,8 +100,8 @@ class TerminalUi(QtWidgets.QMainWindow): """ if (self.qProcess.state() == QtCore.QProcess.Running): return - - #To make the progressbar running + +# To make the progressbar running self.progressBar.setMaximum(0) self.progressBar.setProperty("value", -1) @@ -79,19 +109,34 @@ class TerminalUi(QtWidgets.QMainWindow): self.qProcess.start('ngspice', self.args) def changeColor(self): - """Toggles the :class:`Ui_Form` console between dark mode and light mode + """Toggles the :class:`Ui_Form` console between dark mode + and light mode """ if self.darkColor is True: - self.simulationConsole.setStyleSheet("QTextEdit {\n" - " background-color: white;\n" - " color: black;\n" - "}") - self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "dark_mode.png"))) + self.simulationConsole.setStyleSheet("QTextEdit {\n \ + background-color: white;\n \ + color: black;\n \ + }") + self.lightDarkModeButton.setIcon( + QtGui.QIcon( + os.path.join( + self.iconDir, + "dark_mode.png" + ) + ) + ) self.darkColor = False else: - self.simulationConsole.setStyleSheet("QTextEdit {\n" - " background-color: rgb(36, 31, 49);\n" - " color: white;\n" - "}") - self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) - self.darkColor = True \ No newline at end of file + self.simulationConsole.setStyleSheet("QTextEdit {\n \ + background-color: rgb(36, 31, 49);\n \ + color: white;\n \ + }") + self.lightDarkModeButton.setIcon( + QtGui.QIcon( + os.path.join( + self.iconDir, + "light_mode.png" + ) + ) + ) + self.darkColor = True -- cgit From 5cd19e9c29247276c5b48fed59f80631ce78ed86 Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 1 Jun 2023 12:52:31 +0530 Subject: Added docstrings to the TerminalUi class --- src/frontEnd/TerminalUi.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/frontEnd') diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index 21b5b557..24ee4596 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -3,7 +3,18 @@ import os class TerminalUi(QtWidgets.QMainWindow): + """This is a class that represents the GUI required to provide + details regarding the ngspice simulation. This GUI consists of + a progress bar, a console window which displays the log of the + simulation and button required for re-simulation and cancellation + of the simulation""" def __init__(self, qProcess, args): + """The constructor of the TerminalUi class + param: qProcess: a PyQt QProcess that runs ngspice + type: qProcess: :class:`QtCore.QProcess` + param: args: arguments to be passed on to the ngspice call + type: args: list + """ super(TerminalUi, self).__init__() # Other variables -- 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 +- src/frontEnd/DockArea.py | 171 ++++++++++++++++++++++++++------------------ 2 files changed, 104 insertions(+), 74 deletions(-) (limited to 'src/frontEnd') 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." ) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 493e7f49..5b67a394 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -101,25 +101,28 @@ class DockArea(QtWidgets.QMainWindow): # Adding to main Layout self.plottingWidget.setLayout(self.plottingLayout) - dock['Plotting-' + str(count) - ] = QtWidgets.QDockWidget('Plotting-' + str(count)) - dock['Plotting-' + str(count)].setWidget(self.plottingWidget) + dock[f'Plotting-{self.projName}-' + str(count) + ] = QtWidgets.QDockWidget(f'Plotting-{self.projName}-' + + str(count)) + dock[f'Plotting-{self.projName}-' + str(count)] \ + .setWidget(self.plottingWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['Plotting-' + str(count)]) - self.tabifyDockWidget(dock['Welcome'], dock['Plotting-' + str(count)]) + dock[f'Plotting-{self.projName}-' + str(count)]) + self.tabifyDockWidget(dock['Welcome'], + dock[f'Plotting-{self.projName}-' + str(count)]) - dock['Plotting-' + str(count)].setVisible(True) - dock['Plotting-' + str(count)].setFocus() - dock['Plotting-' + str(count)].raise_() + dock[f'Plotting-{self.projName}-' + str(count)].setVisible(True) + dock[f'Plotting-{self.projName}-' + str(count)].setFocus() + dock[f'Plotting-{self.projName}-' + str(count)].raise_() temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock['Plotting-' + str(count)] + dock[f'Plotting-{self.projName}-' + str(count)] ) count = count + 1 - def ngspiceEditor(self, projDir, simulationEssentials): + def ngspiceEditor(self, projDir): """ This function creates widget for Ngspice window.""" self.projDir = projDir self.projName = os.path.basename(self.projDir) @@ -140,27 +143,31 @@ class DockArea(QtWidgets.QMainWindow): # Adding to main Layout self.ngspiceWidget.setLayout(self.ngspiceLayout) - dock['NgSpice-' + str(count) - ] = QtWidgets.QDockWidget('NgSpice-' + str(count)) - dock['NgSpice-' + str(count)].setWidget(self.ngspiceWidget) + dock[f'Simulation-{self.projName}-' + str(count) + ] = QtWidgets.QDockWidget(f'Simulation-{self.projName}-' + + str(count)) + dock[f'Simulation-{self.projName}-' + str(count)] \ + .setWidget(self.ngspiceWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['NgSpice-' + str(count)]) - self.tabifyDockWidget(dock['Welcome'], dock['NgSpice-' + str(count)]) + dock[f'Simulation-{self.projName}-' + str(count)]) + self.tabifyDockWidget(dock['Welcome'], + dock[f'Simulation-{self.projName}-' + + str(count)]) # CSS - dock['NgSpice-' + str(count)].setStyleSheet(" \ + dock[f'Simulation-{self.projName}-' + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray; padding: 0px;\ width: 200px; height: 150px; } \ ") - dock['NgSpice-' + str(count)].setVisible(True) - dock['NgSpice-' + str(count)].setFocus() - dock['NgSpice-' + str(count)].raise_() + dock[f'Simulation-{self.projName}-' + str(count)].setVisible(True) + dock[f'Simulation-{self.projName}-' + str(count)].setFocus() + dock[f'Simulation-{self.projName}-' + str(count)].raise_() temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock['NgSpice-' + str(count)] + dock[f'Simulation-{self.projName}-' + str(count)] ) count = count + 1 @@ -168,6 +175,10 @@ class DockArea(QtWidgets.QMainWindow): """This function defines UI for model editor.""" print("in model editor") global count + + projDir = self.obj_appconfig.current_project["ProjectName"] + projName = os.path.basename(projDir) + self.modelwidget = QtWidgets.QWidget() self.modellayout = QtWidgets.QVBoxLayout() @@ -176,23 +187,25 @@ class DockArea(QtWidgets.QMainWindow): # Adding to main Layout self.modelwidget.setLayout(self.modellayout) - dock['Model Editor-' + - str(count)] = QtWidgets.QDockWidget('Model Editor-' + str(count)) - dock['Model Editor-' + str(count)].setWidget(self.modelwidget) + dock[f'Model Editor-{projName}-' + + str(count)] = QtWidgets.QDockWidget(f'Model Editor-{projName}-' + + str(count)) + dock[f'Model Editor-{projName}-' + str(count)] \ + .setWidget(self.modelwidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['Model Editor-' + str(count)]) + dock[f'Model Editor-{projName}-' + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock['Model Editor-' + str(count)]) + dock[f'Model Editor-{projName}-' + str(count)]) # CSS - dock['Model Editor-' + str(count)].setStyleSheet(" \ + dock[f'Model Editor-{projName}-' + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray; \ padding: 5px; width: 200px; height: 150px; } \ ") - dock['Model Editor-' + str(count)].setVisible(True) - dock['Model Editor-' + str(count)].setFocus() - dock['Model Editor-' + str(count)].raise_() + dock[f'Model Editor-{projName}-' + str(count)].setVisible(True) + dock[f'Model Editor-{projName}-' + str(count)].setFocus() + dock[f'Model Editor-{projName}-' + str(count)].raise_() count = count + 1 @@ -201,91 +214,106 @@ class DockArea(QtWidgets.QMainWindow): This function is creating Editor UI for Kicad to Ngspice conversion. """ global count + + projDir = self.obj_appconfig.current_project["ProjectName"] + projName = os.path.basename(projDir) + self.kicadToNgspiceWidget = QtWidgets.QWidget() self.kicadToNgspiceLayout = QtWidgets.QVBoxLayout() self.kicadToNgspiceLayout.addWidget(MainWindow(clarg1, clarg2)) self.kicadToNgspiceWidget.setLayout(self.kicadToNgspiceLayout) - dock['kicadToNgspice-' + str(count)] = \ - QtWidgets.QDockWidget('kicadToNgspice-' + str(count)) - dock['kicadToNgspice-' + + dock[f'Netlist-{projName}-' + str(count)] = \ + QtWidgets.QDockWidget(f'Netlist-{projName}-' + str(count)) + dock[f'Netlist-{projName}-' + str(count)].setWidget(self.kicadToNgspiceWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['kicadToNgspice-' + str(count)]) + dock[f'Netlist-{projName}-' + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock['kicadToNgspice-' + str(count)]) + dock[f'Netlist-{projName}-' + str(count)]) # CSS - dock['kicadToNgspice-' + str(count)].setStyleSheet(" \ + dock[f'Netlist-{projName}-' + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") - dock['kicadToNgspice-' + str(count)].setVisible(True) - dock['kicadToNgspice-' + str(count)].setFocus() - dock['kicadToNgspice-' + str(count)].raise_() - dock['kicadToNgspice-' + str(count)].activateWindow() + dock[f'Netlist-{projName}-' + str(count)].setVisible(True) + dock[f'Netlist-{projName}-' + str(count)].setFocus() + dock[f'Netlist-{projName}-' + str(count)].raise_() + dock[f'Netlist-{projName}-' + str(count)].activateWindow() temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock['kicadToNgspice-' + str(count)] + dock[f'Netlist-{projName}-' + str(count)] ) count = count + 1 def subcircuiteditor(self): """This function creates a widget for different subcircuit options.""" global count + + projDir = self.obj_appconfig.current_project["ProjectName"] + projName = os.path.basename(projDir) + self.subcktWidget = QtWidgets.QWidget() self.subcktLayout = QtWidgets.QVBoxLayout() self.subcktLayout.addWidget(Subcircuit(self)) self.subcktWidget.setLayout(self.subcktLayout) - dock['Subcircuit-' + - str(count)] = QtWidgets.QDockWidget('Subcircuit-' + str(count)) - dock['Subcircuit-' + str(count)].setWidget(self.subcktWidget) + dock[f'Subcircuit-{projName}-' + + str(count)] = QtWidgets.QDockWidget(f'Subcircuit-{projName}-' + + str(count)) + dock[f'Subcircuit-{projName}-' + str(count)] \ + .setWidget(self.subcktWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['Subcircuit-' + str(count)]) + dock[f'Subcircuit-{projName}-' + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock['Subcircuit-' + str(count)]) + dock[f'Subcircuit-{projName}-' + str(count)]) # CSS - dock['Subcircuit-' + str(count)].setStyleSheet(" \ + dock[f'Subcircuit-{projName}-' + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") - dock['Subcircuit-' + str(count)].setVisible(True) - dock['Subcircuit-' + str(count)].setFocus() - dock['Subcircuit-' + str(count)].raise_() + dock[f'Subcircuit-{projName}-' + str(count)].setVisible(True) + dock[f'Subcircuit-{projName}-' + str(count)].setFocus() + dock[f'Subcircuit-{projName}-' + str(count)].raise_() count = count + 1 def makerchip(self): """This function creates a widget for different subcircuit options.""" global count + + projDir = self.obj_appconfig.current_project["ProjectName"] + projName = os.path.basename(projDir) + self.makerWidget = QtWidgets.QWidget() self.makerLayout = QtWidgets.QVBoxLayout() self.makerLayout.addWidget(makerchip(self)) self.makerWidget.setLayout(self.makerLayout) - dock['Makerchip-' + - str(count)] = QtWidgets.QDockWidget('Makerchip-' + str(count)) - dock['Makerchip-' + str(count)].setWidget(self.makerWidget) + dock[f'Makerchip-{projName}-' + + str(count)] = QtWidgets.QDockWidget(f'Makerchip-{projName}-' + + str(count)) + dock[f'Makerchip-{projName}-' + str(count)].setWidget(self.makerWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['Makerchip-' + str(count)]) + dock[f'Makerchip-{projName}-' + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock['Makerchip-' + str(count)]) + dock[f'Makerchip-{projName}-' + str(count)]) # CSS - dock['Makerchip-' + str(count)].setStyleSheet(" \ + dock[f'Makerchip-{projName}-' + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") - dock['Makerchip-' + str(count)].setVisible(True) - dock['Makerchip-' + str(count)].setFocus() - dock['Makerchip-' + str(count)].raise_() + dock[f'Makerchip-{projName}-' + str(count)].setVisible(True) + dock[f'Makerchip-{projName}-' + str(count)].setFocus() + dock[f'Makerchip-{projName}-' + str(count)].raise_() count = count + 1 @@ -320,31 +348,38 @@ class DockArea(QtWidgets.QMainWindow): def modelicaEditor(self, projDir): """This function sets up the UI for ngspice to modelica conversion.""" global count + + projDir = self.obj_appconfig.current_project["ProjectName"] + projName = os.path.basename(projDir) + self.modelicaWidget = QtWidgets.QWidget() self.modelicaLayout = QtWidgets.QVBoxLayout() self.modelicaLayout.addWidget(OpenModelicaEditor(projDir)) self.modelicaWidget.setLayout(self.modelicaLayout) - dock['Modelica-' + str(count) - ] = QtWidgets.QDockWidget('Modelica-' + str(count)) - dock['Modelica-' + str(count)].setWidget(self.modelicaWidget) + dock[f'Modelica-{projName}-' + str(count) + ] = QtWidgets.QDockWidget(f'Modelica-{projName}-' + str(count)) + dock[f'Modelica-{projName}-' + str(count)] \ + .setWidget(self.modelicaWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock['Modelica-' + str(count)]) - self.tabifyDockWidget(dock['Welcome'], dock['Modelica-' + str(count)]) + dock[f'Modelica-{projName}-' + + str(count)]) + self.tabifyDockWidget(dock['Welcome'], dock[f'Modelica-{projName}-' + + str(count)]) - dock['Modelica-' + str(count)].setVisible(True) - dock['Modelica-' + str(count)].setFocus() - dock['Modelica-' + str(count)].raise_() + dock[f'Modelica-{projName}-' + str(count)].setVisible(True) + dock[f'Modelica-{projName}-' + str(count)].setFocus() + dock[f'Modelica-{projName}-' + str(count)].raise_() # CSS - dock['Modelica-' + str(count)].setStyleSheet(" \ + dock[f'Modelica-{projName}-' + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock['Modelica-' + str(count)] + dock[f'Modelica-{projName}-' + str(count)] ) count = count + 1 -- 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 +++++++++------------ src/frontEnd/DockArea.py | 148 +++++++++++++++++++++++--------------------- src/frontEnd/TerminalUi.py | 25 +------- 3 files changed, 105 insertions(+), 140 deletions(-) (limited to 'src/frontEnd') 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." ) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 5b67a394..e4ea42cd 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -35,8 +35,6 @@ class DockArea(QtWidgets.QMainWindow): QtWidgets.QMainWindow.__init__(self) self.obj_appconfig = Appconfig() - self.qprocess = QtCore.QProcess(self) - for dockName in dockList: dock[dockName] = QtWidgets.QDockWidget(dockName) self.welcomeWidget = QtWidgets.QWidget() @@ -91,6 +89,7 @@ class DockArea(QtWidgets.QMainWindow): """This function create widget for interactive PythonPlotting.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] self.projName = os.path.basename(self.projDir) + dockName = f'Plotting-{self.projName}-' # self.project = os.path.join(self.projDir, self.projName) global count @@ -101,31 +100,32 @@ class DockArea(QtWidgets.QMainWindow): # Adding to main Layout self.plottingWidget.setLayout(self.plottingLayout) - dock[f'Plotting-{self.projName}-' + str(count) - ] = QtWidgets.QDockWidget(f'Plotting-{self.projName}-' + dock[dockName + str(count) + ] = QtWidgets.QDockWidget(dockName + str(count)) - dock[f'Plotting-{self.projName}-' + str(count)] \ + dock[dockName + str(count)] \ .setWidget(self.plottingWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Plotting-{self.projName}-' + str(count)]) + dock[dockName + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock[f'Plotting-{self.projName}-' + str(count)]) + dock[dockName + str(count)]) - dock[f'Plotting-{self.projName}-' + str(count)].setVisible(True) - dock[f'Plotting-{self.projName}-' + str(count)].setFocus() - dock[f'Plotting-{self.projName}-' + str(count)].raise_() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock[f'Plotting-{self.projName}-' + str(count)] + dock[dockName + str(count)] ) count = count + 1 - def ngspiceEditor(self, projDir): + def ngspiceEditor(self, projDir, simulationEssentials): """ This function creates widget for Ngspice window.""" self.projDir = projDir self.projName = os.path.basename(self.projDir) + dockName = f'Simulation-{self.projName}-' self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") @@ -138,36 +138,36 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, self.qprocess) + NgspiceWidget(self.ngspiceNetlist, simulationEssentials) ) # Adding to main Layout self.ngspiceWidget.setLayout(self.ngspiceLayout) - dock[f'Simulation-{self.projName}-' + str(count) - ] = QtWidgets.QDockWidget(f'Simulation-{self.projName}-' + dock[dockName + str(count) + ] = QtWidgets.QDockWidget(dockName + str(count)) - dock[f'Simulation-{self.projName}-' + str(count)] \ + dock[dockName + str(count)] \ .setWidget(self.ngspiceWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Simulation-{self.projName}-' + str(count)]) + dock[dockName + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock[f'Simulation-{self.projName}-' + dock[dockName + str(count)]) # CSS - dock[f'Simulation-{self.projName}-' + str(count)].setStyleSheet(" \ + dock[dockName + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray; padding: 0px;\ width: 200px; height: 150px; } \ ") - dock[f'Simulation-{self.projName}-' + str(count)].setVisible(True) - dock[f'Simulation-{self.projName}-' + str(count)].setFocus() - dock[f'Simulation-{self.projName}-' + str(count)].raise_() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock[f'Simulation-{self.projName}-' + str(count)] + dock[dockName + str(count)] ) count = count + 1 @@ -178,6 +178,7 @@ class DockArea(QtWidgets.QMainWindow): projDir = self.obj_appconfig.current_project["ProjectName"] projName = os.path.basename(projDir) + dockName = f'Model Editor-{projName}-' self.modelwidget = QtWidgets.QWidget() @@ -187,25 +188,25 @@ class DockArea(QtWidgets.QMainWindow): # Adding to main Layout self.modelwidget.setLayout(self.modellayout) - dock[f'Model Editor-{projName}-' + - str(count)] = QtWidgets.QDockWidget(f'Model Editor-{projName}-' + dock[dockName + + str(count)] = QtWidgets.QDockWidget(dockName + str(count)) - dock[f'Model Editor-{projName}-' + str(count)] \ + dock[dockName + str(count)] \ .setWidget(self.modelwidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Model Editor-{projName}-' + str(count)]) + dock[dockName + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock[f'Model Editor-{projName}-' + str(count)]) + dock[dockName + str(count)]) # CSS - dock[f'Model Editor-{projName}-' + str(count)].setStyleSheet(" \ + dock[dockName + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray; \ padding: 5px; width: 200px; height: 150px; } \ ") - dock[f'Model Editor-{projName}-' + str(count)].setVisible(True) - dock[f'Model Editor-{projName}-' + str(count)].setFocus() - dock[f'Model Editor-{projName}-' + str(count)].raise_() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() count = count + 1 @@ -217,36 +218,37 @@ class DockArea(QtWidgets.QMainWindow): projDir = self.obj_appconfig.current_project["ProjectName"] projName = os.path.basename(projDir) + dockName = f'Netlist-{projName}-' self.kicadToNgspiceWidget = QtWidgets.QWidget() self.kicadToNgspiceLayout = QtWidgets.QVBoxLayout() self.kicadToNgspiceLayout.addWidget(MainWindow(clarg1, clarg2)) self.kicadToNgspiceWidget.setLayout(self.kicadToNgspiceLayout) - dock[f'Netlist-{projName}-' + str(count)] = \ - QtWidgets.QDockWidget(f'Netlist-{projName}-' + str(count)) - dock[f'Netlist-{projName}-' + + dock[dockName + str(count)] = \ + QtWidgets.QDockWidget(dockName + str(count)) + dock[dockName + str(count)].setWidget(self.kicadToNgspiceWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Netlist-{projName}-' + str(count)]) + dock[dockName + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock[f'Netlist-{projName}-' + str(count)]) + dock[dockName + str(count)]) # CSS - dock[f'Netlist-{projName}-' + str(count)].setStyleSheet(" \ + dock[dockName + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") - dock[f'Netlist-{projName}-' + str(count)].setVisible(True) - dock[f'Netlist-{projName}-' + str(count)].setFocus() - dock[f'Netlist-{projName}-' + str(count)].raise_() - dock[f'Netlist-{projName}-' + str(count)].activateWindow() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() + dock[dockName + str(count)].activateWindow() temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock[f'Netlist-{projName}-' + str(count)] + dock[dockName + str(count)] ) count = count + 1 @@ -256,31 +258,32 @@ class DockArea(QtWidgets.QMainWindow): projDir = self.obj_appconfig.current_project["ProjectName"] projName = os.path.basename(projDir) + dockName = f'Subcircuit-{projName}-' self.subcktWidget = QtWidgets.QWidget() self.subcktLayout = QtWidgets.QVBoxLayout() self.subcktLayout.addWidget(Subcircuit(self)) self.subcktWidget.setLayout(self.subcktLayout) - dock[f'Subcircuit-{projName}-' + - str(count)] = QtWidgets.QDockWidget(f'Subcircuit-{projName}-' + dock[dockName + + str(count)] = QtWidgets.QDockWidget(dockName + str(count)) - dock[f'Subcircuit-{projName}-' + str(count)] \ + dock[dockName + str(count)] \ .setWidget(self.subcktWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Subcircuit-{projName}-' + str(count)]) + dock[dockName + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock[f'Subcircuit-{projName}-' + str(count)]) + dock[dockName + str(count)]) # CSS - dock[f'Subcircuit-{projName}-' + str(count)].setStyleSheet(" \ + dock[dockName + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") - dock[f'Subcircuit-{projName}-' + str(count)].setVisible(True) - dock[f'Subcircuit-{projName}-' + str(count)].setFocus() - dock[f'Subcircuit-{projName}-' + str(count)].raise_() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() count = count + 1 @@ -290,30 +293,31 @@ class DockArea(QtWidgets.QMainWindow): projDir = self.obj_appconfig.current_project["ProjectName"] projName = os.path.basename(projDir) + dockName = f'Makerchip-{projName}-' self.makerWidget = QtWidgets.QWidget() self.makerLayout = QtWidgets.QVBoxLayout() self.makerLayout.addWidget(makerchip(self)) self.makerWidget.setLayout(self.makerLayout) - dock[f'Makerchip-{projName}-' + - str(count)] = QtWidgets.QDockWidget(f'Makerchip-{projName}-' + dock[dockName + + str(count)] = QtWidgets.QDockWidget(dockName + str(count)) - dock[f'Makerchip-{projName}-' + str(count)].setWidget(self.makerWidget) + dock[dockName + str(count)].setWidget(self.makerWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Makerchip-{projName}-' + str(count)]) + dock[dockName + str(count)]) self.tabifyDockWidget(dock['Welcome'], - dock[f'Makerchip-{projName}-' + str(count)]) + dock[dockName + str(count)]) # CSS - dock[f'Makerchip-{projName}-' + str(count)].setStyleSheet(" \ + dock[dockName + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") - dock[f'Makerchip-{projName}-' + str(count)].setVisible(True) - dock[f'Makerchip-{projName}-' + str(count)].setFocus() - dock[f'Makerchip-{projName}-' + str(count)].raise_() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() count = count + 1 @@ -349,37 +353,37 @@ class DockArea(QtWidgets.QMainWindow): """This function sets up the UI for ngspice to modelica conversion.""" global count - projDir = self.obj_appconfig.current_project["ProjectName"] projName = os.path.basename(projDir) + dockName = f'Modelica-{projName}-' self.modelicaWidget = QtWidgets.QWidget() self.modelicaLayout = QtWidgets.QVBoxLayout() self.modelicaLayout.addWidget(OpenModelicaEditor(projDir)) self.modelicaWidget.setLayout(self.modelicaLayout) - dock[f'Modelica-{projName}-' + str(count) - ] = QtWidgets.QDockWidget(f'Modelica-{projName}-' + str(count)) - dock[f'Modelica-{projName}-' + str(count)] \ + dock[dockName + str(count) + ] = QtWidgets.QDockWidget(dockName + str(count)) + dock[dockName + str(count)] \ .setWidget(self.modelicaWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, - dock[f'Modelica-{projName}-' + dock[dockName + str(count)]) - self.tabifyDockWidget(dock['Welcome'], dock[f'Modelica-{projName}-' + self.tabifyDockWidget(dock['Welcome'], dock[dockName + str(count)]) - dock[f'Modelica-{projName}-' + str(count)].setVisible(True) - dock[f'Modelica-{projName}-' + str(count)].setFocus() - dock[f'Modelica-{projName}-' + str(count)].raise_() + dock[dockName + str(count)].setVisible(True) + dock[dockName + str(count)].setFocus() + dock[dockName + str(count)].raise_() # CSS - dock[f'Modelica-{projName}-' + str(count)].setStyleSheet(" \ + dock[dockName + str(count)].setStyleSheet(" \ .QWidget { border-radius: 15px; border: 1px solid gray;\ padding: 5px; width: 200px; height: 150px; } \ ") temp = self.obj_appconfig.current_project['ProjectName'] if temp: self.obj_appconfig.dock_dict[temp].append( - dock[f'Modelica-{projName}-' + str(count)] + dock[dockName + str(count)] ) count = count + 1 diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index 24ee4596..902b6f59 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -65,35 +65,12 @@ class TerminalUi(QtWidgets.QMainWindow): # show app self.show() - def writeSimulationStatusToConsole(self, isSuccess): - """Writes simulation status to the console with appropriate style - to the :class:`Form_Ui` console. - - :param isSuccess: A boolean flag used to indicate whether the - simulation was a success or not - :type isSuccess: bool - """ - failedFormat = ' \ - {} \ - ' - successFormat = ' \ - {} \ - ' - - if self.qProcess.exitStatus() == QtCore.QProcess.NormalExit: - if isSuccess: - self.simulationConsole.append( - successFormat.format("Simulation Completed Successfully!")) - else: - self.simulationConsole.append( - failedFormat.format("Simulation Failed!")) - def cancelSimulation(self): """This function cancels the ongoing ngspice simulation. """ if (self.qProcess.state() == QtCore.QProcess.NotRunning): return - cancelFormat = '{}' + cancelFormat = '{}' self.qProcess.kill() # To show progressBar completed -- 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 +++++++++++++++++++++++++--------------- src/frontEnd/DockArea.py | 4 ++-- 2 files changed, 27 insertions(+), 17 deletions(-) (limited to 'src/frontEnd') 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." ) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index e4ea42cd..dbf43cf4 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -121,7 +121,7 @@ class DockArea(QtWidgets.QMainWindow): ) count = count + 1 - def ngspiceEditor(self, projDir, simulationEssentials): + def ngspiceEditor(self, projDir, startSimulation): """ This function creates widget for Ngspice window.""" self.projDir = projDir self.projName = os.path.basename(self.projDir) @@ -138,7 +138,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, simulationEssentials) + NgspiceWidget(self.ngspiceNetlist, startSimulation) ) # Adding to main Layout -- 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') 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 abc410aac656e840940b2227f4d94f0780a614be Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Wed, 7 Jun 2023 16:20:33 +0530 Subject: sync cancel and redo simulation features --- src/frontEnd/TerminalUi.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/frontEnd') diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index 902b6f59..2c5a7c02 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -17,39 +17,42 @@ class TerminalUi(QtWidgets.QMainWindow): """ super(TerminalUi, self).__init__() -# Other variables + # Other variables self.darkColor = True self.qProcess = qProcess self.args = args self.iconDir = "../../images" -# Load the ui file + # Load the ui file uic.loadUi("TerminalUi.ui", self) -# Define Our Widgets + # Define Our Widgets self.progressBar = self.findChild( QtWidgets.QProgressBar, "progressBar" - ) + ) self.simulationConsole = self.findChild( QtWidgets.QTextEdit, "simulationConsole" - ) + ) self.lightDarkModeButton = self.findChild( QtWidgets.QPushButton, "lightDarkModeButton" - ) + ) self.cancelSimulationButton = self.findChild( QtWidgets.QPushButton, "cancelSimulationButton" - ) + ) + self.cancelSimulationButton.setEnabled(True) + self.redoSimulationButton = self.findChild( QtWidgets.QPushButton, "redoSimulationButton" - ) + ) + self.redoSimulationButton.setEnabled(False) -# Add functionalities to Widgets + # Add functionalities to Widgets self.lightDarkModeButton.setIcon( QtGui.QIcon( os.path.join( @@ -62,7 +65,6 @@ class TerminalUi(QtWidgets.QMainWindow): self.cancelSimulationButton.clicked.connect(self.cancelSimulation) self.redoSimulationButton.clicked.connect(self.redoSimulation) -# show app self.show() def cancelSimulation(self): @@ -70,10 +72,11 @@ class TerminalUi(QtWidgets.QMainWindow): """ if (self.qProcess.state() == QtCore.QProcess.NotRunning): return + cancelFormat = '{}' self.qProcess.kill() -# To show progressBar completed + # To show progressBar completed self.progressBar.setMaximum(100) self.progressBar.setProperty("value", 100) @@ -83,19 +86,25 @@ class TerminalUi(QtWidgets.QMainWindow): self.simulationConsole.verticalScrollBar().maximum() ) + self.cancelSimulationButton.setEnabled(False) + self.redoSimulationButton.setEnabled(True) + def redoSimulation(self): """This function reruns the ngspice simulation """ if (self.qProcess.state() == QtCore.QProcess.Running): return -# To make the progressbar running + # To make the progressbar running self.progressBar.setMaximum(0) self.progressBar.setProperty("value", -1) self.simulationConsole.setText("") self.qProcess.start('ngspice', self.args) + self.cancelSimulationButton.setEnabled(True) + self.redoSimulationButton.setEnabled(False) + def changeColor(self): """Toggles the :class:`Ui_Form` console between dark mode and light mode -- 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 +++++++++++++++----------------------------- src/frontEnd/DockArea.py | 15 ++----- 2 files changed, 36 insertions(+), 79 deletions(-) (limited to 'src/frontEnd') 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"): diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index dbf43cf4..7037dcfd 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -121,28 +121,19 @@ class DockArea(QtWidgets.QMainWindow): ) count = count + 1 - def ngspiceEditor(self, projDir, startSimulation): + def ngspiceEditor(self, projName, netlist, simEndSignal): """ This function creates widget for Ngspice window.""" - self.projDir = projDir - self.projName = os.path.basename(self.projDir) - dockName = f'Simulation-{self.projName}-' - self.ngspiceNetlist = os.path.join( - self.projDir, self.projName + ".cir.out") - - # Edited by Sumanto Kar 25/08/2021 - if os.path.isfile(self.ngspiceNetlist) is False: - return False - global count self.ngspiceWidget = QtWidgets.QWidget() self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, startSimulation) + NgspiceWidget(netlist, simEndSignal) ) # Adding to main Layout self.ngspiceWidget.setLayout(self.ngspiceLayout) + dockName = f'Simulation-{projName}-' dock[dockName + str(count) ] = QtWidgets.QDockWidget(dockName + str(count)) -- cgit From 4eea06f6fcd654c7f0919f395ff42fabbafa0171 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Sun, 11 Jun 2023 16:22:29 +0530 Subject: fixed multiple signal issue with cancel sim. --- src/frontEnd/TerminalUi.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/frontEnd') diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index 2c5a7c02..4c53548f 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -65,34 +65,39 @@ class TerminalUi(QtWidgets.QMainWindow): self.cancelSimulationButton.clicked.connect(self.cancelSimulation) self.redoSimulationButton.clicked.connect(self.redoSimulation) + self.simulationCancelled = False self.show() def cancelSimulation(self): """This function cancels the ongoing ngspice simulation. """ + self.cancelSimulationButton.setEnabled(False) + self.redoSimulationButton.setEnabled(True) + if (self.qProcess.state() == QtCore.QProcess.NotRunning): return - cancelFormat = '{}' + self.simulationCancelled = True self.qProcess.kill() # To show progressBar completed self.progressBar.setMaximum(100) self.progressBar.setProperty("value", 100) + cancelFormat = '{}' self.simulationConsole.append( cancelFormat.format("Simulation Cancelled!")) self.simulationConsole.verticalScrollBar().setValue( self.simulationConsole.verticalScrollBar().maximum() ) - self.cancelSimulationButton.setEnabled(False) - self.redoSimulationButton.setEnabled(True) - def redoSimulation(self): """This function reruns the ngspice simulation """ - if (self.qProcess.state() == QtCore.QProcess.Running): + self.cancelSimulationButton.setEnabled(True) + self.redoSimulationButton.setEnabled(False) + + if (self.qProcess.state() != QtCore.QProcess.NotRunning): return # To make the progressbar running @@ -100,10 +105,9 @@ class TerminalUi(QtWidgets.QMainWindow): self.progressBar.setProperty("value", -1) self.simulationConsole.setText("") - self.qProcess.start('ngspice', self.args) + self.simulationCancelled = False - self.cancelSimulationButton.setEnabled(True) - self.redoSimulationButton.setEnabled(False) + self.qProcess.start('ngspice', self.args) def changeColor(self): """Toggles the :class:`Ui_Form` console between dark mode -- cgit