diff options
author | nilshah98 | 2019-06-07 18:54:35 +0530 |
---|---|---|
committer | nilshah98 | 2019-06-13 12:15:50 +0530 |
commit | a0f738ba15264b69d9d51755569408bdd8e383b5 (patch) | |
tree | 3d472af32b57508a16dd7f81e5c54f8ccda1bf47 | |
parent | cc9bb8d5d56e64b6e6b6ff2db988ff200b9f720d (diff) | |
download | eSim-a0f738ba15264b69d9d51755569408bdd8e383b5.tar.gz eSim-a0f738ba15264b69d9d51755569408bdd8e383b5.tar.bz2 eSim-a0f738ba15264b69d9d51755569408bdd8e383b5.zip |
pep8 fixes and list models bug fixed
-rw-r--r-- | src/frontEnd/ProjectExplorer.py | 19 | ||||
-rw-r--r-- | src/kicadtoNgspice/Analysis.py | 65 | ||||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 7 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 65 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 19 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 84 | ||||
-rw-r--r-- | src/kicadtoNgspice/Source.py | 25 | ||||
-rw-r--r-- | src/kicadtoNgspice/TrackWidget.py | 8 | ||||
-rw-r--r-- | src/modelEditor/ModelEditor.py | 59 | ||||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 2 | ||||
-rw-r--r-- | src/ngspiceSimulation/pythonPlotting.py | 11 | ||||
-rw-r--r-- | src/ngspicetoModelica/ModelicaUI.py | 4 | ||||
-rw-r--r-- | src/ngspicetoModelica/NgspicetoModelica.py | 218 | ||||
-rw-r--r-- | src/projManagement/Kicad.py | 2 | ||||
-rw-r--r-- | src/projManagement/Validation.py | 4 | ||||
-rw-r--r-- | src/projManagement/Worker.py | 3 | ||||
-rw-r--r-- | src/projManagement/newProject.py | 1 | ||||
-rw-r--r-- | src/projManagement/openProject.py | 1 |
18 files changed, 368 insertions, 229 deletions
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 77b3f124..3ee66cd3 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -132,14 +132,19 @@ class ProjectExplorer(QtGui.QWidget): else: self.obj_appconfig.current_project["ProjectName"] = str( self.filePath) - self.obj_appconfig.proc_dict - [self.obj_appconfig.current_project['ProjectName']] = [ - ] - if self.obj_appconfig.current_project['ProjectName'] \ - not in self.obj_appconfig.dock_dict: + ( + self.obj_appconfig. + proc_dict[self.obj_appconfig.current_project['ProjectName']] + ) = [] + if ( + self.obj_appconfig.current_project['ProjectName'] not in self.obj_appconfig.dock_dict - [self.obj_appconfig.current_project['ProjectName']] = [ - ] + ): + ( + self.obj_appconfig. + dock_dict[ + self.obj_appconfig.current_project['ProjectName']] + ) = [] def enable_save(self): self.save.setEnabled(True) diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py index cde39f8f..a60a2286 100644 --- a/src/kicadtoNgspice/Analysis.py +++ b/src/kicadtoNgspice/Analysis.py @@ -8,7 +8,17 @@ import json class Analysis(QtGui.QWidget): """ - This class create Analysis Tab in KicadtoNgspice Window. + - This class create Analysis Tab in KicadtoNgspice Window. + - Set various track widget options here + - AC_entry_var + - AC_Parameter + - DC_entry_var + - DC_Parameter + - TRAN_entry_var + - TRAN_Parameter + - set_Checkbox + - AC_type + - op_check """ def __init__(self, clarg1): @@ -40,7 +50,9 @@ class Analysis(QtGui.QWidget): analysisfile = open(os.path.join(projpath, 'analysis')) content = analysisfile.readline() + print("=========================================================") print("Content of Analysis file :", content) + print("=========================================================") contentlist = content.split() if contentlist[0] == '.ac': @@ -88,6 +100,12 @@ class Analysis(QtGui.QWidget): self.setLayout(self.grid) self.show() + ''' + - Create the checkboxes for analysis type, under analysis tab + - checkbox > checkgrid > checkgroupbtn > checkAC | checkDC | checkTRAN + - Trigger enableBox on clicking + ''' + def createCheckBox(self): self.checkbox = QtGui.QGroupBox() self.checkbox.setTitle("Select Analysis Type") @@ -111,6 +129,11 @@ class Analysis(QtGui.QWidget): return self.checkbox + ''' + - Activate deactive analysis areas according to type + - Add analysis data to track_obj from TrackWidget + ''' + def enableBox(self): if self.checkAC.isChecked(): self.acbox.setDisabled(False) @@ -130,6 +153,14 @@ class Analysis(QtGui.QWidget): self.dcbox.setDisabled(True) self.track_obj.set_CheckBox["ITEMS"] = "TRAN" + ''' + - Designing of AC group in analysis tab + - 3 radio buttons - Lin | Dec | Oct + - 3 input boxes, with top 2 combos\ + - If previous values exist then fill default values from + previous value json file + ''' + def createACgroup(self): kicadFile = self.clarg1 (projpath, filename) = os.path.split(kicadFile) @@ -202,12 +233,14 @@ class Analysis(QtGui.QWidget): self.acgrid.addWidget(self.start_fre_combo, 2, 2) self.ac_parameter[0] = "Hz" + # Try setting to default value from anaylsis file try: self.ac_parameter[self.parameter_cnt] = str( json_data["analysis"]["ac"]["Start Fre Combo"]) except BaseException: self.ac_parameter[self.parameter_cnt] = "Hz" + # Event listener for combo action self.start_fre_combo.activated[str].connect(self.start_combovalue) self.parameter_cnt = self.parameter_cnt + 1 @@ -274,12 +307,23 @@ class Analysis(QtGui.QWidget): return self.acbox + ''' + - Below 2 functions handle combo value event listeners for + - - start frequency for ac + - - stop frequency for ac + - And accordingly set the ac_parameters + ''' + def start_combovalue(self, text): self.ac_parameter[0] = str(text) def stop_combovalue(self, text): self.ac_parameter[1] = str(text) + ''' + - Set track object for AC, according to the type of radio box selected + ''' + def set_ac_type(self): self.parameter_cnt = 0 @@ -292,6 +336,10 @@ class Analysis(QtGui.QWidget): else: pass + ''' + - Create DC area under analysis tab + ''' + def createDCgroup(self): kicadFile = self.clarg1 (projpath, filename) = os.path.split(kicadFile) @@ -564,6 +612,10 @@ class Analysis(QtGui.QWidget): return self.dcbox + ''' + - Below 6 functions to handle combo boxes for the DC group + ''' + def start_changecombo(self, text): self.dc_parameter[0] = str(text) @@ -582,12 +634,20 @@ class Analysis(QtGui.QWidget): def stop_changecombo2(self, text): self.dc_parameter[5] = str(text) + ''' + - Handles the Operating point analysis checkbox + ''' + def setflag(self): if self.check.isChecked(): self.track_obj.op_check.append(1) else: self.track_obj.op_check.append(0) + ''' + - Creating transient group under analysis and creating it's components + ''' + def createTRANgroup(self): kicadFile = self.clarg1 (projpath, filename) = os.path.split(kicadFile) @@ -717,6 +777,9 @@ class Analysis(QtGui.QWidget): print("Transient Analysis JSON Parse Error") return self.trbox + ''' + - Below 3 functions handle event for the combo box in transient group + ''' def start_combo_change(self, text): self.tran_parameter[0] = str(text) diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 38234fed..51daa1de 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -39,7 +39,7 @@ class Convert: str(self.entry_var[self.start].text())) > 0 else '0' va_val = str( self.entry_var[self.start + 1].text() - ) if len( + ) if len( str(self.entry_var[self.start + 1].text())) \ > 0 else '0' freq_val = str(self.entry_var[self.start + 2].text()) \ @@ -440,7 +440,10 @@ class Convert: param = key default = 0 # Cheking if value is iterable.its for vector - if hasattr(value, '__iter__'): + if ( + hasattr(value, '__iter__') + and type(value) is not str + ): addmodelLine += param + "=[" for lineVar in value: if str( diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index dfc7cff8..833bd6cc 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -33,11 +33,13 @@ import json class MainWindow(QtGui.QWidget): """ - This class create KicadtoNgspice window. - And Call Convert function if convert button is pressed. - The convert function takes all the value entered by user and create - a final netlist "*.cir.out". - This final netlist is compatible with NgSpice. + - This class create KicadtoNgspice window. + - And Call Convert function if convert button is pressed. + - The convert function takes all the value entered by user and create + a final netlist "*.cir.out". + - This final netlist is compatible with NgSpice. + - 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): @@ -52,6 +54,7 @@ class MainWindow(QtGui.QWidget): self.clarg2 = clarg2 # Create object of track widget + # Track the dynamically created widget of KicadtoNgSpice Window self.obj_track = TrackWidget.TrackWidget() # Clear Dictionary/List item of sub circuit and ngspice model @@ -65,9 +68,9 @@ class MainWindow(QtGui.QWidget): # Object of Processing obj_proc = PrcocessNetlist() - # Read the netlist + # Read the netlist, ie the .cir file kicadNetlist = obj_proc.readNetlist(self.kicadFile) - + print("=============================================================") print("Given Kicad Schematic Netlist Info :", kicadNetlist) # Construct parameter information @@ -75,13 +78,13 @@ class MainWindow(QtGui.QWidget): # Replace parameter with values netlist, infoline = obj_proc.preprocessNetlist(kicadNetlist, param) - + print("=============================================================") print("Schematic Info after processing Kicad Netlist: ", netlist) # print "INFOLINE",infoline # Separate option and schematic information optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist) - + print("=============================================================") print("OPTIONINFO in the Netlist", optionInfo) # List for storing source and its value @@ -92,15 +95,23 @@ class MainWindow(QtGui.QWidget): schematicInfo, sourcelist) # List storing model detail - global modelList, outputOption, unknownModelList, multipleModelList, plotText + global modelList, outputOption,\ + unknownModelList, multipleModelList, plotText modelList = [] outputOption = [] plotText = [] - schematicInfo, outputOption, modelList, unknownModelList, multipleModelList, plotText = obj_proc.convertICintoBasicBlocks( - schematicInfo, outputOption, modelList, plotText - ) - + ( + schematicInfo, + outputOption, + modelList, + unknownModelList, + multipleModelList, + plotText + ) = obj_proc.convertICintoBasicBlocks( + schematicInfo, outputOption, modelList, plotText + ) + print("=======================================") print("Model available in the Schematic :", modelList) """ @@ -128,11 +139,11 @@ class MainWindow(QtGui.QWidget): else: self.createMainWindow() - def createMainWindow(self): - """ - This function create main window of Kicad to Ngspice converter - """ + """ + This function create main window of Kicad to Ngspice converter + """ + def createMainWindow(self): self.vbox = QtGui.QVBoxLayout(self) self.hbox = QtGui.QHBoxLayout(self) self.hbox.addStretch(1) @@ -450,7 +461,11 @@ class MainWindow(QtGui.QWidget): json_data["model"][line[3]]["values"] = [] for key, value in line[7].items(): - if hasattr(value, '__iter__') and i <= end: + if( + hasattr(value, '__iter__') and + i <= end and type(value) is not + str + ): for item in value: fields = { item: str( @@ -503,21 +518,24 @@ class MainWindow(QtGui.QWidget): self.obj_track.sourcelisttrack["ITEMS"], self.obj_track.source_entry_var["ITEMS"], store_schematicInfo, self.clarg1 - ) + ) try: # Adding Source Value to Schematic Info store_schematicInfo = self.obj_convert.addSourceParameter() + print("=========================================================") print("Netlist After Adding Source details :", store_schematicInfo) # Adding Model Value to store_schematicInfo store_schematicInfo = self.obj_convert.addModelParameter( store_schematicInfo) + print("=========================================================") print("Netlist After Adding Ngspice Model :", store_schematicInfo) # Adding Device Library to SchematicInfo store_schematicInfo = self.obj_convert.addDeviceLibrary( store_schematicInfo, self.kicadFile) + print("=========================================================") print( "Netlist After Adding Device Model Library :", store_schematicInfo) @@ -525,6 +543,7 @@ class MainWindow(QtGui.QWidget): # Adding Subcircuit Library to SchematicInfo store_schematicInfo = self.obj_convert.addSubcircuit( store_schematicInfo, self.kicadFile) + print("=========================================================") print("Netlist After Adding subcircuits :", store_schematicInfo) analysisoutput = self.obj_convert.analysisInsertor( @@ -538,7 +557,7 @@ class MainWindow(QtGui.QWidget): self.obj_track.AC_type["ITEMS"], self.obj_track.op_check ) - + print("=========================================================") print("Analysis OutPut ", analysisoutput) # Calling netlist file generation function @@ -561,6 +580,7 @@ class MainWindow(QtGui.QWidget): self.createSubFile(subPath) def createNetlistFile(self, store_schematicInfo, plotText): + print("=============================================================") print("Creating Final netlist") # print "INFOLINE",infoline # print "OPTIONINFO",optionInfo @@ -588,6 +608,7 @@ class MainWindow(QtGui.QWidget): Please check it") sys.exit() else: + print("========================================================") print(analysisFileLoc + " does not exist") sys.exit() @@ -673,6 +694,7 @@ class MainWindow(QtGui.QWidget): except BaseException: print("Error in opening .cir.out file.") else: + print("=========================================================") print( self.projName + ".cir.out does not exist. Please create a spice netlist.") @@ -732,4 +754,5 @@ class MainWindow(QtGui.QWidget): out.writelines('\n') out.writelines('.ends ' + self.projName) + print("=============================================================") print("The subcircuit has been written in " + self.projName + ".sub") diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index e9b5822a..9af7cbfb 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -7,8 +7,8 @@ import os class Model(QtGui.QWidget): """ - This class creates Model Tab of KicadtoNgspice window. - The widgets are created dynamically in the Model Tab. + - This class creates Model Tab of KicadtoNgspice window. + The widgets are created dynamically in the Model Tab. """ def __init__(self, schematicInfo, modelList, clarg1): @@ -62,7 +62,7 @@ class Model(QtGui.QWidget): # print "Key : ",key # print "Value : ",value # Check if value is iterable - if hasattr(value, '__iter__'): + if hasattr(value, '__iter__') and type(value) is not str: # For tag having vector value temp_tag = [] for item in value: @@ -78,7 +78,7 @@ class Model(QtGui.QWidget): try: for mod in json_data["model"]: if json_data["model"][mod]["type"] ==\ - line[2] and mod == line[3]: + line[2] and mod == line[3]: self.obj_trac.model_entry_var [self.nextcount].setText( str(list( @@ -96,17 +96,18 @@ class Model(QtGui.QWidget): else: paramLabel = QtGui.QLabel(value) modelgrid.addWidget(paramLabel, self.nextrow, 0) - self.obj_trac.model_entry_var - [self.nextcount] = QtGui.QLineEdit( + self.obj_trac.model_entry_var[self.nextcount] = ( + QtGui.QLineEdit() ) modelgrid.addWidget( - self.obj_trac.model_entry_var - [self.nextcount], self.nextrow, 1) + self.obj_trac.model_entry_var[self.nextcount], + self.nextrow, 1 + ) try: for mod in json_data["model"]: if json_data["model"][mod]["type"] ==\ - line[2] and mod == line[3]: + line[2] and mod == line[3]: self.obj_trac.model_entry_var [self.nextcount].setText( str(list(json_data diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index 63847761..bd1b45dc 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -13,15 +13,29 @@ class PrcocessNetlist: def __init__(self): pass + """ + - Read the circuit file and return splitted lines + """ + def readNetlist(self, filename): f = open(filename) data = f.read() f.close() + print("=============================================================") + print("readNetList called, from Processing") + print("=============================================================") + print("NETLIST", data.splitlines()) + print("=============================================================") return data.splitlines() + """ + - Read Parameter information and store it into dictionary + - kicadNetlis is the .cir file content + """ + def readParamInfo(self, kicadNetlis): - """Read Parameter information and store it into dictionary""" param = {} + print("=========================KICADNETLIST========================") for eachline in kicadNetlis: print(eachline) eachline = eachline.strip() @@ -32,10 +46,18 @@ class PrcocessNetlist: for i in range(1, len(words), 1): paramList = words[i].split('=') param[paramList[0]] = paramList[1] + print("=============================================================") + print("readParamInfo called, from Processing") + print("=============================================================") + print("PARAM", param) + print("=============================================================") return param + """ + - Preprocess netlist (replace parameters) + """ + def preprocessNetlist(self, kicadNetlis, param): - """Preprocess netlist (replace parameters)""" netlist = [] for eachline in kicadNetlis: # Remove leading and trailing blanks spaces from line @@ -66,6 +88,12 @@ class PrcocessNetlist: # Copy information line infoline = netlist[0] netlist.remove(netlist[0]) + print("=============================================================") + print("preprocessNetList called, from Processing") + print("=============================================================") + print("NETLIST", netlist) + print("INFOLINE", infoline) + print("=============================================================") return netlist, infoline def separateNetlistInfo(self, netlist): @@ -78,14 +106,24 @@ class PrcocessNetlist: optionInfo.append(eachline) else: schematicInfo.append(eachline) + print("=============================================================") + print("separateNetlistInfo called, from Processing") + print("=============================================================") + print("OPTIONINFO", optionInfo) + print("SCHEMATICINFO", schematicInfo) + print("=============================================================") return optionInfo, schematicInfo + """ + - Insert Special source parameter + - As per the parameters passed create source list + """ + def insertSpecialSourceParam(self, schematicInfo, sourcelist): - # Inser Special source parameter schematicInfo1 = [] - + print("=============================================================") print("Reading schematic info for source details") - + print("=============================================================") for compline in schematicInfo: words = compline.split() compName = words[0] @@ -171,10 +209,17 @@ class PrcocessNetlist: schematicInfo = schematicInfo + schematicInfo1 print("Source List : ", sourcelist) # print schematicInfo + print("=============================================================") + print("insertSpecialSourceParam called, from Processing") + print("=============================================================") + print("SCHEMATICINFO", schematicInfo) + print("SOURCELIST", sourcelist) + print("=============================================================") return schematicInfo, sourcelist def convertICintoBasicBlocks( self, schematicInfo, outputOption, modelList, plotText): + print("=============================================================") print("Reading Schematic info for Model") # Insert details of Ngspice model unknownModelList = [] @@ -228,6 +273,8 @@ class PrcocessNetlist: unknownModelList.append(compType) elif count == 1: try: + print("==========================================\ + ===========================") print( "Start Parsing Previous Values XML\ for ngspice model :", modelPath) @@ -265,7 +312,7 @@ class PrcocessNetlist: if 'default' in item.attrib: paramDict[item.tag + ":" + item.attrib['default']] \ - = temp_list + = temp_list else: paramDict[item.tag] = item.text @@ -273,7 +320,7 @@ class PrcocessNetlist: if 'default' in item.attrib: paramDict[item.tag + ":" + item.attrib['default']]\ - = item.text + = item.text else: paramDict[item.tag] = item.text @@ -288,6 +335,8 @@ class PrcocessNetlist: modelLine += compName else: + print("=====================================\ + ================================") print("Split Details :", splitDetail) modelLine = "a" + str(k) + " " vectorDetail = splitDetail.split(':') @@ -302,7 +351,7 @@ class PrcocessNetlist: for i in range(0, int( item.split("-")[0])): modelLine += words[pos] +\ - " " + " " pos += 1 modelLine += ") " else: @@ -310,7 +359,7 @@ class PrcocessNetlist: for i in range(0, int( item.split("-")[0])): modelLine += words[pos] + \ - " " + " " pos += 1 modelLine += "] " elif item.split("-")[1] == 'NV': @@ -436,16 +485,27 @@ class PrcocessNetlist: else: schematicInfo.insert(index, "* " + compline) - + print("=====================================================") print( "UnknownModelList Used in the Schematic", unknownModelList) + print("=====================================================") print( "Multiple Model XML file with same name ", multipleModelList) + print("=====================================================") print("Model List Details : ", modelList) - + print("=============================================================") + print("convertICIntoBasicBlocks called, from Processing") + print("=============================================================") + print("SCHEMATICINFO", schematicInfo) + print("OUTPUTOPTION", outputOption) + print("MODELLIST", modelList) + print("UNKOWNMODELLIST", unknownModelList) + print("MULTIPLEMODELLIST", multipleModelList) + print("PLOTTEST", plotText) + print("=============================================================") return ( schematicInfo, outputOption, modelList, unknownModelList, multipleModelList, plotText - ) + ) diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py index 8649ce93..d8e39af4 100644 --- a/src/kicadtoNgspice/Source.py +++ b/src/kicadtoNgspice/Source.py @@ -25,11 +25,23 @@ class Source(QtGui.QWidget): # Creating Source Widget self.createSourceWidget(sourcelist, sourcelisttrack) + """ + - This function dynamically create source widget in the + Source tab of KicadtoNgSpice window + - Depending on the type of source, ac, dc, sine, pwl, etc... + source tab is created + - All the entry fields, are kept into the entry_var + tracked by self.count + - Finally after each of the sourcelist is mapped to its input component + we move to adding these to the track widget + - Also check if any default values present from previous analysis and add + them by default + """ + def createSourceWidget(self, sourcelist, sourcelisttrack): - """ - This function dynamically create source widget in the - Source tab of KicadtoNgSpice window - """ + print("============================================================") + print("SOURCELISTTRACK", sourcelisttrack) + print("============================================================") kicadFile = self.clarg1 (projpath, filename) = os.path.split(kicadFile) project_name = os.path.basename(projpath) @@ -328,8 +340,8 @@ class Source(QtGui.QWidget): list( json_data["source"][key] ["values"][it - 4].values())[0] - ) - ) + ) + ) except BaseException: pass @@ -353,6 +365,7 @@ class Source(QtGui.QWidget): else: print("No source is present in your circuit") + print("============================================================") # This is used to keep the track of dynamically created widget self.obj_track.sourcelisttrack["ITEMS"] = sourcelisttrack self.obj_track.source_entry_var["ITEMS"] = self.entry_var diff --git a/src/kicadtoNgspice/TrackWidget.py b/src/kicadtoNgspice/TrackWidget.py index dcf85dca..ec5c2c81 100644 --- a/src/kicadtoNgspice/TrackWidget.py +++ b/src/kicadtoNgspice/TrackWidget.py @@ -1,6 +1,12 @@ class TrackWidget: """ - This Class track the dynamically created widget of KicadtoNgSpice Window. + - This Class track the dynamically created widget of KicadtoNgSpice Window. + - Tracks using dictionary and lists ==> + - - Sources + - - Parameters + - - References + - - Model Details + - - ... etc """ # Track widget list for Source details sourcelisttrack = {"ITEMS": "None"} diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index 464ad17f..0d5ff0cf 100644 --- a/src/modelEditor/ModelEditor.py +++ b/src/modelEditor/ModelEditor.py @@ -37,12 +37,8 @@ class ModelEditorclass(QtGui.QWidget): self.splitter = QtGui.QSplitter() self.grid = QtGui.QGridLayout() self.splitter.setOrientation(QtCore.Qt.Vertical) -<<<<<<< HEAD - -======= # Initialise the table view ->>>>>>> 357fd69... pep8 done, model editor documentation self.modeltable = QtGui.QTableWidget() self.newbtn = QtGui.QPushButton('New') @@ -112,18 +108,12 @@ class ModelEditorclass(QtGui.QWidget): self.grid.addWidget(self.magnetic, 8, 1) self.setLayout(self.grid) self.show() -<<<<<<< HEAD - - '''To create New Model file ''' - -======= ''' - To create New Model file - Change state of other buttons accordingly, ex. enable diode, bjt, ... - Validate filename created, to check if one already exists ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def opennew(self): self.addbtn.setHidden(True) try: @@ -146,15 +136,7 @@ class ModelEditorclass(QtGui.QWidget): self.modelname = (str(text)) else: pass -<<<<<<< HEAD - - self.validation(text) - - def diode_click(self): - self.openfiletype('Diode') - self.types.setHidden(True) - -======= + # Validate if the file created exists already or not # Show error accordingly self.validation(text) @@ -176,7 +158,6 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def bjt_click(self): self.types.setHidden(False) self.types.clear() @@ -209,9 +190,6 @@ class ModelEditorclass(QtGui.QWidget): filetype = str(self.types.currentText()) self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) -<<<<<<< HEAD - -======= ''' - Set states for other elements @@ -221,7 +199,6 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def jfet_click(self): self.types.setHidden(False) self.types.clear() @@ -230,10 +207,8 @@ class ModelEditorclass(QtGui.QWidget): filetype = str(self.types.currentText()) self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) -<<<<<<< HEAD - -======= - ''' + + ''' - Set states for other elements - Initialise types combo box elements - - N-IGBT @@ -241,7 +216,6 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def igbt_click(self): self.types.setHidden(False) self.types.clear() @@ -250,9 +224,7 @@ class ModelEditorclass(QtGui.QWidget): filetype = str(self.types.currentText()) self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) -<<<<<<< HEAD - -======= + ''' - Set states for other elements - Initialise types combo box elements @@ -260,7 +232,6 @@ class ModelEditorclass(QtGui.QWidget): - Add an event listener for type-selection event - No types here, only one view ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def magnetic_click(self): self.openfiletype('Magnetic Core') self.types.setHidden(True) @@ -331,9 +302,6 @@ class ModelEditorclass(QtGui.QWidget): self.createtable(path) else: pass -<<<<<<< HEAD - -======= ''' - When `Edit` button clicked, this function called @@ -343,7 +311,6 @@ class ModelEditorclass(QtGui.QWidget): - Create table for the selected .lib file using `self.createtable(path)` - Handle exception of no file selected ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def openedit(self): os.chdir(self.savepathtest) self.newflag = 0 @@ -366,9 +333,6 @@ class ModelEditorclass(QtGui.QWidget): except BaseException: print("No File selected for edit") pass -<<<<<<< HEAD - -======= ''' - Set states for other components @@ -381,7 +345,6 @@ class ModelEditorclass(QtGui.QWidget): - Show the extracted data in QTableWidget - Can edit QTable inplace, connect `edit_modeltable` function for editing ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def createtable(self, modelfile): self.savebtn.setDisabled(False) self.addbtn.setHidden(False) @@ -425,9 +388,6 @@ class ModelEditorclass(QtGui.QWidget): QtCore.QString("Parameters;Values").split(";")) self.modeltable.show() self.modeltable.itemChanged.connect(self.edit_modeltable) -<<<<<<< HEAD - -======= ''' - Called when editing model inplace in QTableWidget @@ -436,7 +396,6 @@ class ModelEditorclass(QtGui.QWidget): - Edit name and value as per needed - Add the val name pair in the modeldict ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def edit_modeltable(self): self.savebtn.setDisabled(False) try: @@ -448,8 +407,6 @@ class ModelEditorclass(QtGui.QWidget): self.modeldict[val] = name except BaseException: pass -<<<<<<< HEAD -======= ''' - Called when `Add` button clicked beside QTableWidget @@ -458,7 +415,6 @@ class ModelEditorclass(QtGui.QWidget): - Accordingly add parameter and value in modeldict as well as table - text1 => parameter, text2 => value ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def addparameters(self): text1, ok = QtGui.QInputDialog.getText( self, 'Parameter', 'Enter Parameter') @@ -483,15 +439,12 @@ class ModelEditorclass(QtGui.QWidget): pass else: pass -<<<<<<< HEAD -======= ''' - Called when save functon clicked - If new file created, call `createXML` file - Else call `savethefile` ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def savemodelfile(self): if self.newflag == 1: self.createXML(self.model_name) @@ -703,9 +656,6 @@ class ModelEditorclass(QtGui.QWidget): remove_item = self.modeltable.item(index.row(), 0).text() self.modeltable.removeRow(index.row()) del self.modeldict[str(remove_item)] -<<<<<<< HEAD - -======= ''' - Called when upload button clicked @@ -716,7 +666,6 @@ class ModelEditorclass(QtGui.QWidget): - Save it in `User Libraries` with the given name, and input from uploaded file ''' ->>>>>>> 357fd69... pep8 done, model editor documentation def converttoxml(self): os.chdir(self.savepathtest) self.addbtn.setHidden(True) diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index 695bfa50..def1d4e9 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -31,7 +31,7 @@ class NgspiceWidget(QtGui.QWidget): ( self.obj_appconfig.proc_dict [self.obj_appconfig.current_project['ProjectName']].append( - self.process.pid()) + self.process.pid()) ) # For Windows OS diff --git a/src/ngspiceSimulation/pythonPlotting.py b/src/ngspiceSimulation/pythonPlotting.py index 848d9d54..7cff21ef 100644 --- a/src/ngspiceSimulation/pythonPlotting.py +++ b/src/ngspiceSimulation/pythonPlotting.py @@ -175,10 +175,10 @@ class plotWindow(QtGui.QMainWindow): "<font color='indigo'>List of Branches:</font>") self.funcLabel.setText("<font color='indigo'>Function:</font>") self.funcName.setText( - "<font color='indigo'>Standard functions</font>\ + "<font color='indigo'>Standard functions</font>\ <br><br>Addition:<br>Subtraction:<br>\ Multiplication:<br>Division:<br>Comparison:" - ) + ) self.funcExample.setText( "\n\nNode1 + Node2\nNode1 - Node2\nNode1 * Node2\nNode1 / Node2\ \nNode1 vs Node2") @@ -507,7 +507,12 @@ class plotWindow(QtGui.QMainWindow): loc_x += 50 loc_y += 50 # Adding object of multimeter to dictionary - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append(self.obj[j]) + ( + self.obj_appconfig. + dock_dict[ + self.obj_appconfig.current_project['ProjectName']]. + append(self.obj[j]) + ) if boxCheck == 0: QtGui.QMessageBox.about( diff --git a/src/ngspicetoModelica/ModelicaUI.py b/src/ngspicetoModelica/ModelicaUI.py index 1d860fb7..e523da8b 100644 --- a/src/ngspicetoModelica/ModelicaUI.py +++ b/src/ngspicetoModelica/ModelicaUI.py @@ -52,7 +52,7 @@ class OpenModelicaEditor(QtGui.QWidget): def callConverter(self): try: - self.cmd1 = "python3 ../ngspicetoModelica/NgspicetoModelica.py " + \ + self.cmd1 = "python3 ../ngspicetoModelica/NgspicetoModelica.py" + \ self.ngspiceNetlist + ' ' + self.map_json # self.obj_workThread1 = Worker.WorkerThread(self.cmd1) # self.obj_workThread1.start() @@ -72,7 +72,7 @@ class OpenModelicaEditor(QtGui.QWidget): self.obj_appconfig.print_info( "Ngspice netlist successfully converted to OpenModelica" + "netlist" - ) + ) self.msg.exec_() else: diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py index 007c5a74..3efee506 100644 --- a/src/ngspicetoModelica/NgspicetoModelica.py +++ b/src/ngspicetoModelica/NgspicetoModelica.py @@ -421,11 +421,11 @@ class NgMoConverter: # If parameter is not mapped then it will just pass try: actualModelicaParam = ( - self.mappingData["Devices"] - [deviceName] - ["mapping"] - [key] - ) + self.mappingData["Devices"] + [deviceName] + ["mapping"] + [key] + ) tempstatList.append( actualModelicaParam + "=" + @@ -473,13 +473,13 @@ class NgMoConverter: if trans == 'npn': start = ( self.mappingData["Devices"][deviceName]["import"] - ) + ".NPN" + ) + ".NPN" elif trans == 'pnp': start = self.mappingData( - ["Devices"] - [deviceName] - ["import"] - ) + ".PNP" + ["Devices"] + [deviceName] + ["import"] + ) + ".PNP" else: print("Transistor " + str(trans) + " Not found") sys.exit(1) @@ -501,12 +501,12 @@ class NgMoConverter: userDeviceParamList.append(str("Vak")) else: actualModelicaParam = ( - self.mappingData - ["Devices"] - [deviceName] - ["mapping"] - [key] - ) + self.mappingData + ["Devices"] + [deviceName] + ["mapping"] + [key] + ) tempstatList.append( actualModelicaParam + "=" + @@ -519,21 +519,21 @@ class NgMoConverter: pass # Running loop over default parameter of OpenModelica for default in ( - self.mappingData - ["Devices"] - [deviceName] - ["default"] - ): + self.mappingData + ["Devices"] + [deviceName] + ["default"] + ): if default in userDeviceParamList: continue else: defaultValue = ( - self.mappingData - ["Devices"] - [deviceName] - ["default"] - [default] - ) + self.mappingData + ["Devices"] + [deviceName] + ["default"] + [default] + ) tempstatList.append( default + "=" + self.getUnitVal(defaultValue) + " ") @@ -563,18 +563,18 @@ class NgMoConverter: if trans == 'nmos': start = ( - self.mappingData - ["Devices"] - [deviceName] - ["import"] - ) + ".Mn" + self.mappingData + ["Devices"] + [deviceName] + ["import"] + ) + ".Mn" elif trans == 'pmos': start = ( - self.mappingData - ["Devices"] - [deviceName] - ["import"] - ) + ".Mp" + self.mappingData + ["Devices"] + [deviceName] + ["import"] + ) + ".Mp" else: print("MOSFET " + str(trans) + " not found") sys.exit(1) @@ -597,12 +597,12 @@ class NgMoConverter: userDeviceParamList.append(str("U0")) else: actualModelicaParam = ( - self.mappingData - ["Devices"] - [deviceName] - ["mapping"] - [key] - ) + self.mappingData + ["Devices"] + [deviceName] + ["mapping"] + [key] + ) tempstatList.append( actualModelicaParam + "=" + @@ -616,24 +616,24 @@ class NgMoConverter: # Running loop over default parameter of OpenModelica for default in ( - self.mappingData - ["Devices"] - [deviceName] - ["default"] - ): + self.mappingData + ["Devices"] + [deviceName] + ["default"] + ): if default in userDeviceParamList: continue else: defaultValue = ( - self.mappingData - ["Devices"] - [deviceName] - ["default"] - [default] - ) + self.mappingData + ["Devices"] + [deviceName] + ["default"] + [default] + ) tempstatList.append( default + "=" + self.getUnitVal(defaultValue) + " " - ) + ) # Adding LEVEL(This is constant not the device level) tempstatList.append("Level=1" + " ") @@ -697,11 +697,11 @@ class NgMoConverter: # If parameter is not mapped then it will just pass try: actualModelicaParam = self.mappingData( - ["Devices"] - [deviceName] - ["mapping"] - [key] - ) + ["Devices"] + [deviceName] + ["mapping"] + [key] + ) tempstatList.append( actualModelicaParam + "=" + @@ -713,24 +713,24 @@ class NgMoConverter: pass # Running loop over default parameter of OpenModelica for default in ( - self.mappingData - ["Devices"] - [deviceName] - ["default"] - ): + self.mappingData + ["Devices"] + [deviceName] + ["default"] + ): if default in userDeviceParamList: continue else: defaultValue = ( - self.mappingData - ["Devices"] - [deviceName] - ["default"] - [default] - ) + self.mappingData + ["Devices"] + [deviceName] + ["default"] + [default] + ) tempstatList.append( default + "=" + self.getUnitVal(defaultValue) + " " - ) + ) stat += ",".join(str(item) for item in tempstatList) + "));" modelicaCompInit.append(stat) @@ -779,12 +779,12 @@ class NgMoConverter: # If parameter is not mapped then it will just pass try: actualModelicaParam = ( - self.mappingData - ["Models"] - [actualModelName] - ["mapping"] - [key] - ) + self.mappingData + ["Models"] + [actualModelName] + ["mapping"] + [key] + ) tempstatList.append( actualModelicaParam + "=" + @@ -797,24 +797,24 @@ class NgMoConverter: # Running loop over default parameter of OpenModelica for default in ( - self.mappingData - ["Models"] - [actualModelName] - ["default"] - ): + self.mappingData + ["Models"] + [actualModelName] + ["default"] + ): if default in userModelParamList: continue else: defaultValue = ( - self.mappingData - ["Models"] - [actualModelName] - ["default"] - [default] - ) + self.mappingData + ["Models"] + [actualModelName] + ["default"] + [default] + ) tempstatList.append( default + "=" + self.getUnitVal(defaultValue) + " " - ) + ) stat += ",".join(str(item) for item in tempstatList) + ");" modelicaCompInit.append(stat) @@ -1180,7 +1180,7 @@ class NgMoConverter: dir_name, subtransInfo, subInbuiltModelDict - ) + ) # print "modelicaSubCompInit------------>",modelicaSubCompInit # print "numNodesSubsub---------------------->",numNodesSubsub modelicaSubParamNew = self.getSubParamLine( @@ -1195,7 +1195,7 @@ class NgMoConverter: nodeDicSub, numNodesSubsub, subcktName - ) + ) # print "connSubInfo----------------->",connSubInfo newname = basename.split('.') newfilename = newname[0] @@ -1242,21 +1242,21 @@ class NgMoConverter: out.close() return ( - data, - subOptionInfo, - subSchemInfo, - subModel, - subModelInfo, - subsubName, - subParamInfo, - modelicaSubCompInit, - modelicaSubParam, - nodeSubInterface, - nodeSub, - nodeDicSub, - pinInitSub, - connSubInfo - ) + data, + subOptionInfo, + subSchemInfo, + subModel, + subModelInfo, + subsubName, + subParamInfo, + modelicaSubCompInit, + modelicaSubParam, + nodeSubInterface, + nodeSub, + nodeDicSub, + pinInitSub, + connSubInfo + ) def main(args): @@ -1347,7 +1347,7 @@ def main(args): dir_name, transInfo, inbuiltModelDict - ) + ) # print "ModelicaComponents # : modelicaCompInit----------->",modelicaCompInit # print "SubcktNumNodes @@ -1365,7 +1365,7 @@ def main(args): nodeSubInterface, nodeSub, nodeDicSub, pinInitSub, connSubInfo = ( obj_NgMoConverter.procesSubckt( subcktName, numNodesSub, dir_name - ) + ) ) # Adding 'numNodesSub' by Fahim # Creating Final Output file diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index 8b20112e..9aaac46d 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -53,6 +53,7 @@ class Kicad: @return """ + def openSchematic(self): print("Function : Open Kicad Schematic") self.projDir = self.obj_appconfig.current_project["ProjectName"] @@ -158,6 +159,7 @@ class Kicad: @return """ + def openKicadToNgspice(self): """ This function create command to call kicad to Ngspice converter. diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index b0cfb5a1..9fcac9a2 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -42,6 +42,7 @@ class Validation: True => If the folder contains the projName.proj file False => If the folder doesn't contain projName.proj file """ + def __init__(self): pass @@ -69,6 +70,7 @@ class Validation: :"CHECKNAME" => If space is there in name :"VALID" => If valid project name given """ + def validateNewproj(self, projDir): """ This Project Validate New Project Information @@ -97,6 +99,7 @@ class Validation: True False """ + def validateKicad(self, projDir): """ This function validate if Kicad components are present @@ -118,6 +121,7 @@ class Validation: True False """ + def validateCir(self, projDir): """ This function checks if ".cir" file is present. diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index 4cfeefe9..f40fd724 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -52,6 +52,7 @@ class WorkerThread(QtCore.QThread): @return None """ + def __del__(self): self.wait() @@ -65,6 +66,7 @@ class WorkerThread(QtCore.QThread): @return None """ + def run(self): print("Worker Thread Calling Command :", self.args) self.call_system(self.args) @@ -80,6 +82,7 @@ class WorkerThread(QtCore.QThread): be executed in different child processes (see subproces.Popen()) """ + def call_system(self, command): procThread = Appconfig() proc = subprocess.Popen(command.split()) diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index ef2440d7..c8cd4078 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -45,6 +45,7 @@ class NewProjectInfo(QtGui.QWidget): :dirs => The directories inside the project folder :filelist => The files inside the project folder """ + def createProject(self, projName): """ This function create Project related directories and files diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index d12f4d8a..100cf12c 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -43,6 +43,7 @@ class OpenProjectInfo(QtGui.QWidget): :dirs => The directories inside the project folder :filelist => The files inside the project folder """ + def body(self): self.obj_Appconfig = Appconfig() self.openDir = self.obj_Appconfig.default_workspace["workspace"] |