diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/browser/Welcome.py | 4 | ||||
-rw-r--r-- | src/configuration/Appconfig.py | 4 | ||||
-rw-r--r-- | src/frontEnd/DockArea.py | 55 | ||||
-rw-r--r-- | src/frontEnd/ProjectExplorer.py | 111 | ||||
-rw-r--r-- | src/frontEnd/Workspace.py | 2 | ||||
-rw-r--r-- | src/frontEnd/pathmagic.py | 2 | ||||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 2 | ||||
-rw-r--r-- | src/kicadtoNgspice/DeviceModel.py | 13 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/SubcircuitTab.py | 4 | ||||
-rw-r--r-- | src/modelEditor/ModelEditor.py | 50 | ||||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 9 | ||||
-rw-r--r-- | src/ngspiceSimulation/pythonPlotting.py | 80 | ||||
-rw-r--r-- | src/ngspicetoModelica/ModelicaUI.py | 7 | ||||
-rw-r--r-- | src/subcircuit/newSub.py | 2 |
17 files changed, 226 insertions, 137 deletions
diff --git a/src/browser/Welcome.py b/src/browser/Welcome.py index 52e7d5bd..2ae8fce1 100644 --- a/src/browser/Welcome.py +++ b/src/browser/Welcome.py @@ -2,9 +2,7 @@ from PyQt4 import QtGui, QtCore class Welcome(QtGui.QWidget): - """ - This class creates Welcome page of eSim. - """ + """This class creates Welcome page of eSim.""" def __init__(self): """Sdf.""" diff --git a/src/configuration/Appconfig.py b/src/configuration/Appconfig.py index 8c34abb8..0b34e3fc 100644 --- a/src/configuration/Appconfig.py +++ b/src/configuration/Appconfig.py @@ -58,9 +58,9 @@ class Appconfig(QtGui.QWidget): # Try catch added, since eSim cannot be accessed under parser for Win10 try: modelica_map_json = parser_esim.get('eSim', 'MODELICA_MAP_JSON') - except: + except BaseException: print("Cannot access eSim in parser") - + try: project_explorer = json.load(open(dictPath)) except BaseException: diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 2c605272..8b8e975b 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -11,16 +11,19 @@ from ngspicetoModelica.ModelicaUI import OpenModelicaEditor import os dockList = ['Welcome'] -count = 1 +count = 1 dock = {} + # class DockArea(QtGui.QMainWindow): - """ """ + """Sdf.""" + def __init__(self): + """Sdf.""" QtGui.QMainWindow.__init__(self) self.obj_appconfig = Appconfig() - + for dockName in dockList: dock[dockName] = QtGui.QDockWidget(dockName) self.welcomeWidget = QtGui.QWidget() @@ -42,9 +45,8 @@ class DockArea(QtGui.QMainWindow): # This function create widget for Library Editor def createTestEditor(self): - """ """ + """Sdf.""" global count - self.testWidget = QtGui.QWidget() self.testArea = QtGui.QTextEdit() self.testLayout = QtGui.QVBoxLayout() @@ -71,14 +73,14 @@ class DockArea(QtGui.QMainWindow): # This function create widget for interactive PythonPlotting def plottingEditor(self): - """ """ + """Sdf.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] self.projName = os.path.basename(self.projDir) # self.project = os.path.join(self.projDir,self.projName) global count self.plottingWidget = QtGui.QWidget() - + self.plottingLayout = QtGui.QVBoxLayout() self.plottingLayout.addWidget(plotWindow(self.projDir, self.projName)) @@ -100,9 +102,9 @@ class DockArea(QtGui.QMainWindow): dock['Plotting-' + str(count)]) count = count + 1 + # This function creates widget for NgSpice window. def ngspiceEditor(self, projDir): - """This function creates widget for NgSpice window.""" - + """Sdf.""" self.projDir = projDir self.projName = os.path.basename(self.projDir) self.ngspiceNetlist = os.path.join( @@ -110,7 +112,7 @@ class DockArea(QtGui.QMainWindow): global count self.ngspiceWidget = QtGui.QWidget() - + self.ngspiceLayout = QtGui.QVBoxLayout() self.ngspiceLayout.addWidget( NgspiceWidget( @@ -140,7 +142,9 @@ class DockArea(QtGui.QMainWindow): dock['NgSpice-' + str(count)]) count = count + 1 + # This function defines UI for model editor. def modelEditor(self): + """Sdf.""" print("in model editor") global count self.modelwidget = QtGui.QWidget() @@ -174,7 +178,9 @@ class DockArea(QtGui.QMainWindow): dock['Model Editor-' + str(count)]) count = count + 1 + # This function is creating Editor UI for Kicad to Ngspice conversion. def kicadToNgspiceEditor(self, clarg1, clarg2=None): + """Sdf.""" global count self.kicadToNgspiceWidget = QtGui.QWidget() self.kicadToNgspiceLayout = QtGui.QVBoxLayout() @@ -204,16 +210,15 @@ class DockArea(QtGui.QMainWindow): self.obj_appconfig.dock_dict[temp].append( dock['kicadToNgspice-' + str(count)]) count = count + 1 + + # This function creates a widget for different subcircuit options. def subcircuiteditor(self): - """ - This function creates a widget for different subcircuit options - """ - + """Sdf.""" global count self.subcktWidget = QtGui.QWidget() self.subcktLayout = QtGui.QVBoxLayout() self.subcktLayout.addWidget(Subcircuit(self)) - + self.subcktWidget.setLayout(self.subcktLayout) dock['Subcircuit-' + str(count)] = QtGui.QDockWidget('Subcircuit-' + str(count)) @@ -237,17 +242,15 @@ class DockArea(QtGui.QMainWindow): self.obj_appconfig.dock_dict[temp].append( dock['Subcircuit-' + str(count)]) count = count + 1 - + + # This function creates a widget for different subcircuit options. def usermanual(self): - """ - This function creates a widget for different subcircuit options - """ - + """Sdf.""" global count self.usermanualWidget = QtGui.QWidget() self.usermanualLayout = QtGui.QVBoxLayout() self.usermanualLayout.addWidget(UserManual()) - + self.usermanualWidget.setLayout(self.usermanualLayout) dock['User Manual-' + str(count)] = QtGui.QDockWidget('User Manual-' + str(count)) @@ -269,9 +272,9 @@ class DockArea(QtGui.QMainWindow): count = count + 1 + # This function sets up the UI for ngspice to modelica conversion. def modelicaEditor(self, projDir): - """This function sets up the UI for ngspice to modelica conversion.""" - + """Dfg.""" global count self.modelicaWidget = QtGui.QWidget() self.modelicaLayout = QtGui.QVBoxLayout() @@ -300,7 +303,9 @@ class DockArea(QtGui.QMainWindow): count = count + 1 + # This function when called closes the opened file. def closeDock(self): - temp = self.obj_appconfig.current_project['ProjectName'] - for dockwidget in self.obj_appconfig.dock_dict[temp]: + """Sdf.""" + self.temp = self.obj_appconfig.current_project['ProjectName'] + for dockwidget in self.obj_appconfig.dock_dict[self.temp]: dockwidget.close() diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index d84f41e0..8d0ef4ec 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -6,12 +6,20 @@ from configuration.Appconfig import Appconfig # This is main class for Project Explorer Area. class ProjectExplorer(QtGui.QWidget): - """ """ + """ + This class contains function: + a)One work as a constructor(__init__). + b)For saving data. + c)for renaming project. + d)for refreshing project. + e)for removing project. + f) for saving data. + """ def __init__(self): """ This method is doing following tasks: - a)initializing objects used in full program. + a)Working as a constructor for class ProjectExplorer. b)view of project explorer area. """ QtGui.QWidget.__init__(self) @@ -24,20 +32,20 @@ class ProjectExplorer(QtGui.QWidget): # CSS self.treewidget.setStyleSheet(" \ - QTreeView { border-radius: 15px; border: 1px solid gray; padding: \ - 5px; width: 200px; height: 150px; } \ - QTreeView::branch:has-siblings:!adjoins-item { border-image:\ - url(../../images/vline.png) 0; } \ - QTreeView::branch:has-siblings:adjoins-item { border-image:\ - url(../../images/branch-more.png) 0; } \ - QTreeView::branch:!has-children:!has-siblings:\ - adjoins-item { border-image: url(../../images/branch-end.png) 0; } \ - QTreeView::branch:has-children:!has-siblings:closed, \ - QTreeView::branch:closed:has-children:has-siblings { border-image:\ - none; image: url(../../images/branch-closed.png); } \ - QTreeView::branch:open:has-children:!has-siblings, \ - QTreeView::branch:open:has-children:has-siblings { border-image: \ - none; image: url(../../images/branch-open.png); } \ + QTreeView::branch:has-siblings:!adjoins-item { \ + border-image: url(../../images/vline.png) 0;} \ + QTreeView::branch:has-siblings:adjoins-item { \ + border-image: url(../../images/branch-more.png) 0; } \ + QTreeView::branch:!has-children:!has-siblings:adjoins-item { \ + border-image: url(../../images/branch-end.png) 0; } \ + QTreeView::branch:has-children:!has-siblings:closed, \ + QTreeView::branch:closed:has-children:has-siblings { \ + border-image: none; \ + image: url(../../images/branch-closed.png); } \ + QTreeView::branch:open:has-children:!has-siblings, \ + QTreeView::branch:open:has-children:has-siblings { \ + border-image: none; \ + image: url(../../images/branch-open.png); } \ ") for parents, children in list( @@ -45,8 +53,9 @@ class ProjectExplorer(QtGui.QWidget): os.path.join(parents) if os.path.exists(parents): pathlist = parents.split(os.sep) - parentnode = QtGui.QTreeWidgetItem(self.treewidget, - [pathlist[-1], parents]) + parentnode = QtGui.QTreeWidgetItem( + self.treewidget, [pathlist[-1], parents] + ) for files in children: QtGui.QTreeWidgetItem( parentnode, [files, os.path.join(parents, files)]) @@ -64,9 +73,9 @@ class ProjectExplorer(QtGui.QWidget): parentnode = QtGui.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents]) for files in children: - QtGui.QTreeWidgetItem( + QtGui.QTreeWidgetItem( parentnode, [files, os.path.join(parents, files)] - ) + ) ( self.obj_appconfig. @@ -89,6 +98,8 @@ class ProjectExplorer(QtGui.QWidget): menu = QtGui.QMenu() if level == 0: + renameProject = menu.addAction(self.tr("Rename Project")) + renameProject.triggered.connect(self.renameProject) deleteproject = menu.addAction(self.tr("Remove Project")) deleteproject.triggered.connect(self.removeProject) refreshproject = menu.addAction(self.tr("Refresh")) @@ -159,6 +170,10 @@ class ProjectExplorer(QtGui.QWidget): # This function is saving data before it closes the given file. def save_data(self): + """ + This function first opens file in write-mode, when write + operation is performed it closes that file and then window. + """ self.fopen = open(self.filePath, 'w') self.fopen.write(self.text.toPlainText()) self.fopen.close() @@ -167,7 +182,9 @@ class ProjectExplorer(QtGui.QWidget): # This function removes the project in explorer area by right # clicking on project and selecting remove option. def removeProject(self): - """ """ + """ + + """ self.indexItem = self.treewidget.currentIndex() self.filePath = str( self.indexItem.sibling( @@ -199,7 +216,7 @@ class ProjectExplorer(QtGui.QWidget): for items in self.treewidget.selectedItems(): items.removeChild(items.child(0)) for files in filelistnew: - QtGui.QTreeWidgetItem( + QtGui.QTreeWidgetItem( parentnode, [ files, os.path.join( self.filePath, files)]) @@ -207,3 +224,53 @@ class ProjectExplorer(QtGui.QWidget): self.obj_appconfig.project_explorer[self.filePath] = filelistnew json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath, 'w')) + + # """ + def renameProject(self): + indexItem = self.treewidget.currentIndex() + baseFileName = str(indexItem.data()) + newBaseFileName, ok = QtGui.QInputDialog.getText( + self, 'Rename Project', 'Project Name:', + QtGui.QLineEdit.Normal, baseFileName + ) + if ok and newBaseFileName: + newBaseFileName = str(newBaseFileName) + projectPath, projectFiles = list( + self.obj_appconfig.project_explorer.items())[indexItem.row()] + updatedProjectFiles = [] + + # rename files matching project name + for projectFile in projectFiles: + if baseFileName in projectFile: + oldFilePath = os.path.join(projectPath, projectFile) + projectFile = projectFile.replace( + baseFileName, newBaseFileName, 1) + newFilePath = os.path.join(projectPath, projectFile) + print ("Renaming " + oldFilePath + " to " + newFilePath) + os.rename(oldFilePath, newFilePath) + + updatedProjectFiles.append(projectFile) + + # rename project folder + updatedProjectPath = newBaseFileName.join( + projectPath.rsplit(baseFileName, 1)) + print ("Renaming " + projectPath + " to " + updatedProjectPath) + os.rename(projectPath, updatedProjectPath) + + # update project_explorer dictionary + del self.obj_appconfig.project_explorer[projectPath] + self.obj_appconfig.project_explorer[updatedProjectPath] = ( + updatedProjectFiles + ) + + # save project_explorer dictionary on disk + json.dump(self.obj_appconfig.project_explorer, + open(self.obj_appconfig.dictPath, 'w')) + + # recreate project explorer tree + self.treewidget.clear() + for parent, children in ( + self.obj_appconfig.project_explorer.items() + ): + self.addTreeNode(parent, children) + # """ diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index 62833064..30d0607b 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -21,6 +21,8 @@ import time import os # This class creates Workspace GUI. + + class Workspace(QtGui.QWidget): """ diff --git a/src/frontEnd/pathmagic.py b/src/frontEnd/pathmagic.py index 92a5e6e2..49c4932d 100644 --- a/src/frontEnd/pathmagic.py +++ b/src/frontEnd/pathmagic.py @@ -3,4 +3,4 @@ import sys # Setting PYTHONPATH cwd = os.getcwd() (setPath, fronEnd) = os.path.split(cwd) -sys.path.append(setPath)
\ No newline at end of file +sys.path.append(setPath) diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 76b6ba57..8280f9e7 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -443,7 +443,7 @@ class Convert: default = 0 # Cheking if value is iterable.its for vector if ( - type(value) is not str and + not isinstance(value, str) and hasattr(value, '__iter__') ): addmodelLine += param + "=[" diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index 57fd3f25..e1367181 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -65,6 +65,8 @@ class DeviceModel(QtGui.QWidget): print("Reading Device model details from Schematic") for eachline in schematicInfo: + print("=========================================") + print(eachline) words = eachline.split() if eachline[0] == 'q': print("Device Model Transistor: ", words[0]) @@ -82,7 +84,7 @@ class DeviceModel(QtGui.QWidget): try: for key in json_data["deviceModel"]: - if key[0] == eachline[0] and key[1] == eachline[1]: + if key == words[0]: # print "DEVICE MODEL MATCHING---",child.tag[0],\ # child.tag[1],eachline[0],eachline[1] try: @@ -148,7 +150,7 @@ class DeviceModel(QtGui.QWidget): # global path_name try: for key in json_data["deviceModel"]: - if key[0] == eachline[0] and key[1] == eachline[1]: + if key == words[0]: # print "DEVICE MODEL MATCHING---",child.tag[0],\ # child.tag[1],eachline[0],eachline[1] try: @@ -213,7 +215,7 @@ class DeviceModel(QtGui.QWidget): # global path_name try: for key in json_data["deviceModel"]: - if key[0] == eachline[0] and key[1] == eachline[1]: + if key == words[0]: # print "DEVICE MODEL MATCHING---",child.tag[0],\ # child.tag[1],eachline[0],eachline[1] try: @@ -326,7 +328,7 @@ class DeviceModel(QtGui.QWidget): # global path_name try: for key in json_data["deviceModel"]: - if key[0] == eachline[0] and key[1] == eachline[1]: + if key == words[0]: # print "DEVICE MODEL MATCHING---",child.tag[0],\ # child.tag[1],eachline[0],eachline[1] while i <= end: @@ -337,7 +339,7 @@ class DeviceModel(QtGui.QWidget): json_data["deviceModel"][key][0]): path_name = ( json_data["deviceModel"][key][0] - ) + ) else: self.entry_var[i].setText("") i = i + 1 @@ -408,6 +410,7 @@ class DeviceModel(QtGui.QWidget): self.widgetObjCount = iter_value print("self.widgetObjCount-----", self.widgetObjCount) self.libfile = path_value + print("PATH VALUE", path_value) # print "Selected Library File :",self.libfile # Setting Library to Text Edit Line diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index 9624fc82..ef9201cb 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -41,6 +41,7 @@ class MainWindow(QtGui.QWidget): - clarg1 is the path to the .cir file - clarg2 is either None or "sub" depending on the analysis type """ + def __init__(self, clarg1, clarg2=None): QtGui.QWidget.__init__(self) print("==================================") @@ -107,7 +108,7 @@ class MainWindow(QtGui.QWidget): unknownModelList, multipleModelList, plotText - ) = obj_proc.convertICintoBasicBlocks( + ) = obj_proc.convertICintoBasicBlocks( schematicInfo, outputOption, modelList, plotText ) print("=======================================") @@ -483,8 +484,7 @@ class MainWindow(QtGui.QWidget): for key, value in line[7].items(): if( hasattr(value, '__iter__') and - i <= end and type(value) is not - str + i <= end and not isinstance(value, str) ): for item in value: fields = { diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index eb1793f9..a182dd4e 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -62,7 +62,7 @@ class Model(QtGui.QWidget): # print "Key : ",key # print "Value : ",value # Check if value is iterable - if type(value) is not str and hasattr(value, '__iter__'): + if not isinstance(value, str) and hasattr(value, '__iter__'): # For tag having vector value temp_tag = [] for item in value: @@ -115,8 +115,8 @@ class Model(QtGui.QWidget): self.obj_trac.model_entry_var [self.nextcount].setText( str(list(json_data - ["model"][mod]["values"] - [i].values())[0])) + ["model"][mod]["values"] + [i].values())[0])) ) i = i + 1 except BaseException: diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index ebbd3429..216383e6 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -16,6 +16,7 @@ class PrcocessNetlist: """ - Read the circuit file and return splitted lines """ + def readNetlist(self, filename): f = open(filename) data = f.read() @@ -31,6 +32,7 @@ class PrcocessNetlist: - Read Parameter information and store it into dictionary - kicadNetlis is the .cir file content """ + def readParamInfo(self, kicadNetlis): param = {} print("=========================KICADNETLIST========================") @@ -55,6 +57,7 @@ class PrcocessNetlist: - Preprocess netlist (replace parameters) - Separate infoline (first line) from the rest of netlist """ + def preprocessNetlist(self, kicadNetlis, param): netlist = [] for eachline in kicadNetlis: @@ -125,6 +128,7 @@ class PrcocessNetlist: - Then check for type whether ac, dc, sine, etc... - Handle starting with h and f as well """ + def insertSpecialSourceParam(self, schematicInfo, sourcelist): schematicInfo1 = [] print("=============================================================") @@ -462,7 +466,7 @@ class PrcocessNetlist: "a" + str(k) + " (" + words[1] + " " + words[2] + ") (interNode_" + str(interMediateNodeCount) + " " + words[3] + ") " - ) + ) modelLine += compName + "_primary" schematicInfo.append(modelLine) k = k + 1 diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py index 52a7a824..d15407f7 100644 --- a/src/kicadtoNgspice/SubcircuitTab.py +++ b/src/kicadtoNgspice/SubcircuitTab.py @@ -73,7 +73,7 @@ class SubcircuitTab(QtGui.QWidget): global path_name try: for key in json_data["subcircuit"]: - if key[0] == eachline[0] and key[1] == eachline[1]: + if key == words[0]: # print "Subcircuit MATCHING---",child.tag[0], \ # child.tag[1], eachline[0], eachline[1] try: @@ -203,4 +203,4 @@ class SubcircuitTab(QtGui.QWidget): "Please select a valid Subcircuit directory \ (Containing '.sub' file).") self.msg.setWindowTitle("Error Message") - self.msg.show()
\ No newline at end of file + self.msg.show() diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index 0d5ff0cf..1dce456e 100644 --- a/src/modelEditor/ModelEditor.py +++ b/src/modelEditor/ModelEditor.py @@ -81,7 +81,7 @@ class ModelEditorclass(QtGui.QWidget): self.igbt.setDisabled(True) self.magnetic = QtGui.QRadioButton('Magnetic Core') self.magnetic.setDisabled(True) - + self.radiobtnbox.addButton(self.diode) self.diode.clicked.connect(self.diode_click) self.radiobtnbox.addButton(self.bjt) @@ -114,6 +114,7 @@ class ModelEditorclass(QtGui.QWidget): - Change state of other buttons accordingly, ex. enable diode, bjt, ... - Validate filename created, to check if one already exists ''' + def opennew(self): self.addbtn.setHidden(True) try: @@ -146,6 +147,7 @@ class ModelEditorclass(QtGui.QWidget): - Set states for other elements - Diode has no types, so hide that ''' + def diode_click(self): self.openfiletype('Diode') self.types.setHidden(True) @@ -158,6 +160,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def bjt_click(self): self.types.setHidden(False) self.types.clear() @@ -178,6 +181,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def mos_click(self): self.types.setHidden(False) self.types.clear() @@ -199,6 +203,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def jfet_click(self): self.types.setHidden(False) self.types.clear() @@ -207,7 +212,7 @@ class ModelEditorclass(QtGui.QWidget): filetype = str(self.types.currentText()) self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) - + ''' - Set states for other elements - Initialise types combo box elements @@ -216,6 +221,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def igbt_click(self): self.types.setHidden(False) self.types.clear() @@ -232,6 +238,7 @@ class ModelEditorclass(QtGui.QWidget): - Add an event listener for type-selection event - No types here, only one view ''' + def magnetic_click(self): self.openfiletype('Magnetic Core') self.types.setHidden(True) @@ -241,6 +248,7 @@ class ModelEditorclass(QtGui.QWidget): - Get the type clicked, from text - Open appropriate table using openfiletype(filetype) ''' + def setfiletype(self, text): self.filetype = str(text) self.openfiletype(self.filetype) @@ -250,6 +258,7 @@ class ModelEditorclass(QtGui.QWidget): - Accordingly call `createtable(path)` to draw tables usingg QTable - Check for the state of button before rendering ''' + def openfiletype(self, filetype): self.path = '../deviceModelLibrary/Templates' if self.diode.isChecked(): @@ -311,6 +320,7 @@ class ModelEditorclass(QtGui.QWidget): - Create table for the selected .lib file using `self.createtable(path)` - Handle exception of no file selected ''' + def openedit(self): os.chdir(self.savepathtest) self.newflag = 0 @@ -345,6 +355,7 @@ class ModelEditorclass(QtGui.QWidget): - Show the extracted data in QTableWidget - Can edit QTable inplace, connect `edit_modeltable` function for editing ''' + def createtable(self, modelfile): self.savebtn.setDisabled(False) self.addbtn.setHidden(False) @@ -385,7 +396,8 @@ class ModelEditorclass(QtGui.QWidget): self.modeltable.setItem(count, 1, valueitem) count = count + 1 self.modeltable.setHorizontalHeaderLabels( - QtCore.QString("Parameters;Values").split(";")) + ("Parameters;Values").split(";") + ) self.modeltable.show() self.modeltable.itemChanged.connect(self.edit_modeltable) @@ -396,6 +408,7 @@ class ModelEditorclass(QtGui.QWidget): - Edit name and value as per needed - Add the val name pair in the modeldict ''' + def edit_modeltable(self): self.savebtn.setDisabled(False) try: @@ -415,6 +428,7 @@ class ModelEditorclass(QtGui.QWidget): - Accordingly add parameter and value in modeldict as well as table - text1 => parameter, text2 => value ''' + def addparameters(self): text1, ok = QtGui.QInputDialog.getText( self, 'Parameter', 'Enter Parameter') @@ -445,6 +459,7 @@ class ModelEditorclass(QtGui.QWidget): - If new file created, call `createXML` file - Else call `savethefile` ''' + def savemodelfile(self): if self.newflag == 1: self.createXML(self.model_name) @@ -457,6 +472,7 @@ class ModelEditorclass(QtGui.QWidget): - For each component, separate folder is there - Check the contents of .lib and .xml file to understand their structure ''' + def createXML(self, model_name): root = ET.Element("library") ET.SubElement(root, "model_name").text = model_name @@ -468,7 +484,7 @@ class ModelEditorclass(QtGui.QWidget): defaultcwd = os.getcwd() self.savepath = '../deviceModelLibrary' if self.diode.isChecked(): - savepath = os.path.join(self.savepath, 'Diode') + savepath = os.path.join(self.savepath, 'Diode') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -489,7 +505,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.mos.isChecked(): - savepath = os.path.join(self.savepath, 'MOS') + savepath = os.path.join(self.savepath, 'MOS') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -510,7 +526,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.jfet.isChecked(): - savepath = os.path.join(self.savepath, 'JFET') + savepath = os.path.join(self.savepath, 'JFET') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -531,7 +547,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.igbt.isChecked(): - savepath = os.path.join(self.savepath, 'IGBT') + savepath = os.path.join(self.savepath, 'IGBT') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -552,7 +568,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.magnetic.isChecked(): - savepath = os.path.join(self.savepath, 'Misc') + savepath = os.path.join(self.savepath, 'Misc') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -573,7 +589,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.bjt.isChecked(): - savepath = os.path.join(self.savepath, 'Transistor') + savepath = os.path.join(self.savepath, 'Transistor') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -600,6 +616,7 @@ class ModelEditorclass(QtGui.QWidget): - This function checks if the file (xml type) with the name already exists - Accordingly show error message ''' + def validation(self, text): newfilename = text + '.xml' @@ -617,6 +634,7 @@ class ModelEditorclass(QtGui.QWidget): - Create .lib and .xml file for the editfile path and replace them - Also print Updated Library with libpath in the command window ''' + def savethefile(self, editfile): xmlpath, file = os.path.split(editfile) filename = os.path.splitext(file)[0] @@ -632,7 +650,7 @@ class ModelEditorclass(QtGui.QWidget): libfile.write('+ ' + tags + '=' + text + '\n') libfile.write(')') libfile.close() - + root = ET.Element("library") ET.SubElement(root, "model_name").text = self.model_name ET.SubElement(root, "ref_model").text = self.ref_model @@ -650,6 +668,7 @@ class ModelEditorclass(QtGui.QWidget): - Remove the whole row from QTable Widget - Remove the param,value pair from modeldict ''' + def removeparameter(self): self.savebtn.setDisabled(False) index = self.modeltable.currentIndex() @@ -666,6 +685,7 @@ class ModelEditorclass(QtGui.QWidget): - Save it in `User Libraries` with the given name, and input from uploaded file ''' + def converttoxml(self): os.chdir(self.savepathtest) self.addbtn.setHidden(True) @@ -700,14 +720,14 @@ class ModelEditorclass(QtGui.QWidget): model_name = ''.join(model_name[0:modelnamecnt - 1]) else: model_name = ''.join(model_name) - + libopen1 = open(self.libfile) while True: char = libopen1.read(1) if not char: break stringof.append(char) - + count = 0 for chars in stringof: count = count + 1 @@ -726,9 +746,9 @@ class ModelEditorclass(QtGui.QWidget): for chars in stringof: count = count + 1 if chars == '=': - stopcount.append(count) + stopcount.append(count) stopcount.append(count) - + i = 0 for no in stopcount: try: @@ -784,4 +804,4 @@ class ModelEditorclass(QtGui.QWidget): fileopen.close() os.chdir(defaultcwd) libopen.close() - libopen1.close()
\ No newline at end of file + libopen1.close() diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index def1d4e9..1d5c974f 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -6,12 +6,13 @@ import os # This Class creates NgSpice Window class NgspiceWidget(QtGui.QWidget): - """ - Includes functions that checks whether OS is linux or windows - and creates NgSpice window accordingly. - """ def __init__(self, command, projPath): + """ + 1)Creates constructor for NgspiceWidget class. + 2)Checks whether OS is linux or windows + and creates NgSpice window accordingly. + """ QtGui.QWidget.__init__(self) self.obj_appconfig = Appconfig() self.process = QtCore.QProcess(self) diff --git a/src/ngspiceSimulation/pythonPlotting.py b/src/ngspiceSimulation/pythonPlotting.py index 9f8f8e88..3bf8fe59 100644 --- a/src/ngspiceSimulation/pythonPlotting.py +++ b/src/ngspiceSimulation/pythonPlotting.py @@ -1,4 +1,5 @@ - # Used for decimal division eg 2/3=0.66 and not '0' 6/2=3.0 and 6//2=3 +from __future__ import division # Used for decimal division eg +# 2/3=0.66 and not '0' 6/2=3.0 and 6//2=3 import os from PyQt4 import QtGui, QtCore from decimal import Decimal, getcontext @@ -19,6 +20,7 @@ class plotWindow(QtGui.QMainWindow): ''' def __init__(self, fpath, projectName): + """This create constructor for plotWindow class.""" QtGui.QMainWindow.__init__(self) self.fpath = fpath self.projectName = projectName @@ -59,7 +61,7 @@ class plotWindow(QtGui.QMainWindow): # Get DataExtraction Details self.obj_dataext = DataExtraction() self.plotType = self.obj_dataext.openFile(self.fpath) - + self.obj_dataext.computeAxes() self.a = self.obj_dataext.numVals() @@ -125,7 +127,7 @@ class plotWindow(QtGui.QMainWindow): self.warnning = QtGui.QLabel() self.funcName = QtGui.QLabel() self.funcExample = QtGui.QLabel() - + self.plotbtn = QtGui.QPushButton("Plot") self.plotbtn.setToolTip('<b>Press</b> to Plot') self.multimeterbtn = QtGui.QPushButton("Multimeter") @@ -155,11 +157,11 @@ class plotWindow(QtGui.QMainWindow): self.right_grid.addWidget(self.funcName, 4, 0) self.right_grid.addWidget(self.funcExample, 4, 1) self.right_vbox.addLayout(self.right_grid) - + self.hbox = QtGui.QHBoxLayout() self.hbox.addLayout(self.left_vbox) self.hbox.addLayout(self.right_vbox) - + self.widget = QtGui.QWidget() self.widget.setLayout(self.hbox) # finalvbox self.scrollArea = QtGui.QScrollArea() @@ -174,7 +176,7 @@ class plotWindow(QtGui.QMainWindow): # Right side window frame showing list of nodes and branches. self.mainFrame.setLayout(self.finalhbox) self.showMaximized() - + self.listNode.setText("<font color='indigo'>List of Nodes:</font>") self.listBranch.setText( "<font color='indigo'>List of Branches:</font>") @@ -235,20 +237,20 @@ class plotWindow(QtGui.QMainWindow): self.axes.cla() self.canvas.draw() QtCore.SLOT('quit()') - + def pushedPlotFunc(self): self.parts = str(self.text.text()) self.parts = self.parts.split(" ") if self.parts[len(self.parts) - 1] == '': self.parts = self.parts[0:-1] - + self.values = self.parts self.comboAll = [] - self.axes.cla() - + self.axes.cla() + self.plotType2 = self.obj_dataext.openFile(self.fpath) - + if len(self.parts) <= 2: self.warnning.setText("Too few arguments!\nRefer syntax below!") QtGui.QMessageBox.about( @@ -281,7 +283,7 @@ class plotWindow(QtGui.QMainWindow): self.comboAll.append(self.obj_dataext.y[i]) for i in range(len(a)): - + if a[i] == len(self.obj_dataext.NBList): QtGui.QMessageBox.about( self, "Warning!!", "One of the operands doesn't belong\ @@ -298,9 +300,9 @@ class plotWindow(QtGui.QMainWindow): else: self.axes.cla() - + for i in range(len(self.obj_dataext.y[a[0]])): - self.combo.append(self.obj_dataext.y[a[0]][i]) + self.combo.append(self.obj_dataext.y[a[0]][i]) self.combo1.append(self.obj_dataext.y[a[1]][i]) self.axes.plot( @@ -314,7 +316,7 @@ class plotWindow(QtGui.QMainWindow): self.axes.set_xlabel('Voltage(V)-->') else: self.axes.set_ylabel('Current(I)-->') - self.axes.set_ylabel('Current(I)-->') + self.axes.set_ylabel('Current(I)-->') elif max(a) >= self.volts_length and min(a) < self.volts_length: QtGui.QMessageBox.about( @@ -348,7 +350,7 @@ class plotWindow(QtGui.QMainWindow): label=str(1)) self.axes.set_xlabel('freq-->') - + if max(a) < self.volts_length: self.axes.set_ylabel('Voltage(V)-->') else: @@ -366,7 +368,7 @@ class plotWindow(QtGui.QMainWindow): self.axes.set_ylabel('Voltage(V)-->') else: self.axes.set_ylabel('Current(I)-->') - + else: # self.setWindowTitle('DC Analysis') self.axes.plot( @@ -406,7 +408,7 @@ class plotWindow(QtGui.QMainWindow): self.axes.set_ylabel('Voltage(V)-->') else: self.axes.set_ylabel('Current(I)-->') - + self.axes.grid(True) if boxCheck == 0: QtGui.QMessageBox.about( @@ -435,7 +437,7 @@ class plotWindow(QtGui.QMainWindow): QtGui.QMessageBox.about( self, "Warning!!", "Please select at least one Node OR Branch") self.canvas.draw() - + def onPush_trans(self): self.axes.cla() boxCheck = 0 @@ -472,7 +474,7 @@ class plotWindow(QtGui.QMainWindow): label=str( j + 1)) self.axes.set_xlabel('Voltage Sweep(V)-->') - + if j < self.volts_length: self.axes.set_ylabel('Voltage(V)-->') else: @@ -493,7 +495,7 @@ class plotWindow(QtGui.QMainWindow): 'm': 'color:magenta', 'k': 'color:black' }[letter] - + def multiMeter(self): print("Function : MultiMeter") self.obj = {} @@ -535,7 +537,7 @@ class plotWindow(QtGui.QMainWindow): class MultimeterWidgetClass(QtGui.QWidget): def __init__(self, node_branch, rmsValue, loc_x, loc_y, voltFlag): QtGui.QWidget.__init__(self) - + self.multimeter = QtGui.QWidget(self) if voltFlag: self.node_branchLabel = QtGui.QLabel("Node") @@ -559,7 +561,7 @@ class MultimeterWidgetClass(QtGui.QWidget): self.setWindowTitle("MultiMeter") self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.show() - + class DataExtraction: def __init__(self): @@ -578,7 +580,7 @@ class DataExtraction: # Reading data file for voltage with open(os.path.join(fpath, "plot_data_v.txt")) as f2: self.voltData = f2.read() - + self.voltData = self.voltData.split("\n") # Initializing variable @@ -619,7 +621,7 @@ class DataExtraction: self.analysisType = 0 if "dec" in self.analysisInfo: self.dec = 1 - + for i in self.voltData[3:]: p += 1 # 'p' gives no. of lines of data for each node/branch if "Index" in i: @@ -628,7 +630,7 @@ class DataExtraction: # print "l:",l if "AC" in i: # DC for dc files and AC for ac ones break - + elif ".tran" in self.analysisInfo: self.analysisType = 1 for i in self.voltData[3:]: @@ -651,7 +653,6 @@ class DataExtraction: # print "l:",l if "DC" in i: # DC for dc files and AC for ac ones break - # print "VoltNumber",vnumber # print "CurrentNumber",inumber @@ -669,7 +670,7 @@ class DataExtraction: try: with open(os.path.join(fpath, "plot_data_i.txt")) as f2: alli = f2.read() - + alli = alli.split("\n") self.NBIList = [] @@ -682,7 +683,7 @@ class DataExtraction: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage('Unable to open plot data files.') self.msg.setWindowTitle("Error Message:openFile") - + try: for l in alli[3].split(" "): if len(l) > 0: @@ -718,7 +719,7 @@ class DataExtraction: inum_i = len(alli[5].split("\t")) full_data = [] - + # Creating list of data: if d3 < 3: for i in range(1, d2): @@ -783,9 +784,9 @@ class DataExtraction: if self.NBList[len(self.NBList) - 1] == 'v-sweep': self.NBList.pop() j1.pop() - + j1.pop() - j = j + j1 + j = j + j1 j = j + full_data[m] # print j m += 1 @@ -825,18 +826,3 @@ class DataExtraction: for i in self.data: temp = i.split("\t") self.x.append(Decimal(temp[0])) - - - - - - - - - - - - - - - diff --git a/src/ngspicetoModelica/ModelicaUI.py b/src/ngspicetoModelica/ModelicaUI.py index 5d9a6ab9..80d43445 100644 --- a/src/ngspicetoModelica/ModelicaUI.py +++ b/src/ngspicetoModelica/ModelicaUI.py @@ -52,8 +52,11 @@ class OpenModelicaEditor(QtGui.QWidget): def callConverter(self): try: - self.cmd1 = "python3 ../ngspicetoModelica/NgspicetoModelica.py " + \ - self.ngspiceNetlist + ' ' + self.map_json + self.cmd1 = ( + "python3 ../ngspicetoModelica/NgspicetoModelica.py " + + self.ngspiceNetlist + ' ' + + self.map_json + ) # self.obj_workThread1 = Worker.WorkerThread(self.cmd1) # self.obj_workThread1.start() convert_process = Popen( diff --git a/src/subcircuit/newSub.py b/src/subcircuit/newSub.py index d94f4395..6b221b4c 100644 --- a/src/subcircuit/newSub.py +++ b/src/subcircuit/newSub.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui +from PyQt4 import QtGui from projManagement.Validation import Validation from configuration.Appconfig import Appconfig from projManagement import Worker |