summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSumanto Kar2025-05-05 19:46:51 +0530
committerGitHub2025-05-05 19:46:51 +0530
commit2e6fcc49286ae4998ec57eef3359312d5978c105 (patch)
tree88dffebb4ed2329355d547c7fd7372cb391acea7
parent19f442b73bcdc5fc4818dc2e47b7c0d8e8194fb0 (diff)
parente0a9a28c1413d5e9068b578134bdd0cd535209b3 (diff)
downloadeSim-master.tar.gz
eSim-master.tar.bz2
eSim-master.zip
Merge pull request #322 from 092vk/doubleSimulationHEADmaster
Enabled Dual Plotting for Simulation
-rw-r--r--src/frontEnd/Application.py28
-rwxr-xr-xsrc/frontEnd/DockArea.py4
-rw-r--r--src/frontEnd/TerminalUi.py18
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py61
4 files changed, 106 insertions, 5 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index 5d76bf9d..ea286651 100644
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -58,6 +58,9 @@ class Application(QtWidgets.QMainWindow):
# Set slot for simulation end signal to plot simulation data
self.simulationEndSignal.connect(self.plotSimulationData)
+ #the plotFlag
+ self.plotFlag = False
+
# Creating require Object
self.obj_workspace = Workspace.Workspace()
self.obj_Mainview = MainView()
@@ -188,7 +191,7 @@ class Application(QtWidgets.QMainWindow):
QtGui.QIcon(init_path + 'images/ngspice.png'),
'<b>Simulate</b>', self
)
- self.ngspice.triggered.connect(self.open_ngspice)
+ self.ngspice.triggered.connect(self.plotFlagPopBox)
self.model = QtWidgets.QAction(
QtGui.QIcon(init_path + 'images/model.png'),
@@ -247,6 +250,27 @@ class Application(QtWidgets.QMainWindow):
self.lefttoolbar.setOrientation(QtCore.Qt.Vertical)
self.lefttoolbar.setIconSize(QSize(40, 40))
+ def plotFlagPopBox(self):
+ """This function displays a pop-up box with message- Do you want Ngspice plots? and oprions Yes and NO.
+
+ If the user clicks on Yes, both the NgSpice and python plots are displayed and if No is clicked then only the python plots."""
+
+ msg_box = QtWidgets.QMessageBox(self)
+ msg_box.setWindowTitle("Ngspice Plots")
+ msg_box.setText("Do you want Ngspice plots?")
+
+ yes_button = msg_box.addButton("Yes", QtWidgets.QMessageBox.YesRole)
+ no_button = msg_box.addButton("No", QtWidgets.QMessageBox.NoRole)
+
+ msg_box.exec_()
+
+ if msg_box.clickedButton() == yes_button:
+ self.plotFlag = True
+ else:
+ self.plotFlag = False
+
+ self.open_ngspice()
+
def closeEvent(self, event):
'''
This function closes the ongoing program (process).
@@ -438,7 +462,7 @@ class Application(QtWidgets.QMainWindow):
return
self.obj_Mainview.obj_dockarea.ngspiceEditor(
- projName, ngspiceNetlist, self.simulationEndSignal)
+ projName, ngspiceNetlist, self.simulationEndSignal, self.plotFlag)
self.ngspice.setEnabled(False)
self.conversion.setEnabled(False)
diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py
index 01e0d715..d73e556b 100755
--- a/src/frontEnd/DockArea.py
+++ b/src/frontEnd/DockArea.py
@@ -127,14 +127,14 @@ class DockArea(QtWidgets.QMainWindow):
)
count = count + 1
- def ngspiceEditor(self, projName, netlist, simEndSignal):
+ def ngspiceEditor(self, projName, netlist, simEndSignal, plotFlag):
""" This function creates widget for Ngspice window."""
global count
self.ngspiceWidget = QtWidgets.QWidget()
self.ngspiceLayout = QtWidgets.QVBoxLayout()
self.ngspiceLayout.addWidget(
- NgspiceWidget(netlist, simEndSignal)
+ NgspiceWidget(netlist, simEndSignal, plotFlag)
)
# Adding to main Layout
diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py
index 4c53548f..f838ae07 100644
--- a/src/frontEnd/TerminalUi.py
+++ b/src/frontEnd/TerminalUi.py
@@ -94,6 +94,7 @@ class TerminalUi(QtWidgets.QMainWindow):
def redoSimulation(self):
"""This function reruns the ngspice simulation
"""
+ self.Flag = "Flase"
self.cancelSimulationButton.setEnabled(True)
self.redoSimulationButton.setEnabled(False)
@@ -107,6 +108,23 @@ class TerminalUi(QtWidgets.QMainWindow):
self.simulationConsole.setText("")
self.simulationCancelled = False
+ msg_box = QtWidgets.QMessageBox(self)
+ msg_box.setWindowTitle("Ngspice Plots")
+ msg_box.setText("Do you want Ngspice plots?")
+
+ yes_button = msg_box.addButton("Yes", QtWidgets.QMessageBox.YesRole)
+ no_button = msg_box.addButton("No", QtWidgets.QMessageBox.NoRole)
+
+ msg_box.exec_()
+
+ if msg_box.clickedButton() == yes_button:
+ self.Flag = True
+ else:
+ self.Flag = False
+
+ # Emit a custom signal with name plotFlag2 depending upon the Flag
+ self.qProcess.setProperty("plotFlag2", self.Flag)
+
self.qProcess.start('ngspice', self.args)
def changeColor(self):
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index 94368cdd..dd2607cd 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -7,7 +7,7 @@ from frontEnd import TerminalUi
# This Class creates NgSpice Window
class NgspiceWidget(QtWidgets.QWidget):
- def __init__(self, netlist, simEndSignal):
+ def __init__(self, netlist, simEndSignal, plotFlag):
"""
- Creates constructor for NgspiceWidget class.
- Creates NgspiceWindow and runs the process
@@ -27,12 +27,18 @@ class NgspiceWidget(QtWidgets.QWidget):
self.projDir = self.obj_appconfig.current_project["ProjectName"]
self.args = ['-b', '-r', netlist.replace(".cir.out", ".raw"), netlist]
print("Argument to ngspice: ", self.args)
+ self.projPath = self.projDir
self.process = QtCore.QProcess(self)
self.terminalUi = TerminalUi.TerminalUi(self.process, self.args)
self.layout = QtWidgets.QVBoxLayout(self)
self.layout.addWidget(self.terminalUi)
+ # Receiving the plotFlag
+ self.plotFlag = plotFlag
+ print("Value of plotFlag: ", self.plotFlag)
+ self.command = netlist
+
self.process.setWorkingDirectory(self.projDir)
self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
self.process.readyRead.connect(self.readyReadAll)
@@ -166,4 +172,57 @@ class NgspiceWidget(QtWidgets.QWidget):
self.terminalUi.simulationConsole.verticalScrollBar().maximum()
)
+ """ Get the plotFlag from process if it exists, otherwise use current plotFlag, plotFlag2 is for pop which appears when resimulate is clicked on ngSpice window """
+ newPlotFlag = self.process.property("plotFlag")
+ if newPlotFlag is not None:
+ self.plotFlag = newPlotFlag
+
+ newPlotFlag2 = self.process.property("plotFlag2")
+ if newPlotFlag2 is not None:
+ self.plotFlag = newPlotFlag2
+
+ if self.plotFlag:
+ self.plotFlagFunc(self.projPath, self.command)
+
simEndSignal.emit(exitStatus, exitCode)
+
+ def plotFlagFunc(self,projPath,command):
+ if self.plotFlag == True:
+ print("reached here too")
+ if os.name == 'nt':
+ parser_nghdl = ConfigParser()
+ parser_nghdl.read(
+ os.path.join('library', 'config', '.nghdl', 'config.ini')
+ )
+
+ msys_home = parser_nghdl.get('COMPILER', 'MSYS_HOME')
+
+ tempdir = os.getcwd()
+ projPath = self.obj_appconfig.current_project["ProjectName"]
+ os.chdir(projPath)
+ self.command = 'cmd /c ' + '"start /min ' + \
+ msys_home + "/usr/bin/mintty.exe ngspice -p " + command + '"'
+
+ self.process.start(self.command)
+ os.chdir(tempdir)
+ else:
+ print("reached .. 4")
+ self.commandi = "cd " + projPath + \
+ ";ngspice -r " + command.replace(".cir.out", ".raw") + \
+ " " + command
+ self.xtermArgs = ['-hold', '-e', self.commandi]
+ print("xTerm")
+
+ self.xtermProcess = QtCore.QProcess(self)
+ self.xtermProcess.start('xterm', self.xtermArgs)
+
+ self.obj_appconfig.process_obj.append(self.xtermProcess)
+ print(self.obj_appconfig.proc_dict)
+ (
+ self.obj_appconfig.proc_dict
+ [self.obj_appconfig.current_project['ProjectName']].append(
+ self.xtermProcess.pid())
+ )
+
+ self.gawProcess.start('sh', ['-c', self.gawCommand])
+ print("last:", self.gawCommand)