summaryrefslogtreecommitdiff
path: root/src/ngspiceSimulation/NgspiceWidget.py
diff options
context:
space:
mode:
authorrahulp132023-06-11 16:22:29 +0530
committerrahulp132023-06-11 16:22:29 +0530
commit4eea06f6fcd654c7f0919f395ff42fabbafa0171 (patch)
treeafc4cf7c8d461576f03393445f3741eecfa650ee /src/ngspiceSimulation/NgspiceWidget.py
parentc99a4951df139de96e80a51805a3b4d677336653 (diff)
downloadeSim-4eea06f6fcd654c7f0919f395ff42fabbafa0171.tar.gz
eSim-4eea06f6fcd654c7f0919f395ff42fabbafa0171.tar.bz2
eSim-4eea06f6fcd654c7f0919f395ff42fabbafa0171.zip
fixed multiple signal issue with cancel sim.
Diffstat (limited to 'src/ngspiceSimulation/NgspiceWidget.py')
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index e940d995..94368cdd 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -38,10 +38,10 @@ class NgspiceWidget(QtWidgets.QWidget):
self.process.readyRead.connect(self.readyReadAll)
self.process.finished.connect(
lambda exitCode, exitStatus:
- self.finishSimulation(exitCode, exitStatus, simEndSignal)
+ self.finishSimulation(exitCode, exitStatus, simEndSignal, False)
)
self.process.errorOccurred.connect(
- lambda: self.finishSimulation(None, None, simEndSignal))
+ lambda: self.finishSimulation(None, None, simEndSignal, True))
self.process.start('ngspice', self.args)
self.obj_appconfig.process_obj.append(self.process)
@@ -77,7 +77,8 @@ class NgspiceWidget(QtWidgets.QWidget):
self.terminalUi.simulationConsole.insertPlainText(stderror)
- def finishSimulation(self, exitCode, exitStatus, simEndSignal):
+ def finishSimulation(self, exitCode, exitStatus,
+ simEndSignal, hasErrorOccurred):
"""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
@@ -94,6 +95,12 @@ class NgspiceWidget(QtWidgets.QWidget):
simulation is successful
:type simEndSignal: PyQt Signal
"""
+
+ # Canceling simulation triggers both finished and
+ # errorOccurred signals...need to skip finished signal in this case.
+ if not hasErrorOccurred and self.terminalUi.simulationCancelled:
+ return
+
# Stop progressbar from running after simulation is completed
self.terminalUi.progressBar.setMaximum(100)
self.terminalUi.progressBar.setProperty("value", 100)
@@ -109,11 +116,21 @@ class NgspiceWidget(QtWidgets.QWidget):
elif exitStatus is None:
exitStatus = self.process.exitStatus()
- # Redo-simulation does not set correct exit status and code.
- # So, need to check the error type:
- # => UnknownError along with NormalExit seems successful simulation
- if exitStatus == QtCore.QProcess.NormalExit and exitCode == 0 \
+ if self.terminalUi.simulationCancelled:
+ msg = QtWidgets.QMessageBox()
+ msg.setModal(True)
+ msg.setIcon(QtWidgets.QMessageBox.Warning)
+ msg.setWindowTitle("Warning Message")
+ msg.setText("Simulation was cancelled.")
+ msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
+ msg.exec()
+
+ elif exitStatus == QtCore.QProcess.NormalExit and exitCode == 0 \
and errorType == QtCore.QProcess.UnknownError:
+ # Redo-simulation does not set correct exit status and code.
+ # So, need to check the error type ==>
+ # UnknownError along with NormalExit seems successful simulation
+
successFormat = '<span style="color:#00ff00; font-size:26px;">\
{} \
</span>'
@@ -139,11 +156,11 @@ class NgspiceWidget(QtWidgets.QWidget):
else:
errMsg += ' could not complete. Try again later.'
- self.msg = QtWidgets.QErrorMessage()
- self.msg.setModal(True)
- self.msg.setWindowTitle("Error Message")
- self.msg.showMessage(errMsg)
- self.msg.exec_()
+ msg = QtWidgets.QErrorMessage()
+ msg.setModal(True)
+ msg.setWindowTitle("Error Message")
+ msg.showMessage(errMsg)
+ msg.exec()
self.terminalUi.simulationConsole.verticalScrollBar().setValue(
self.terminalUi.simulationConsole.verticalScrollBar().maximum()