From 1129cf1035c1ac520d84c04b384f758e090be0c3 Mon Sep 17 00:00:00 2001
From: Pranav P
Date: Thu, 25 May 2023 14:44:03 +0530
Subject: Added sphinx docstring documentation to newly added functions and
removed some unnecessary variables
---
src/frontEnd/Application.py | 18 ++++++++----------
src/frontEnd/TerminalUi.py | 16 ++++++++++++----
src/ngspiceSimulation/NgspiceWidget.py | 14 ++++++++++++++
3 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index b45509a7..140fd5f5 100644
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -83,8 +83,6 @@ class Application(QtWidgets.QMainWindow):
self.systemTrayIcon.setIcon(QtGui.QIcon(init_path + 'images/logo.png'))
self.systemTrayIcon.setVisible(True)
- self.isFileChanged = False
-
def initToolBar(self):
"""
This function initializes Tool Bars.
@@ -553,6 +551,14 @@ class Application(QtWidgets.QMainWindow):
return False
def checkChangeInPlotFile(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.
+
+ :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`
+ """
self.enableButtons(True)
if exitStatus == QtCore.QProcess.NormalExit:
try:
@@ -576,9 +582,7 @@ class Application(QtWidgets.QMainWindow):
# return
st = os.stat(os.path.join(self.projDir, "plot_data_i.txt"))
- self.simulationCompleted = True
if st.st_mtime >= currTime:
- self.isFileChanged = True
try:
self.obj_Mainview.obj_dockarea.plottingEditor()
@@ -604,14 +608,9 @@ class Application(QtWidgets.QMainWindow):
self.closeproj.setEnabled(state)
self.wrkspce.setEnabled(state)
- def isSimulationSuccess(self):
- return self.isFileChanged
-
def open_ngspice(self):
"""This Function execute ngspice on current project."""
self.projDir = self.obj_appconfig.current_project["ProjectName"]
- self.isFileChanged = False
- self.simulationCompleted = False
simulationEssentials = {
"enableButtons": self.enableButtons,
@@ -619,7 +618,6 @@ class Application(QtWidgets.QMainWindow):
}
if self.projDir is not None:
- self.currTime = time.time()
# Edited by Sumanto Kar 25/08/2021
if self.obj_Mainview.obj_dockarea.ngspiceEditor(
diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py
index 4d6e6d23..ecf93ee2 100644
--- a/src/frontEnd/TerminalUi.py
+++ b/src/frontEnd/TerminalUi.py
@@ -95,6 +95,12 @@ class Ui_Form(object):
self.redo_simulation_button.clicked.connect(self.redoSimulation)
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 = '{}'
successFormat = '{}'
@@ -103,12 +109,10 @@ class Ui_Form(object):
self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!"))
else:
self.simulationConsole.append(failedFormat.format("Simulation Failed!"))
-
- def showProgressCompleted(self):
- self.progressBar.setMaximum(100)
- self.progressBar.setProperty("value", 100)
def cancelSimulation(self):
+ """This function cancels the ongoing ngspice simulation.
+ """
if (self.qProcess.state() == QtCore.QProcess.NotRunning):
return
cancelFormat = '{}'
@@ -124,6 +128,8 @@ class Ui_Form(object):
)
def redoSimulation(self):
+ """This function reruns the ngspice simulation
+ """
if (self.qProcess.state() == QtCore.QProcess.Running):
return
@@ -135,6 +141,8 @@ class Ui_Form(object):
self.qProcess.start('ngspice', self.args)
def changeColor(self):
+ """Toggles the :class:`Ui_Form` console between dark mode and light mode
+ """
if self.dark_color is True:
self.simulationConsole.setStyleSheet("QTextEdit {\n"
" background-color: white;\n"
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index 2c3b00f1..3e6882b5 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -67,6 +67,15 @@ class NgspiceWidget(QtWidgets.QWidget):
print(self.gawCommand)
def finishSimulation(self, exitCode, exitStatus):
+ """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 simulation (Whether it was a success or not).
+
+ :param exitCode: The exit code signal of the qprocess that runs ngspice
+ :type exitCode: int
+ :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
@@ -80,6 +89,9 @@ class NgspiceWidget(QtWidgets.QWidget):
self.currTime = time.time()
def writeSimulationStatus(self):
+ """This function writes status of the simulation (Success or Failure) to the
+ :class:`TerminalUi.Ui_Form` console.
+ """
if self.readyToPrintSimulationStatus is False:
return
@@ -96,6 +108,8 @@ class NgspiceWidget(QtWidgets.QWidget):
@QtCore.pyqtSlot()
def readyReadAll(self):
+ """Outputs the ngspice process standard output and standard error to :class:`TerminalUi.Ui_Form` console
+ """
self.terminalUi.simulationConsole.insertPlainText(
str(self.process.readAllStandardOutput().data(), encoding='utf-8')
)
--
cgit