diff options
-rw-r--r-- | src/frontEnd/Application.py | 21 | ||||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 34 |
2 files changed, 33 insertions, 22 deletions
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): diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index aa175bf6..d0ec7337 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -7,21 +7,31 @@ import os # This Class creates NgSpice Window class NgspiceWidget(QtWidgets.QWidget): - def __init__(self, command, startSimulation): + def __init__(self, netlist, startSimulation): """ - Creates constructor for NgspiceWidget class. - - Checks whether OS is Linux or Windows and - creates Ngspice window accordingly. + - Creates NgspiceWindow and runs the process + - Calls the logs the ngspice process, returns + it's simulation status and calls the plotter + - Checks whether it is Linux and runs gaw + :param netlist: The file .cir.out file that + contains the instructions. + :type netlist: str + :param startSimulation: A function that disables + the toolbar buttons of connects the finishSimulation + function to finished.connect + :type startSimulation: function """ QtWidgets.QWidget.__init__(self) self.obj_appconfig = Appconfig() self.process = QtCore.QProcess(self) self.projDir = self.obj_appconfig.current_project["ProjectName"] - self.args = ['-b', '-r', command.replace(".cir.out", ".raw"), command] + self.args = ['-b', '-r', netlist.replace(".cir.out", ".raw"), + netlist] self.terminalUi = TerminalUi.TerminalUi(self.process, self.args) self.layout = QtWidgets.QVBoxLayout(self) self.layout.addWidget(self.terminalUi) - print("Argument to ngspice command : ", command) +# print("Argument to ngspice command : ", netlist) # This variable makes sure that finished.connect is called exactly once self.process.isFinishConnected = False @@ -46,11 +56,12 @@ class NgspiceWidget(QtWidgets.QWidget): if os.name != "nt": self.gawProcess = QtCore.QProcess(self) - self.gawCommand = "gaw " + command.replace(".cir.out", ".raw") + self.gawCommand = "gaw " + netlist.replace(".cir.out", ".raw") self.gawProcess.start('sh', ['-c', self.gawCommand]) print(self.gawCommand) - def finishSimulation(self, exitCode, exitStatus, checkChangeInPlotData): + def finishSimulation(self, exitCode, + exitStatus, checkNgspiceProcessFinished): """This function is intended to run when the ngspice simulation finishes. It singals to the function that generates the plots and also writes in the appropriate status of the @@ -62,22 +73,19 @@ class NgspiceWidget(QtWidgets.QWidget): :param exitStatus: The exit status signal of the qprocess that runs ngspice :type exitStatus: class:`QtCore.QProcess.ExitStatus` - :param checkChangeInPlotData: Takes the plotting function + :param checkNgspiceProcessFinished: Takes the plotting function as input and uses it to generate the plots. The reason why this is passed in such a way is to minimize the no. of functions passed through a chain of objects. - :type checkChangeInPlotData: function + :type checkNgspiceProcessFinished: function """ # To stop progressbar from running after simulation is completed self.terminalUi.progressBar.setMaximum(100) self.terminalUi.progressBar.setProperty("value", 100) - # st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - # if st.st_mtime >= self.currTime: if exitStatus == QtCore.QProcess.NormalExit: - checkChangeInPlotData(exitCode) -# self.terminalUi.writeSimulationStatusToConsole() + checkNgspiceProcessFinished(exitCode) failedFormat = '<span style="color:#ff3333; font-size:26px;"> \ {} \ |