summaryrefslogtreecommitdiff
path: root/src/frontEnd/Application.py
diff options
context:
space:
mode:
authorPranav P2023-04-07 20:20:33 +0530
committerPranav P2023-04-07 20:20:33 +0530
commitf87ebcf83c4a2a614e79b10039021cc5a0d56889 (patch)
tree799b929fa44ba972b738a6a758093472d7a7e3a5 /src/frontEnd/Application.py
parent2b3b684b9f6b039beace62272c3d46dc8ec22147 (diff)
downloadeSim-f87ebcf83c4a2a614e79b10039021cc5a0d56889.tar.gz
eSim-f87ebcf83c4a2a614e79b10039021cc5a0d56889.tar.bz2
eSim-f87ebcf83c4a2a614e79b10039021cc5a0d56889.zip
Added progress bar, QtTimer and removed the plots
Diffstat (limited to 'src/frontEnd/Application.py')
-rw-r--r--src/frontEnd/Application.py142
1 files changed, 77 insertions, 65 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index 7588b1a1..44237d56 100644
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -549,12 +549,69 @@ class Application(QtWidgets.QMainWindow):
psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
+
+ def check_change_in_plotfile(self, currTime):
+ print("The function has executed")
+ 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"))
+ print(st.st_mtime, currTime - 1)
+ if st.st_mtime >= currTime - 1:
+ self.is_file_changed = True
+ self.timer.stop()
+ self.plot_simulation()
+ return
+ except Exception:
+ pass
+
+ if self.is_file_changed is False:
+ self.timer.start()
+
+ # Fail Safe ===>
+ self.count += 1
+ if self.count >= 10:
+ print(
+ "Ngspice taking too long for simulation. "
+ "Check netlist file (*.cir.out) "
+ "to change simulation parameters."
+ )
+
+ self.msg = QtWidgets.QErrorMessage()
+ self.msg.setModal(True)
+ self.msg.setWindowTitle("Warning Message")
+ self.msg.showMessage(
+ 'Ngspice taking too long for simulation. '
+ 'Check netlist file (*.cir.out) '
+ 'to change simulation parameters.'
+ )
+ self.msg.exec_()
+
+ return
def open_ngspice(self):
"""This Function execute ngspice on current project."""
self.projDir = self.obj_appconfig.current_project["ProjectName"]
if self.projDir is not None:
+ currTime = time.time()
# Edited by Sumanto Kar 25/08/2021
if self.obj_Mainview.obj_dockarea.ngspiceEditor(
@@ -572,71 +629,11 @@ class Application(QtWidgets.QMainWindow):
self.msg.exec_()
return
- currTime = time.time()
- count = 0
- while True:
- try:
- # if os.name == 'nt':
- # proc = 'mintty'
- # else:
- # proc = 'xterm'
-
- # Edited by Sumanto Kar 25/08/2021
- if 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:
- break
- except Exception:
- pass
- time.sleep(1)
-
- # Fail Safe ===>
- count += 1
- if count >= 10:
- print(
- "Ngspice taking too long for simulation. "
- "Check netlist file (*.cir.out) "
- "to change simulation parameters."
- )
-
- self.msg = QtWidgets.QErrorMessage()
- self.msg.setModal(True)
- self.msg.setWindowTitle("Warning Message")
- self.msg.showMessage(
- 'Ngspice taking too long for simulation. '
- 'Check netlist file (*.cir.out) '
- 'to change simulation parameters.'
- )
- self.msg.exec_()
-
- return
-
- # Calling Python Plotting
- 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.count = 0
+ self.timer = QtCore.QTimer(self)
+ self.timer.setInterval(1000)
+ self.timer.timeout.connect(lambda: self.check_change_in_plotfile(currTime))
+ self.timer.start()
else:
self.msg = QtWidgets.QErrorMessage()
@@ -648,6 +645,21 @@ class Application(QtWidgets.QMainWindow):
)
self.msg.exec_()
+ def plot_simulation(self):
+ 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))
+
def open_subcircuit(self):
"""
This function opens 'subcircuit' option in left-tool-bar.