summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
authorPranav P2023-06-01 17:38:18 +0530
committerPranav P2023-06-01 17:38:18 +0530
commitd8a2de2ef6126654184a1924cd21d242bea1be18 (patch)
treec2622c775565c892ad0cf42cb45f263bc63d9f6b /src/frontEnd
parentfb53f8b67cb15802c1d5ddbe59cf880c1d98954f (diff)
downloadeSim-d8a2de2ef6126654184a1924cd21d242bea1be18.tar.gz
eSim-d8a2de2ef6126654184a1924cd21d242bea1be18.tar.bz2
eSim-d8a2de2ef6126654184a1924cd21d242bea1be18.zip
PR fixes
Diffstat (limited to 'src/frontEnd')
-rw-r--r--src/frontEnd/Application.py72
-rwxr-xr-xsrc/frontEnd/DockArea.py148
-rw-r--r--src/frontEnd/TerminalUi.py25
3 files changed, 105 insertions, 140 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index 26a988ce..d3025fe4 100644
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -40,7 +40,6 @@ from frontEnd import Workspace
from frontEnd import DockArea
from PyQt5.Qt import QSize
import shutil
-import time
import sys
import psutil
@@ -551,47 +550,37 @@ class Application(QtWidgets.QMainWindow):
pass
return False
- def checkChangeInPlotData(self, currTime, exitStatus):
+# @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.
-
- :param currTime: The time stamp of the analysis file
- before simulation starts
- :type currTime: float
- :param exitStatus: The exit status of the ngspice QProcess
- :type exitStatus: class:`QtCore.QProcess.ExitStatus`
+ :param exitCode: The exit status of the ngspice QProcess
+ :type exitCode: int
"""
self.toggleToolbarButtons(True)
- if exitStatus == QtCore.QProcess.NormalExit:
+ if exitCode == 0:
try:
-
- st = os.stat(os.path.join(self.projDir, "plot_data_i.txt"))
- if st.st_mtime >= currTime:
-
- try:
- self.obj_Mainview.obj_dockarea.plottingEditor()
- except Exception as e:
- self.msg = QtWidgets.QErrorMessage()
- self.msg.setModal(True)
- self.msg.setWindowTitle("Error Message")
- self.msg.showMessage(
- 'Error while opening python plotting Editor.'
- ' Please look at console for more details.'
- )
- 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
+ self.obj_Mainview.obj_dockarea.plottingEditor()
+ except Exception as e:
+ self.msg = QtWidgets.QErrorMessage()
+ self.msg.setModal(True)
+ self.msg.setWindowTitle("Error Message")
+ self.msg.showMessage(
+ 'Error while opening python plotting Editor.'
+ ' Please look at console for more details.'
+ )
+ self.msg.exec_()
+ print("Exception Message:", str(e), traceback.format_exc())
+ self.obj_appconfig.print_error('Exception Message : '
+ + str(e))
def toggleToolbarButtons(self, state):
+ """This function is used to disable buttons related to simulation
+ during the ngspice simulation and to enable it back once the
+ simulation is completed
+ param: state: Decides whether to enable or disable the button
+ type: state: bool"""
self.ngspice.setEnabled(state)
self.conversion.setEnabled(state)
self.closeproj.setEnabled(state)
@@ -602,19 +591,14 @@ class Application(QtWidgets.QMainWindow):
self.projDir = self.obj_appconfig.current_project["ProjectName"]
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))
+ simulationEssentials = {
+ 'checkChangeInPlotData': self.checkChangeInPlotData,
+ 'toggleToolbarButtons': self.toggleToolbarButtons
+ }
# Edited by Sumanto Kar 25/08/2021
if self.obj_Mainview.obj_dockarea.ngspiceEditor(
- self.projDir) is False:
+ self.projDir, simulationEssentials) is False:
print(
"Netlist file (*.cir.out) not found."
)
diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py
index 5b67a394..e4ea42cd 100755
--- a/src/frontEnd/DockArea.py
+++ b/src/frontEnd/DockArea.py
@@ -35,8 +35,6 @@ 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()
@@ -91,6 +89,7 @@ class DockArea(QtWidgets.QMainWindow):
"""This function create widget for interactive PythonPlotting."""
self.projDir = self.obj_appconfig.current_project["ProjectName"]
self.projName = os.path.basename(self.projDir)
+ dockName = f'Plotting-{self.projName}-'
# self.project = os.path.join(self.projDir, self.projName)
global count
@@ -101,31 +100,32 @@ class DockArea(QtWidgets.QMainWindow):
# Adding to main Layout
self.plottingWidget.setLayout(self.plottingLayout)
- dock[f'Plotting-{self.projName}-' + str(count)
- ] = QtWidgets.QDockWidget(f'Plotting-{self.projName}-'
+ dock[dockName + str(count)
+ ] = QtWidgets.QDockWidget(dockName
+ str(count))
- dock[f'Plotting-{self.projName}-' + str(count)] \
+ dock[dockName + str(count)] \
.setWidget(self.plottingWidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Plotting-{self.projName}-' + str(count)])
+ dock[dockName + str(count)])
self.tabifyDockWidget(dock['Welcome'],
- dock[f'Plotting-{self.projName}-' + str(count)])
+ dock[dockName + str(count)])
- dock[f'Plotting-{self.projName}-' + str(count)].setVisible(True)
- dock[f'Plotting-{self.projName}-' + str(count)].setFocus()
- dock[f'Plotting-{self.projName}-' + str(count)].raise_()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
temp = self.obj_appconfig.current_project['ProjectName']
if temp:
self.obj_appconfig.dock_dict[temp].append(
- dock[f'Plotting-{self.projName}-' + str(count)]
+ dock[dockName + str(count)]
)
count = count + 1
- def ngspiceEditor(self, projDir):
+ def ngspiceEditor(self, projDir, simulationEssentials):
""" This function creates widget for Ngspice window."""
self.projDir = projDir
self.projName = os.path.basename(self.projDir)
+ dockName = f'Simulation-{self.projName}-'
self.ngspiceNetlist = os.path.join(
self.projDir, self.projName + ".cir.out")
@@ -138,36 +138,36 @@ class DockArea(QtWidgets.QMainWindow):
self.ngspiceLayout = QtWidgets.QVBoxLayout()
self.ngspiceLayout.addWidget(
- NgspiceWidget(self.ngspiceNetlist, self.qprocess)
+ NgspiceWidget(self.ngspiceNetlist, simulationEssentials)
)
# Adding to main Layout
self.ngspiceWidget.setLayout(self.ngspiceLayout)
- dock[f'Simulation-{self.projName}-' + str(count)
- ] = QtWidgets.QDockWidget(f'Simulation-{self.projName}-'
+ dock[dockName + str(count)
+ ] = QtWidgets.QDockWidget(dockName
+ str(count))
- dock[f'Simulation-{self.projName}-' + str(count)] \
+ dock[dockName + str(count)] \
.setWidget(self.ngspiceWidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Simulation-{self.projName}-' + str(count)])
+ dock[dockName + str(count)])
self.tabifyDockWidget(dock['Welcome'],
- dock[f'Simulation-{self.projName}-'
+ dock[dockName
+ str(count)])
# CSS
- dock[f'Simulation-{self.projName}-' + str(count)].setStyleSheet(" \
+ dock[dockName + str(count)].setStyleSheet(" \
.QWidget { border-radius: 15px; border: 1px solid gray; padding: 0px;\
width: 200px; height: 150px; } \
")
- dock[f'Simulation-{self.projName}-' + str(count)].setVisible(True)
- dock[f'Simulation-{self.projName}-' + str(count)].setFocus()
- dock[f'Simulation-{self.projName}-' + str(count)].raise_()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
temp = self.obj_appconfig.current_project['ProjectName']
if temp:
self.obj_appconfig.dock_dict[temp].append(
- dock[f'Simulation-{self.projName}-' + str(count)]
+ dock[dockName + str(count)]
)
count = count + 1
@@ -178,6 +178,7 @@ class DockArea(QtWidgets.QMainWindow):
projDir = self.obj_appconfig.current_project["ProjectName"]
projName = os.path.basename(projDir)
+ dockName = f'Model Editor-{projName}-'
self.modelwidget = QtWidgets.QWidget()
@@ -187,25 +188,25 @@ class DockArea(QtWidgets.QMainWindow):
# Adding to main Layout
self.modelwidget.setLayout(self.modellayout)
- dock[f'Model Editor-{projName}-' +
- str(count)] = QtWidgets.QDockWidget(f'Model Editor-{projName}-'
+ dock[dockName +
+ str(count)] = QtWidgets.QDockWidget(dockName
+ str(count))
- dock[f'Model Editor-{projName}-' + str(count)] \
+ dock[dockName + str(count)] \
.setWidget(self.modelwidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Model Editor-{projName}-' + str(count)])
+ dock[dockName + str(count)])
self.tabifyDockWidget(dock['Welcome'],
- dock[f'Model Editor-{projName}-' + str(count)])
+ dock[dockName + str(count)])
# CSS
- dock[f'Model Editor-{projName}-' + str(count)].setStyleSheet(" \
+ dock[dockName + str(count)].setStyleSheet(" \
.QWidget { border-radius: 15px; border: 1px solid gray; \
padding: 5px; width: 200px; height: 150px; } \
")
- dock[f'Model Editor-{projName}-' + str(count)].setVisible(True)
- dock[f'Model Editor-{projName}-' + str(count)].setFocus()
- dock[f'Model Editor-{projName}-' + str(count)].raise_()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
count = count + 1
@@ -217,36 +218,37 @@ class DockArea(QtWidgets.QMainWindow):
projDir = self.obj_appconfig.current_project["ProjectName"]
projName = os.path.basename(projDir)
+ dockName = f'Netlist-{projName}-'
self.kicadToNgspiceWidget = QtWidgets.QWidget()
self.kicadToNgspiceLayout = QtWidgets.QVBoxLayout()
self.kicadToNgspiceLayout.addWidget(MainWindow(clarg1, clarg2))
self.kicadToNgspiceWidget.setLayout(self.kicadToNgspiceLayout)
- dock[f'Netlist-{projName}-' + str(count)] = \
- QtWidgets.QDockWidget(f'Netlist-{projName}-' + str(count))
- dock[f'Netlist-{projName}-' +
+ dock[dockName + str(count)] = \
+ QtWidgets.QDockWidget(dockName + str(count))
+ dock[dockName +
str(count)].setWidget(self.kicadToNgspiceWidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Netlist-{projName}-' + str(count)])
+ dock[dockName + str(count)])
self.tabifyDockWidget(dock['Welcome'],
- dock[f'Netlist-{projName}-' + str(count)])
+ dock[dockName + str(count)])
# CSS
- dock[f'Netlist-{projName}-' + str(count)].setStyleSheet(" \
+ dock[dockName + str(count)].setStyleSheet(" \
.QWidget { border-radius: 15px; border: 1px solid gray;\
padding: 5px; width: 200px; height: 150px; } \
")
- dock[f'Netlist-{projName}-' + str(count)].setVisible(True)
- dock[f'Netlist-{projName}-' + str(count)].setFocus()
- dock[f'Netlist-{projName}-' + str(count)].raise_()
- dock[f'Netlist-{projName}-' + str(count)].activateWindow()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
+ dock[dockName + str(count)].activateWindow()
temp = self.obj_appconfig.current_project['ProjectName']
if temp:
self.obj_appconfig.dock_dict[temp].append(
- dock[f'Netlist-{projName}-' + str(count)]
+ dock[dockName + str(count)]
)
count = count + 1
@@ -256,31 +258,32 @@ class DockArea(QtWidgets.QMainWindow):
projDir = self.obj_appconfig.current_project["ProjectName"]
projName = os.path.basename(projDir)
+ dockName = f'Subcircuit-{projName}-'
self.subcktWidget = QtWidgets.QWidget()
self.subcktLayout = QtWidgets.QVBoxLayout()
self.subcktLayout.addWidget(Subcircuit(self))
self.subcktWidget.setLayout(self.subcktLayout)
- dock[f'Subcircuit-{projName}-' +
- str(count)] = QtWidgets.QDockWidget(f'Subcircuit-{projName}-'
+ dock[dockName +
+ str(count)] = QtWidgets.QDockWidget(dockName
+ str(count))
- dock[f'Subcircuit-{projName}-' + str(count)] \
+ dock[dockName + str(count)] \
.setWidget(self.subcktWidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Subcircuit-{projName}-' + str(count)])
+ dock[dockName + str(count)])
self.tabifyDockWidget(dock['Welcome'],
- dock[f'Subcircuit-{projName}-' + str(count)])
+ dock[dockName + str(count)])
# CSS
- dock[f'Subcircuit-{projName}-' + str(count)].setStyleSheet(" \
+ dock[dockName + str(count)].setStyleSheet(" \
.QWidget { border-radius: 15px; border: 1px solid gray;\
padding: 5px; width: 200px; height: 150px; } \
")
- dock[f'Subcircuit-{projName}-' + str(count)].setVisible(True)
- dock[f'Subcircuit-{projName}-' + str(count)].setFocus()
- dock[f'Subcircuit-{projName}-' + str(count)].raise_()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
count = count + 1
@@ -290,30 +293,31 @@ class DockArea(QtWidgets.QMainWindow):
projDir = self.obj_appconfig.current_project["ProjectName"]
projName = os.path.basename(projDir)
+ dockName = f'Makerchip-{projName}-'
self.makerWidget = QtWidgets.QWidget()
self.makerLayout = QtWidgets.QVBoxLayout()
self.makerLayout.addWidget(makerchip(self))
self.makerWidget.setLayout(self.makerLayout)
- dock[f'Makerchip-{projName}-' +
- str(count)] = QtWidgets.QDockWidget(f'Makerchip-{projName}-'
+ dock[dockName +
+ str(count)] = QtWidgets.QDockWidget(dockName
+ str(count))
- dock[f'Makerchip-{projName}-' + str(count)].setWidget(self.makerWidget)
+ dock[dockName + str(count)].setWidget(self.makerWidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Makerchip-{projName}-' + str(count)])
+ dock[dockName + str(count)])
self.tabifyDockWidget(dock['Welcome'],
- dock[f'Makerchip-{projName}-' + str(count)])
+ dock[dockName + str(count)])
# CSS
- dock[f'Makerchip-{projName}-' + str(count)].setStyleSheet(" \
+ dock[dockName + str(count)].setStyleSheet(" \
.QWidget { border-radius: 15px; border: 1px solid gray;\
padding: 5px; width: 200px; height: 150px; } \
")
- dock[f'Makerchip-{projName}-' + str(count)].setVisible(True)
- dock[f'Makerchip-{projName}-' + str(count)].setFocus()
- dock[f'Makerchip-{projName}-' + str(count)].raise_()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
count = count + 1
@@ -349,37 +353,37 @@ class DockArea(QtWidgets.QMainWindow):
"""This function sets up the UI for ngspice to modelica conversion."""
global count
- projDir = self.obj_appconfig.current_project["ProjectName"]
projName = os.path.basename(projDir)
+ dockName = f'Modelica-{projName}-'
self.modelicaWidget = QtWidgets.QWidget()
self.modelicaLayout = QtWidgets.QVBoxLayout()
self.modelicaLayout.addWidget(OpenModelicaEditor(projDir))
self.modelicaWidget.setLayout(self.modelicaLayout)
- dock[f'Modelica-{projName}-' + str(count)
- ] = QtWidgets.QDockWidget(f'Modelica-{projName}-' + str(count))
- dock[f'Modelica-{projName}-' + str(count)] \
+ dock[dockName + str(count)
+ ] = QtWidgets.QDockWidget(dockName + str(count))
+ dock[dockName + str(count)] \
.setWidget(self.modelicaWidget)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
- dock[f'Modelica-{projName}-'
+ dock[dockName
+ str(count)])
- self.tabifyDockWidget(dock['Welcome'], dock[f'Modelica-{projName}-'
+ self.tabifyDockWidget(dock['Welcome'], dock[dockName
+ str(count)])
- dock[f'Modelica-{projName}-' + str(count)].setVisible(True)
- dock[f'Modelica-{projName}-' + str(count)].setFocus()
- dock[f'Modelica-{projName}-' + str(count)].raise_()
+ dock[dockName + str(count)].setVisible(True)
+ dock[dockName + str(count)].setFocus()
+ dock[dockName + str(count)].raise_()
# CSS
- dock[f'Modelica-{projName}-' + str(count)].setStyleSheet(" \
+ dock[dockName + str(count)].setStyleSheet(" \
.QWidget { border-radius: 15px; border: 1px solid gray;\
padding: 5px; width: 200px; height: 150px; } \
")
temp = self.obj_appconfig.current_project['ProjectName']
if temp:
self.obj_appconfig.dock_dict[temp].append(
- dock[f'Modelica-{projName}-' + str(count)]
+ dock[dockName + str(count)]
)
count = count + 1
diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py
index 24ee4596..902b6f59 100644
--- a/src/frontEnd/TerminalUi.py
+++ b/src/frontEnd/TerminalUi.py
@@ -65,35 +65,12 @@ class TerminalUi(QtWidgets.QMainWindow):
# show app
self.show()
- def writeSimulationStatusToConsole(self, isSuccess):
- """Writes simulation status to the console with appropriate style
- to the :class:`Form_Ui` console.
-
- :param isSuccess: A boolean flag used to indicate whether the
- simulation was a success or not
- :type isSuccess: bool
- """
- 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:
- self.simulationConsole.append(
- successFormat.format("Simulation Completed Successfully!"))
- else:
- self.simulationConsole.append(
- failedFormat.format("Simulation Failed!"))
-
def cancelSimulation(self):
"""This function cancels the ongoing ngspice simulation.
"""
if (self.qProcess.state() == QtCore.QProcess.NotRunning):
return
- cancelFormat = '<span style="color:#3385ff; font-size:18px;">{}</span>'
+ cancelFormat = '<span style="color:#FF8624; font-size:26px;">{}</span>'
self.qProcess.kill()
# To show progressBar completed