diff options
-rw-r--r-- | src/frontEnd/Application.py | 19 | ||||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 15 | ||||
-rw-r--r-- | src/progressBar/progressBar.py | 12 | ||||
-rw-r--r-- | src/progressBar/progressBar.ui | 2 |
4 files changed, 41 insertions, 7 deletions
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: diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index 9909dd07..f7c88ba9 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -3,6 +3,7 @@ from configuration.Appconfig import Appconfig from configparser import ConfigParser from progressBar import progressBar import os +import time # This Class creates NgSpice Window @@ -19,6 +20,7 @@ class NgspiceWidget(QtWidgets.QWidget): self.process = QtCore.QProcess(self) self.terminal = QtWidgets.QWidget(self) self.simulationEssentials = simulationEssentials + self.qTimer = simulationEssentials['timer'] self.progressBarUi = progressBar.Ui_Form(self.process, self.simulationEssentials) self.progressBarUi.setupUi(self.terminal) self.layout = QtWidgets.QVBoxLayout(self) @@ -71,6 +73,19 @@ class NgspiceWidget(QtWidgets.QWidget): self.enableButtons(True) self.progressBarUi.showProgressCompleted() + self.qTimer.timeout.connect(self.writeSimulationStatus) + + def writeSimulationStatus(self): + self.isSimulationSuccess = self.simulationEssentials['isSimulationSuccess'] + + if self.isSimulationSuccess(): + self.progressBarUi.writeSimulationStatusToConsole(isSuccess=True) + else: + self.progressBarUi.writeSimulationStatusToConsole(isSuccess=False) + + scrollLength = self.progressBarUi.simulationConsole.verticalScrollBar().maximum() + self.progressBarUi.simulationConsole.verticalScrollBar().setValue(scrollLength) + @QtCore.pyqtSlot() def readyReadAll(self): self.progressBarUi.writeIntoConsole( diff --git a/src/progressBar/progressBar.py b/src/progressBar/progressBar.py index 4bc1e982..f0aa964f 100644 --- a/src/progressBar/progressBar.py +++ b/src/progressBar/progressBar.py @@ -16,12 +16,13 @@ class Ui_Form(object): self.qProcess = qProcess self.qTimer = simulationEssentials['timer'] self.enableButtons = simulationEssentials['enableButtons'] + self.isSimulationSuccess = simulationEssentials['isSimulationSuccess'] # 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, 481)) + 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) @@ -99,6 +100,15 @@ class Ui_Form(object): def writeIntoConsole(self, consoleLog): self.simulationConsole.insertPlainText(consoleLog) + + def writeSimulationStatusToConsole(self, isSuccess): + failedFormat = '<span style="color:red;">{}</span>' + successFormat = '<span style="color:green;">{}</span>' + + if isSuccess: + self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) + else: + self.simulationConsole.append(failedFormat.format("Simulation Failed!")) def showProgressCompleted(self): self.progressBar.setMaximum(100) diff --git a/src/progressBar/progressBar.ui b/src/progressBar/progressBar.ui index 142decea..c85c0788 100644 --- a/src/progressBar/progressBar.ui +++ b/src/progressBar/progressBar.ui @@ -19,7 +19,7 @@ <x>10</x> <y>10</y> <width>1131</width> - <height>481</height> + <height>471</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> |