summaryrefslogtreecommitdiff
path: root/src/ngspiceSimulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/ngspiceSimulation')
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py63
1 files changed, 61 insertions, 2 deletions
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index 94368cdd..6d8a9d74 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -2,12 +2,12 @@ import os
from PyQt5 import QtWidgets, QtCore
from configuration.Appconfig import Appconfig
from frontEnd import TerminalUi
-
+from configparser import ConfigParser
# 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:
+ if os.name == 'nt':
+ parser_nghdl = ConfigParser()
+ config_path = os.path.join('library', 'config', '.nghdl', 'config.ini')
+ parser_nghdl.read(config_path)
+ 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 + '"'
+ )
+
+ # Create a new QProcess for mintty
+ self.minttyProcess = QtCore.QProcess(self)
+ self.minttyProcess.start(self.command)
+
+ os.chdir(tempdir)
+ else:
+ self.commandi = "cd " + projPath + \
+ ";ngspice -r " + command.replace(".cir.out", ".raw") + \
+ " " + command
+ self.xtermArgs = ['-hold', '-e', self.commandi]
+
+ 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)