diff options
Diffstat (limited to 'src/frontEnd')
-rw-r--r-- | src/frontEnd/Application.py | 116 | ||||
-rwxr-xr-x[-rw-r--r--] | src/frontEnd/DockArea.py | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | src/frontEnd/ProjectExplorer.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | src/frontEnd/Workspace.py | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | src/frontEnd/__init__.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | src/frontEnd/pathmagic.py | 0 |
6 files changed, 138 insertions, 21 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 94bce4ae..d3ef020f 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -11,14 +11,16 @@ # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in +# Sumanto Kar, sumantokar@iitb.ac.in # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Sunday 13 December 2020 +# REVISION: Monday 31 January 2022 # ========================================================================= import os +import traceback -if os.name == 'nt': # noqa +if os.name == 'nt': from frontEnd import pathmagic # noqa:F401 init_path = '' else: @@ -39,9 +41,11 @@ from PyQt5.Qt import QSize import shutil import time import sys - +import psutil # Its our main window of application. + + class Application(QtWidgets.QMainWindow): """This class initializes all objects used in this file.""" global project_name @@ -86,7 +90,7 @@ class Application(QtWidgets.QMainWindow): - Top-tool-bar (New project, Open project, Close project, \ Mode switch, Help option) - - Left-tool-bar (Open Schematic, Convert KiCad to NgSpice, \ + - Left-tool-bar (Open Schematic, Convert KiCad to Ngspice, \ Simuation, Model Editor, Subcircuit, NGHDL, Modelica \ Converter, OM Optimisation) """ @@ -183,13 +187,13 @@ class Application(QtWidgets.QMainWindow): self.conversion = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/ki-ng.png'), - '<b>Convert Kicad to Ngspice</b>', self + '<b>Convert KiCad to Ngspice</b>', self ) self.conversion.triggered.connect(self.obj_kicad.openKicadToNgspice) self.ngspice = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/ngspice.png'), - '<b>Simulation</b>', self + '<b>Simulate</b>', self ) self.ngspice.triggered.connect(self.open_ngspice) @@ -206,10 +210,16 @@ class Application(QtWidgets.QMainWindow): self.subcircuit.triggered.connect(self.open_subcircuit) self.nghdl = QtWidgets.QAction( - QtGui.QIcon(init_path + 'images/nghdl.png'), '<b>Nghdl</b>', self + QtGui.QIcon(init_path + 'images/nghdl.png'), '<b>NGHDL</b>', self ) self.nghdl.triggered.connect(self.open_nghdl) + self.makerchip = QtWidgets.QAction( + QtGui.QIcon(init_path + 'images/makerchip.png'), + '<b>Makerchip-NgVeri</b>', self + ) + self.makerchip.triggered.connect(self.open_makerchip) + self.omedit = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/omedit.png'), '<b>Modelica Converter</b>', self @@ -230,6 +240,7 @@ class Application(QtWidgets.QMainWindow): self.lefttoolbar.addAction(self.ngspice) self.lefttoolbar.addAction(self.model) self.lefttoolbar.addAction(self.subcircuit) + self.lefttoolbar.addAction(self.makerchip) self.lefttoolbar.addAction(self.nghdl) self.lefttoolbar.addAction(self.omedit) self.lefttoolbar.addAction(self.omoptim) @@ -505,7 +516,7 @@ class Application(QtWidgets.QMainWindow): self.msg.setWindowTitle("Error Message") self.msg.setModal(True) self.msg.showMessage( - 'Please save and close all the Kicad ' + + 'Please save and close all the KiCad ' + 'windows first, then change the mode' ) self.msg.exec_() @@ -523,17 +534,67 @@ class Application(QtWidgets.QMainWindow): print("Current Project is : ", self.obj_appconfig.current_project) self.obj_Mainview.obj_dockarea.usermanual() + def checkIfProcessRunning(self, processName): + ''' + Check if there is any running process + that contains the given name processName. + ''' + # Iterate over the all the running process + for proc in psutil.process_iter(): + try: + # Check if process name contains the given name string. + if processName.lower() in proc.name().lower(): + return True + except (psutil.NoSuchProcess, + psutil.AccessDenied, psutil.ZombieProcess): + pass + return False + 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: - self.obj_Mainview.obj_dockarea.ngspiceEditor(self.projDir) + + # Edited by Sumanto Kar 25/08/2021 + if self.obj_Mainview.obj_dockarea.ngspiceEditor( + self.projDir) is False: + print( + "Netlist file (*.cir.out) not found." + ) + + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Error Message") + self.msg.showMessage( + 'Netlist file (*.cir.out) not found.' + ) + 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 @@ -546,7 +607,8 @@ class Application(QtWidgets.QMainWindow): if count >= 10: print( "Ngspice taking too long for simulation. " - "Check netlist file to change simulation parameters." + "Check netlist file (*.cir.out) " + "to change simulation parameters." ) self.msg = QtWidgets.QErrorMessage() @@ -554,7 +616,8 @@ class Application(QtWidgets.QMainWindow): self.msg.setWindowTitle("Warning Message") self.msg.showMessage( 'Ngspice taking too long for simulation. ' - 'Check netlist file to change simulation parameters.' + 'Check netlist file (*.cir.out) ' + 'to change simulation parameters.' ) self.msg.exec_() @@ -572,7 +635,7 @@ class Application(QtWidgets.QMainWindow): ' Please look at console for more details.' ) self.msg.exec_() - print("Exception Message:", str(e)) + print("Exception Message:", str(e), traceback.format_exc()) self.obj_appconfig.print_error('Exception Message : ' + str(e)) else: @@ -626,6 +689,20 @@ class Application(QtWidgets.QMainWindow): 'Please make sure it is installed') self.msg.exec_() + def open_makerchip(self): + """ + This function opens 'subcircuit' option in left-tool-bar. + When 'subcircuit' icon is clicked wich is present in + left-tool-bar of main page: + + - Meassge shown on screen "Subcircuit editor is called". + - 'subcircuiteditor()' function is called using object + 'obj_dockarea' of class 'Mainview'. + """ + print("Function : Makerchip and Verilator to Ngspice Converter") + self.obj_appconfig.print_info('Makerchip is called') + self.obj_Mainview.obj_dockarea.makerchip() + def open_modelEditor(self): """ This function opens model editor option in left-tool-bar. @@ -707,7 +784,7 @@ class Application(QtWidgets.QMainWindow): else: self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) - self.msg.setWindowTitle("Missing Ngspice netlist") + self.msg.setWindowTitle("Missing Ngspice Netlist") self.msg.showMessage( 'Current project does not contain any Ngspice file. ' + 'Please create Ngspice file with extension .cir.out' @@ -718,8 +795,8 @@ class Application(QtWidgets.QMainWindow): self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( - 'Please select the project first. ' + - 'You can either create a new project or open existing project' + 'Please select the project first. You can either ' + + 'create a new project or open an existing project' ) self.msg.exec_() @@ -850,9 +927,12 @@ def main(args): appView.obj_workspace.returnWhetherClickedOrNot(appView) try: - file = open(os.path.join( - os.path.expanduser("~"), ".esim/workspace.txt"), 'r' - ) + if os.name == 'nt': + user_home = os.path.join('library', 'config') + else: + user_home = os.path.expanduser('~') + + file = open(os.path.join(user_home, ".esim/workspace.txt"), 'r') work = int(file.read(1)) file.close() except IOError: diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index b96c468a..461240b9 100644..100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -4,6 +4,7 @@ from ngspiceSimulation.NgspiceWidget import NgspiceWidget from configuration.Appconfig import Appconfig from modelEditor.ModelEditor import ModelEditorclass from subcircuit.Subcircuit import Subcircuit +from maker.makerchip import makerchip from kicadtoNgspice.KicadtoNgspice import MainWindow from browser.Welcome import Welcome from browser.UserManual import UserManual @@ -123,6 +124,10 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") + # Edited by Sumanto Kar 25/08/2021 + if os.path.isfile(self.ngspiceNetlist) is False: + return False + global count self.ngspiceWidget = QtWidgets.QWidget() @@ -254,6 +259,34 @@ class DockArea(QtWidgets.QMainWindow): count = count + 1 + def makerchip(self): + """This function creates a widget for different subcircuit options.""" + global count + self.makerWidget = QtWidgets.QWidget() + self.makerLayout = QtWidgets.QVBoxLayout() + self.makerLayout.addWidget(makerchip(self)) + + self.makerWidget.setLayout(self.makerLayout) + dock['Makerchip-' + + str(count)] = QtWidgets.QDockWidget('Makerchip-' + str(count)) + dock['Makerchip-' + str(count)].setWidget(self.makerWidget) + self.addDockWidget(QtCore.Qt.TopDockWidgetArea, + dock['Makerchip-' + str(count)]) + self.tabifyDockWidget(dock['Welcome'], + dock['Makerchip-' + str(count)]) + + # CSS + dock['Makerchip-' + str(count)].setStyleSheet(" \ + .QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ + ") + + dock['Makerchip-' + str(count)].setVisible(True) + dock['Makerchip-' + str(count)].setFocus() + dock['Makerchip-' + str(count)].raise_() + + count = count + 1 + def usermanual(self): """This function creates a widget for user manual.""" global count diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 456276c8..456276c8 100644..100755 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index 4d033539..fca73e39 100644..100755 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -124,9 +124,13 @@ class Workspace(QtWidgets.QWidget): self.obj_appconfig.workspace_check = self.chkbox.checkState() print(self.workspace_loc.text()) - file = open(os.path.join( - os.path.expanduser("~"), ".esim/workspace.txt"), 'w' - ) + + if os.name == 'nt': + user_home = os.path.join('library', 'config') + else: + user_home = os.path.expanduser('~') + + file = open(os.path.join(user_home, ".esim/workspace.txt"), 'w') file.writelines( str(self.obj_appconfig.workspace_check) + " " + self.workspace_loc.text() diff --git a/src/frontEnd/__init__.py b/src/frontEnd/__init__.py index e69de29b..e69de29b 100644..100755 --- a/src/frontEnd/__init__.py +++ b/src/frontEnd/__init__.py diff --git a/src/frontEnd/pathmagic.py b/src/frontEnd/pathmagic.py index 5f0d712c..5f0d712c 100644..100755 --- a/src/frontEnd/pathmagic.py +++ b/src/frontEnd/pathmagic.py |