summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav P2023-06-01 11:43:06 +0530
committerPranav P2023-06-01 11:56:20 +0530
commitb0dc41fb3e6ae9fb0f29b4e44524250807d41e49 (patch)
tree30aac804ac26c4e224e48211274da7acd536329e
parent1e14fffaa14a1de35328ec88efd5f2a7a077fec3 (diff)
downloadeSim-b0dc41fb3e6ae9fb0f29b4e44524250807d41e49.tar.gz
eSim-b0dc41fb3e6ae9fb0f29b4e44524250807d41e49.tar.bz2
eSim-b0dc41fb3e6ae9fb0f29b4e44524250807d41e49.zip
Fixes for PR
-rw-r--r--src/frontEnd/Application.py43
-rwxr-xr-xsrc/frontEnd/DockArea.py4
-rw-r--r--src/frontEnd/TerminalUi.py6
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py28
4 files changed, 29 insertions, 52 deletions
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 = '<span style="color:#ff3333;">{}</span>'
- successFormat = '<span style="color:#00ff00;">{}</span>'
+ failedFormat = '<span style="color:#ff3333; font-size:18px;">{}</span>'
+ successFormat = '<span style="color:#00ff00; font-size:18px;">{}</span>'
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 = '<span style="color:#3385ff;">{}</span>'
+ cancelFormat = '<span style="color:#3385ff; font-size:18px;">{}</span>'
self.qProcess.kill()
#To show progressBar completed
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index 9b5667ff..138642ca 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -9,7 +9,7 @@ import time
# This Class creates NgSpice Window
class NgspiceWidget(QtWidgets.QWidget):
- def __init__(self, command, simulationEssentials):
+ def __init__(self, command, qprocess):
"""
- Creates constructor for NgspiceWidget class.
- Checks whether OS is Linux or Windows and
@@ -17,14 +17,10 @@ class NgspiceWidget(QtWidgets.QWidget):
"""
QtWidgets.QWidget.__init__(self)
self.obj_appconfig = Appconfig()
- self.process = QtCore.QProcess(self)
- #self.terminal = QtWidgets.QWidget(self)
+ self.process = qprocess
self.projDir = self.obj_appconfig.current_project["ProjectName"]
- self.checkChangeInPlotFile = simulationEssentials['checkChangeInPlotFile']
- self.enableButtons = simulationEssentials['enableButtons']
self.args = ['-b', '-r', command.replace(".cir.out", ".raw"), command]
self.terminalUi = TerminalUi.TerminalUi(self.process, self.args)
- #self.terminalUi.setupUi(self.terminal)
self.layout = QtWidgets.QVBoxLayout(self)
self.layout.addWidget(self.terminalUi)
@@ -48,10 +44,10 @@ class NgspiceWidget(QtWidgets.QWidget):
# else: # For Linux OS
# Creating argument for process
+
self.currTime = time.time()
self.process.setWorkingDirectory(self.projDir)
self.process.start('ngspice', self.args)
- self.process.started.connect(lambda: self.enableButtons(state=False))
self.process.readyReadStandardOutput.connect(lambda: self.readyReadAll())
self.process.finished.connect(self.finishSimulation)
self.obj_appconfig.process_obj.append(self.process)
@@ -76,25 +72,11 @@ class NgspiceWidget(QtWidgets.QWidget):
:param exitStatus: The exit status signal of the qprocess that runs ngspice
:type exitStatus: class:`QtCore.QProcess.ExitStatus`
"""
- self.checkChangeInPlotFile(self.currTime, exitStatus)
- self.readyToPrintSimulationStatus = True
#To stop progressbar from running after simulation is completed
self.terminalUi.progressBar.setMaximum(100)
self.terminalUi.progressBar.setProperty("value", 100)
- self.writeSimulationStatus()
-
- #To set the current time stamp of the generated file so as for re-simulation
- self.currTime = time.time()
-
- def writeSimulationStatus(self):
- """This function writes status of the simulation (Success or Failure) to the
- :class:`TerminalUi.TerminalUi` console.
- """
- if self.readyToPrintSimulationStatus is False:
- return
-
st = os.stat(os.path.join(self.projDir, "plot_data_i.txt"))
if st.st_mtime >= self.currTime:
self.terminalUi.writeSimulationStatusToConsole(isSuccess=True)
@@ -104,7 +86,9 @@ class NgspiceWidget(QtWidgets.QWidget):
self.terminalUi.simulationConsole.verticalScrollBar().setValue(
self.terminalUi.simulationConsole.verticalScrollBar().maximum()
)
- self.readyToPrintSimulationStatus = False
+
+ #To set the current time stamp of the generated file so as for re-simulation
+ self.currTime = time.time()
@QtCore.pyqtSlot()
def readyReadAll(self):