diff options
author | maddy-2 | 2019-05-27 12:55:18 +0530 |
---|---|---|
committer | nilshah98 | 2019-06-07 11:03:16 +0530 |
commit | 90d656da8cc6dfb076fa2b8ec9764e9bf391bda7 (patch) | |
tree | 22ce01b5ca69ae407f99b63439dad27600d40520 /src | |
parent | 32132ebfcc90e993acc3a87c4017ef0b00bcd890 (diff) | |
download | eSim-90d656da8cc6dfb076fa2b8ec9764e9bf391bda7.tar.gz eSim-90d656da8cc6dfb076fa2b8ec9764e9bf391bda7.tar.bz2 eSim-90d656da8cc6dfb076fa2b8ec9764e9bf391bda7.zip |
kicadtoNgspice made pep8 compliant
Diffstat (limited to 'src')
-rw-r--r-- | src/kicadtoNgspice/Analysis.py | 24 | ||||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 219 | ||||
-rw-r--r-- | src/kicadtoNgspice/DeviceModel.py | 79 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 104 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 53 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 121 | ||||
-rw-r--r-- | src/kicadtoNgspice/Source.py | 103 | ||||
-rw-r--r-- | src/kicadtoNgspice/SubcircuitTab.py | 22 |
8 files changed, 464 insertions, 261 deletions
diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py index fde9a3e3..cde39f8f 100644 --- a/src/kicadtoNgspice/Analysis.py +++ b/src/kicadtoNgspice/Analysis.py @@ -2,7 +2,7 @@ from PyQt4 import QtGui from . import TrackWidget import os -#from xml.etree import ElementTree as ET +# from xml.etree import ElementTree as ET import json @@ -234,8 +234,10 @@ class Analysis(QtGui.QWidget): # CSS self.acbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: \ + 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: \ + 0 3px 0 3px; } \ ") if check: try: @@ -503,16 +505,18 @@ class Analysis(QtGui.QWidget): # QtCore.QObject.connect(check,SIGNAL("stateChanged()"),check,SLOT("checkedSlot")) self.check.stateChanged.connect(self.setflag) - #self.flagcheck = 1 - #self.flagcheck= 2 + # self.flagcheck = 1 + # self.flagcheck= 2 self.dcgrid.addWidget(self.check, 9, 1, 9, 2) self.track_obj.DC_entry_var["ITEMS"] = self.dc_entry_var self.track_obj.DC_Parameter["ITEMS"] = self.dc_parameter # CSS self.dcbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: \ + 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") if check: try: @@ -687,8 +691,10 @@ class Analysis(QtGui.QWidget): # CSS self.trbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") if check: try: diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 924f94fa..38234fed 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -8,7 +8,8 @@ from xml.etree import ElementTree as ET class Convert: """ - This class has all the necessary function required to convert kicad netlist to ngspice netlist. + This class has all the necessary function required to convert + kicad netlist to ngspice netlist. """ def __init__(self, sourcelisttrack, source_entry_var, @@ -36,16 +37,24 @@ class Convert: self.end = compline[3] vo_val = str(self.entry_var[self.start].text()) if len( str(self.entry_var[self.start].text())) > 0 else '0' - va_val = str(self.entry_var[self.start + 1].text()) if len( - str(self.entry_var[self.start + 1].text())) > 0 else '0' - freq_val = str(self.entry_var[self.start + 2].text()) if len( - str(self.entry_var[self.start + 2].text())) > 0 else '0' + va_val = str( + self.entry_var[self.start + 1].text() + ) if len( + str(self.entry_var[self.start + 1].text())) \ + > 0 else '0' + freq_val = str(self.entry_var[self.start + 2].text()) \ + if len( + str(self.entry_var[self.start + 2].text())) > \ + 0 else '0' td_val = str(self.entry_var[self.start + 3].text()) if len( - str(self.entry_var[self.start + 3].text())) > 0 else '0' + str(self.entry_var[self.start + 3].text())) > \ + 0 else '0' theta_val = str(self.entry_var[self.end].text()) if len( str(self.entry_var[self.end].text())) > 0 else '0' self.addline = self.addline.partition( - '(')[0] + "(" + vo_val + " " + va_val + " " + freq_val + " " + td_val + " " + theta_val + ")" + '(')[0] + "(" + vo_val + " " + va_val + " " +\ + freq_val + " " + td_val + " " +\ + theta_val + ")" self.sourcelistvalue.append([self.index, self.addline]) except BaseException: print( @@ -59,20 +68,28 @@ class Convert: v1_val = str(self.entry_var[self.start].text()) if len( str(self.entry_var[self.start].text())) > 0 else '0' v2_val = str(self.entry_var[self.start + 1].text()) if len( - str(self.entry_var[self.start + 1].text())) > 0 else '0' - td_val = str(self.entry_var[self.start + 2].text()) if len( - str(self.entry_var[self.start + 2].text())) > 0 else '0' + str(self.entry_var[self.start + 1].text())) > \ + 0 else '0' + td_val = str(self.entry_var[self.start + 2].text()) \ + if len( + str(self.entry_var[self.start + 2].text())) > \ + 0 else '0' tr_val = str(self.entry_var[self.start + 3].text()) if len( - str(self.entry_var[self.start + 3].text())) > 0 else '0' + str(self.entry_var[self.start + 3].text())) > \ + 0 else '0' tf_val = str(self.entry_var[self.start + 4].text()) if len( - str(self.entry_var[self.start + 4].text())) > 0 else '0' + str(self.entry_var[self.start + 4].text())) > \ + 0 else '0' pw_val = str(self.entry_var[self.start + 5].text()) if len( - str(self.entry_var[self.start + 5].text())) > 0 else '0' + str(self.entry_var[self.start + 5].text())) > \ + 0 else '0' tp_val = str(self.entry_var[self.end].text()) if len( str(self.entry_var[self.end].text())) > 0 else '0' self.addline = self.addline.partition( - '(')[0] + "(" + v1_val + " " + v2_val + " " + td_val + " " + tr_val + " " + tf_val + " " + pw_val + " " + tp_val + ")" + '(')[0] + "(" + v1_val + " " + v2_val + " " +\ + td_val + " " + tr_val + " " + tf_val + " " +\ + pw_val + " " + tp_val + ")" self.sourcelistvalue.append([self.index, self.addline]) except BaseException: print( @@ -100,7 +117,8 @@ class Convert: va_val = str(self.entry_var[self.start].text()) if len( str(self.entry_var[self.start].text())) > 0 else '0' ph_val = str(self.entry_var[self.start + 1].text()) if len( - str(self.entry_var[self.start + 1].text())) > 0 else '0' + str(self.entry_var[self.start + 1].text())) > \ + 0 else '0' self.addline = ' '.join(self.addline.split()) self.addline = self.addline.partition( 'ac')[0] + " " + 'ac' + " " + va_val + " " + ph_val @@ -132,18 +150,27 @@ class Convert: v1_val = str(self.entry_var[self.start].text()) if len( str(self.entry_var[self.start].text())) > 0 else '0' v2_val = str(self.entry_var[self.start + 1].text()) if len( - str(self.entry_var[self.start + 1].text())) > 0 else '0' - td1_val = str(self.entry_var[self.start + 2].text()) if len( - str(self.entry_var[self.start + 2].text())) > 0 else '0' - tau1_val = str(self.entry_var[self.start + 3].text()) if len( - str(self.entry_var[self.start + 3].text())) > 0 else '0' - td2_val = str(self.entry_var[self.start + 4].text()) if len( - str(self.entry_var[self.start + 4].text())) > 0 else '0' + str(self.entry_var[self.start + 1].text())) > \ + 0 else '0' + td1_val = str(self.entry_var[self.start + 2].text()) \ + if len( + str(self.entry_var[self.start + 2].text())) > \ + 0 else '0' + tau1_val = str(self.entry_var[self.start + 3].text()) \ + if len( + str(self.entry_var[self.start + 3].text())) > \ + 0 else '0' + td2_val = str(self.entry_var[self.start + 4].text()) \ + if len( + str(self.entry_var[self.start + 4].text())) > \ + 0 else '0' tau2_val = str(self.entry_var[self.end].text()) if len( str(self.entry_var[self.end].text())) > 0 else '0' self.addline = self.addline.partition( - '(')[0] + "(" + v1_val + " " + v2_val + " " + td1_val + " " + tau1_val + " " + td2_val + " " + tau2_val + ")" + '(')[0] + "(" + v1_val + " " + v2_val + " " +\ + td1_val + " " + tau1_val + " " + td2_val +\ + " " + tau2_val + ")" self.sourcelistvalue.append([self.index, self.addline]) except BaseException: print( @@ -158,7 +185,8 @@ class Convert: return self.schematicInfo def analysisInsertor(self, ac_entry_var, dc_entry_var, tran_entry_var, - set_checkbox, ac_parameter, dc_parameter, tran_parameter, ac_type, op_check): + set_checkbox, ac_parameter, dc_parameter, + tran_parameter, ac_type, op_check): """ This function creates an analysis file in current project """ @@ -184,14 +212,15 @@ class Convert: ' ' + self.ac_type + ' ' + - str(self.defaultvalue(self.ac_entry_var[self.no + - 2].text())) + + str(self.defaultvalue( + self.ac_entry_var[self.no + 2].text())) + ' ' + - str(self.defaultvalue(self.ac_entry_var[self.no].text())) + + str(self.defaultvalue( + self.ac_entry_var[self.no].text())) + self.ac_parameter[self.no] + ' ' + - str(self.defaultvalue(self.ac_entry_var[self.no + - 1].text())) + + str(self.defaultvalue( + self.ac_entry_var[self.no + 1].text())) + self.ac_parameter[self.no + 1]) @@ -205,56 +234,75 @@ class Convert: ' ' + str(self.dc_entry_var[self.no].text()) + ' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 1].text())) + - self.converttosciform(self.dc_parameter[self.no]) + + str(self.defaultvalue( + self.dc_entry_var[self.no + + 1].text())) + + self.converttosciform( + self.dc_parameter[self.no]) + ' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 3].text())) + - self.converttosciform(self.dc_parameter[self.no + - 2]) + + str(self.defaultvalue( + self.dc_entry_var[self.no + + 3].text())) + + self.converttosciform( + self.dc_parameter[self.no + + 2]) + ' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 2].text())) + - self.converttosciform(self.dc_parameter[self.no + - 1])) + str(self.defaultvalue( + self.dc_entry_var[self.no + + 2].text())) + + self.converttosciform( + self.dc_parameter[self.no + + 1])) if self.dc_entry_var[self.no + 4].text(): self.writefile.write(' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 4].text())) + + str(self.defaultvalue( + self.dc_entry_var[self.no + + 4].text())) + ' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 5].text())) + - self.converttosciform(self.dc_parameter[self.no + - 3]) + + str(self.defaultvalue( + self.dc_entry_var[self.no + + 5].text())) + + self.converttosciform( + self.dc_parameter[self.no + + 3]) + ' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 7].text())) + - self.converttosciform(self.dc_parameter[self.no + - 5]) + + str(self.defaultvalue( + self.dc_entry_var[self.no + + 7].text())) + + self.converttosciform( + self.dc_parameter[self.no + + 5]) + ' ' + - str(self.defaultvalue(self.dc_entry_var[self.no + - 6].text())) + - self.converttosciform(self.dc_parameter[self.no + - 4])) + str(self.defaultvalue( + self.dc_entry_var[self.no + + 6].text())) + + self.converttosciform( + self.dc_parameter[self.no + + 4])) elif self.variable == 'TRAN': self.no = 0 self.writefile.write(".tran" + ' ' + - str(self.defaultvalue(self.tran_entry_var[self.no + - 1].text())) + - self.converttosciform(self.trans_parameter[self.no + - 1]) + + str(self.defaultvalue( + self.tran_entry_var[self.no + + 1].text())) + + self.converttosciform( + self.trans_parameter[self.no + + 1]) + ' ' + - str(self.defaultvalue(self.tran_entry_var[self.no + - 2].text())) + - self.converttosciform(self.trans_parameter[self.no + - 2]) + + str(self.defaultvalue( + self.tran_entry_var[self.no + + 2].text())) + + self.converttosciform( + self.trans_parameter[self.no + + 2]) + ' ' + - str(self.defaultvalue(self.tran_entry_var[self.no].text())) + - self.converttosciform(self.trans_parameter[self.no])) + str(self.defaultvalue( + self.tran_entry_var[self.no].text())) + + self.converttosciform( + self.trans_parameter[self.no])) else: pass @@ -278,7 +326,8 @@ class Convert: def defaultvalue(self, value): """ - This function select default value as 0 if Analysis widget do not hold any value. + This function select default value as 0 + if Analysis widget do not hold any value. """ self.value = value if self.value == '': @@ -299,11 +348,11 @@ class Convert: modelParamValue = [] for line in self.obj_track.modelTrack: - #print "Model Track :",line + # print "Model Track :",line if line[2] == 'transfo': try: start = line[7] - end = line[8] + # end = line[8] num_turns = str( self.obj_track.model_entry_var[start + 1].text()) @@ -319,7 +368,11 @@ class Convert: b_array = b_array + b1 + " " bh_array = h_array + " ] " + b_array + " ]" else: - bh_array = "H_array = [-1000 -500 -375 -250 -188 -125 -63 0 63 125 188 250 375 500 1000] B_array = [-3.13e-3 -2.63e-3 -2.33e-3 -1.93e-3 -1.5e-3 -6.25e-4 -2.5e-4 0 2.5e-4 6.25e-4 1.5e-3 1.93e-3 2.33e-3 2.63e-3 3.13e-3]" + bh_array = "H_array = [-1000 -500 -375 -250 -188 -125 \ + -63 0 63 125 188 250 375 500 \ + 1000] B_array = [-3.13e-3 -2.63e-3 -2.33e-3 -1.93e-3\ + -1.5e-3 -6.25e-4 -2.5e-4 0 2.5e-4 6.25e-4 \ + 1.5e-3 1.93e-3 2.33e-3 2.63e-3 3.13e-3]" area = str( self.obj_track.model_entry_var[start + 2].text()) length = str( @@ -354,7 +407,7 @@ class Convert: elif line[2] == 'ic': try: start = line[7] - end = line[8] + # end = line[8] for key, value in line[9].items(): initVal = str( self.obj_track.model_entry_var[value].text()) @@ -372,11 +425,11 @@ class Convert: else: try: start = line[7] - end = line[8] + # end = line[8] addmodelLine = ".model " + line[3] + " " + line[2] + "(" for key, value in line[9].items(): - #print "Tags: ",key - #print "Value: ",value + # print "Tags: ",key + # print "Value: ",value # Checking for default value and accordingly assign # param and default. if ':' in key: @@ -391,20 +444,24 @@ class Convert: addmodelLine += param + "=[" for lineVar in value: if str( - self.obj_track.model_entry_var[lineVar].text()) == "": + self.obj_track.model_entry_var + [lineVar].text()) == "": paramVal = default else: paramVal = str( - self.obj_track.model_entry_var[lineVar].text()) + self.obj_track.model_entry_var + [lineVar].text()) addmodelLine += paramVal + " " addmodelLine += "] " else: if str( - self.obj_track.model_entry_var[value].text()) == "": + self.obj_track.model_entry_var + [value].text()) == "": paramVal = default else: paramVal = str( - self.obj_track.model_entry_var[value].text()) + self.obj_track.model_entry_var + [value].text()) addmodelLine += param + "=" + paramVal + " " @@ -433,7 +490,8 @@ class Convert: (projpath, filename) = os.path.split(kicadFile) deviceLibList = self.obj_track.deviceModelTrack - deviceLine = {} # Key:Index, Value:with its updated line in the form of list + deviceLine = {} + # Key:Index, Value:with its updated line in the form of list includeLine = [] # All .include line list if not deviceLibList: @@ -457,7 +515,7 @@ class Convert: libname = tempStr[0] dimension = tempStr[1] # Replace last word with library name - #words[-1] = libname.split('.')[0] + # words[-1] = libname.split('.')[0] words[-1] = self.getRefrenceName(libname, libpath) # Appending Dimension of MOSFET words.append(dimension) @@ -474,7 +532,7 @@ class Convert: shutil.copy2(src, dst) else: # Replace last word with library name - #words[-1] = libname.split('.')[0] + # words[-1] = libname.split('.')[0] words[-1] = self.getRefrenceName(libname, libpath) deviceLine[index] = words includeLine.append(".include " + libname) @@ -507,7 +565,8 @@ class Convert: (projpath, filename) = os.path.split(kicadFile) subList = self.obj_track.subcircuitTrack - subLine = {} # Key:Index, Value:with its updated line in the form of list + subLine = {} + # Key:Index, Value:with its updated line in the form of list includeLine = [] # All .include line list if len(self.obj_track.subcircuitList) != len( diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index e94ee561..909756b5 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -1,6 +1,6 @@ from PyQt4 import QtGui import os -#from xml.etree import ElementTree as ET +# from xml.etree import ElementTree as ET import json from . import TrackWidget @@ -8,7 +8,8 @@ from . import TrackWidget class DeviceModel(QtGui.QWidget): """ This class creates Device Library Tab in KicadtoNgspice Window - It dynamically creates the widget for device like diode,mosfet,transistor and jfet. + It dynamically creates the widget for device like diode,mosfet, + transistor and jfet. """ def __init__(self, schematicInfo, clarg1): @@ -73,18 +74,21 @@ class DeviceModel(QtGui.QWidget): try: for key in json_data["deviceModel"]: if key[0] == eachline[0] and key[1] == eachline[1]: - #print "DEVICE MODEL MATCHING---",child.tag[0],child.tag[1],eachline[0],eachline[1] + # print "DEVICE MODEL MATCHING---",child.tag[0],\ + # child.tag[1],eachline[0],eachline[1] try: if os.path.exists( json_data["deviceModel"][key][0]): self.entry_var[self.count].setText( json_data["deviceModel"][key][0]) - path_name = json_data["deviceModel"][key][0] + path_name = json_data + ["deviceModel"][key][0] else: self.entry_var[self.count].setText("") except BaseException: print( - "Error when set text of device model transistor") + "Error when set text of device\ + model transistor") except BaseException: pass @@ -104,8 +108,10 @@ class DeviceModel(QtGui.QWidget): # CSS transbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(transbox) @@ -129,21 +135,24 @@ class DeviceModel(QtGui.QWidget): words[3]) self.entry_var[self.count] = QtGui.QLineEdit() self.entry_var[self.count].setText("") - #global path_name + # global path_name try: for key in json_data["deviceModel"]: if key[0] == eachline[0] and key[1] == eachline[1]: - #print "DEVICE MODEL MATCHING---",child.tag[0],child.tag[1],eachline[0],eachline[1] + # print "DEVICE MODEL MATCHING---",child.tag[0],\ + # child.tag[1],eachline[0],eachline[1] try: if os.path.exists( json_data["deviceModel"][key][0]): - path_name = json_data["deviceModel"][key][0] + path_name = json_data + ["deviceModel"][key][0] self.entry_var[self.count].setText( json_data["deviceModel"][key][0]) else: self.entry_var[self.count].setText("") except BaseException: - print("Error when set text of device model diode") + print("Error when set text of device\ + model diode") except BaseException: pass @@ -163,8 +172,10 @@ class DeviceModel(QtGui.QWidget): # CSS diodebox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(diodebox) @@ -188,21 +199,24 @@ class DeviceModel(QtGui.QWidget): words[4]) self.entry_var[self.count] = QtGui.QLineEdit() self.entry_var[self.count].setText("") - #global path_name + # global path_name try: for key in json_data["deviceModel"]: if key[0] == eachline[0] and key[1] == eachline[1]: - #print "DEVICE MODEL MATCHING---",child.tag[0],child.tag[1],eachline[0],eachline[1] + # print "DEVICE MODEL MATCHING---",child.tag[0],\ + # child.tag[1],eachline[0],eachline[1] try: if os.path.exists( json_data["deviceModel"][key][0]): self.entry_var[self.count].setText( json_data["deviceModel"][key][0]) - path_name = json_data["deviceModel"][key][0] + path_name = json_data + ["deviceModel"][key][0] else: self.entry_var[self.count].setText("") except BaseException: - print("Error when set text of Device Model JFET ") + print("Error when set text of Device\ + Model JFET ") except BaseException: pass @@ -222,8 +236,10 @@ class DeviceModel(QtGui.QWidget): # CSS jfetbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(jfetbox) @@ -282,7 +298,8 @@ class DeviceModel(QtGui.QWidget): self.count = self.count + 1 self.multifactorLable[self.count] = QtGui.QLabel( - "Enter multiplicative factor of MOSFET " + words[0] + "(default=1):") + "Enter multiplicative factor of MOSFET " + + words[0] + "(default=1):") mosfetgrid.addWidget( self.multifactorLable[self.count], self.row, 0) self.entry_var[self.count] = QtGui.QLineEdit() @@ -294,18 +311,20 @@ class DeviceModel(QtGui.QWidget): self.devicemodel_dict_end[words[0]] = self.count self.count = self.count + 1 mosfetbox.setLayout(mosfetgrid) - #global path_name + # global path_name try: for key in json_data["deviceModel"]: if key[0] == eachline[0] and key[1] == eachline[1]: - #print "DEVICE MODEL MATCHING---",child.tag[0],child.tag[1],eachline[0],eachline[1] + # print "DEVICE MODEL MATCHING---",child.tag[0],\ + # child.tag[1],eachline[0],eachline[1] while i <= end: self.entry_var[i].setText( json_data["deviceModel"][key][i - beg]) if (i - beg) == 0: if os.path.exists( json_data["deviceModel"][key][0]): - path_name = json_data["deviceModel"][key][0] + path_name = json_data + ["deviceModel"][key][0] else: self.entry_var[i].setText("") i = i + 1 @@ -313,8 +332,10 @@ class DeviceModel(QtGui.QWidget): pass # CSS mosfetbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") if self.entry_var[beg].text() == "": pass @@ -331,7 +352,7 @@ class DeviceModel(QtGui.QWidget): """ print("Calling Track Device Model Library funtion") sending_btn = self.sender() - #print "Object Called is ",sending_btn.objectName() + # print "Object Called is ",sending_btn.objectName() self.widgetObjCount = int(sending_btn.objectName()) self.libfile = str( @@ -340,7 +361,7 @@ class DeviceModel(QtGui.QWidget): "Open Library Directory", "../deviceModelLibrary", "*.lib")) - #print "Selected Library File :",self.libfile + # print "Selected Library File :",self.libfile # Setting Library to Text Edit Line self.entry_var[self.widgetObjCount].setText(self.libfile) @@ -370,11 +391,11 @@ class DeviceModel(QtGui.QWidget): This function is use to keep track of all Device Model widget """ print("Calling Track Library function Without Button") - #print "Object Called is ",sending_btn.objectName() + # print "Object Called is ",sending_btn.objectName() self.widgetObjCount = iter_value print("self.widgetObjCount-----", self.widgetObjCount) self.libfile = path_value - #print "Selected Library File :",self.libfile + # print "Selected Library File :",self.libfile # Setting Library to Text Edit Line self.entry_var[self.widgetObjCount].setText(self.libfile) diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index 9001830f..a8349396 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -1,4 +1,4 @@ -#========================================================================= +# ========================================================================= # # FILE: kicadtoNgspice.py # @@ -14,7 +14,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 04 March 2015 # REVISION: --- -#========================================================================= +# ========================================================================= import sys import os from PyQt4 import QtGui @@ -28,20 +28,20 @@ from . import Convert from . import TrackWidget import json -#from xml.etree import ElementTree as ET +# from xml.etree import ElementTree as ET 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". + The convert function takes all the value entered by user and create + a final netlist "*.cir.out". This final netlist is compatible with NgSpice. """ def __init__(self, clarg1, clarg2=None): QtGui.QWidget.__init__(self) - print("==================================") print("Kicad to Ngspice netlist converter ") print("==================================") @@ -77,7 +77,7 @@ class MainWindow(QtGui.QWidget): netlist, infoline = obj_proc.preprocessNetlist(kicadNetlist, param) print("Schematic Info after processing Kicad Netlist: ", netlist) - #print "INFOLINE",infoline + # print "INFOLINE",infoline # Separate option and schematic information optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist) @@ -92,19 +92,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, unknownModelList, + multipleModelList, plotText = obj_proc.convertICintoBasicBlocks( schematicInfo, outputOption, modelList, plotText) print("Model available in the Schematic :", modelList) """ - Checking if any unknown model is used in schematic which is not recognized by NgSpice. - Also if the two model of same name is present under modelParamXML directory + Checking if any unknown model is used in schematic which is not + recognized by NgSpice. + Also if the two model of same name is present under + modelParamXML directory """ if unknownModelList: print("Unknown Model List is : ", unknownModelList) @@ -116,7 +120,8 @@ class MainWindow(QtGui.QWidget): elif multipleModelList: self.msg = QtGui.QErrorMessage() - self.mcontent = "Look like you have duplicate model in modelParamXML directory " + \ + self.mcontent = "Look like you have duplicate model in \ + modelParamXML directory " + \ ', '.join(multipleModelList[0]) self.msg.showMessage(self.mcontent) self.msg.setWindowTitle("Multiple Models") @@ -148,19 +153,19 @@ class MainWindow(QtGui.QWidget): self.analysisTab = QtGui.QScrollArea() obj_analysis = Analysis.Analysis(self.clarg1) self.analysisTab.setWidget(obj_analysis) - #self.analysisTabLayout = QtGui.QVBoxLayout(self.analysisTab.widget()) + # self.analysisTabLayout = QtGui.QVBoxLayout(self.analysisTab.widget()) self.analysisTab.setWidgetResizable(True) global obj_source self.sourceTab = QtGui.QScrollArea() obj_source = Source.Source(sourcelist, sourcelisttrack, self.clarg1) self.sourceTab.setWidget(obj_source) - #self.sourceTabLayout = QtGui.QVBoxLayout(self.sourceTab.widget()) + # self.sourceTabLayout = QtGui.QVBoxLayout(self.sourceTab.widget()) self.sourceTab.setWidgetResizable(True) global obj_model self.modelTab = QtGui.QScrollArea() obj_model = Model.Model(schematicInfo, modelList, self.clarg1) self.modelTab.setWidget(obj_model) - #self.modelTabLayout = QtGui.QVBoxLayout(self.modelTab.widget()) + # self.modelTabLayout = QtGui.QVBoxLayout(self.modelTab.widget()) self.modelTab.setWidgetResizable(True) global obj_devicemodel self.deviceModelTab = QtGui.QScrollArea() @@ -236,8 +241,10 @@ class MainWindow(QtGui.QWidget): obj_analysis.ac_entry_var[1].text()) json_data["analysis"]["ac"]["No. of points"] = str( obj_analysis.ac_entry_var[2].text()) - json_data["analysis"]["ac"]["Start Fre Combo"] = obj_analysis.ac_parameter[0] - json_data["analysis"]["ac"]["Stop Fre Combo"] = obj_analysis.ac_parameter[1] + json_data + ["analysis"]["ac"]["Start Fre Combo"] = obj_analysis.ac_parameter[0] + json_data + ["analysis"]["ac"]["Stop Fre Combo"] = obj_analysis.ac_parameter[1] json_data["analysis"]["dc"] = {} json_data["analysis"]["dc"]["Source 1"] = str( @@ -250,9 +257,12 @@ class MainWindow(QtGui.QWidget): obj_analysis.dc_entry_var[3].text()) json_data["analysis"]["dc"]["Operating Point"] = str( self.obj_track.op_check[-1]) - json_data["analysis"]["dc"]["Start Combo"] = obj_analysis.dc_parameter[0] - json_data["analysis"]["dc"]["Increment Combo"] = obj_analysis.dc_parameter[1] - json_data["analysis"]["dc"]["Stop Combo"] = obj_analysis.dc_parameter[2] + json_data + ["analysis"]["dc"]["Start Combo"] = obj_analysis.dc_parameter[0] + json_data + ["analysis"]["dc"]["Increment Combo"] = obj_analysis.dc_parameter[1] + json_data + ["analysis"]["dc"]["Stop Combo"] = obj_analysis.dc_parameter[2] json_data["analysis"]["dc"]["Source 2"] = str( obj_analysis.dc_entry_var[4].text()) json_data["analysis"]["dc"]["Start2"] = str( @@ -261,9 +271,12 @@ class MainWindow(QtGui.QWidget): obj_analysis.dc_entry_var[6].text()) json_data["analysis"]["dc"]["Stop2"] = str( obj_analysis.dc_entry_var[7].text()) - json_data["analysis"]["dc"]["Start Combo2"] = obj_analysis.dc_parameter[3] - json_data["analysis"]["dc"]["Increment Combo2"] = obj_analysis.dc_parameter[4] - json_data["analysis"]["dc"]["Stop Combo2"] = obj_analysis.dc_parameter[5] + json_data + ["analysis"]["dc"]["Start Combo2"] = obj_analysis.dc_parameter[3] + json_data + ["analysis"]["dc"]["Increment Combo2"] = obj_analysis.dc_parameter[4] + json_data + ["analysis"]["dc"]["Stop Combo2"] = obj_analysis.dc_parameter[5] json_data["analysis"]["tran"] = {} json_data["analysis"]["tran"]["Start Time"] = str( @@ -272,9 +285,12 @@ class MainWindow(QtGui.QWidget): obj_analysis.tran_entry_var[1].text()) json_data["analysis"]["tran"]["Stop Time"] = str( obj_analysis.tran_entry_var[2].text()) - json_data["analysis"]["tran"]["Start Combo"] = obj_analysis.tran_parameter[0] - json_data["analysis"]["tran"]["Step Combo"] = obj_analysis.tran_parameter[1] - json_data["analysis"]["tran"]["Stop Combo"] = obj_analysis.tran_parameter[2] + json_data + ["analysis"]["tran"]["Start Combo"] = obj_analysis.tran_parameter[0] + json_data + ["analysis"]["tran"]["Step Combo"] = obj_analysis.tran_parameter[1] + json_data + ["analysis"]["tran"]["Stop Combo"] = obj_analysis.tran_parameter[2] """ Writing Source values @@ -514,7 +530,8 @@ class MainWindow(QtGui.QWidget): # Calling netlist file generation function self.createNetlistFile(store_schematicInfo, plotText) - self.msg = "The Kicad to Ngspice Conversion completed successfully!" + self.msg = "The Kicad to Ngspice Conversion completed\ + successfully!" QtGui.QMessageBox.information( self, "Information", self.msg, QtGui.QMessageBox.Ok) @@ -531,19 +548,19 @@ class MainWindow(QtGui.QWidget): def createNetlistFile(self, store_schematicInfo, plotText): print("Creating Final netlist") - #print "INFOLINE",infoline - #print "OPTIONINFO",optionInfo - #print "Device MODEL LIST ",devicemodelList - #print "SUBCKT ",subcktList - #print "OUTPUTOPTION",outputOption - #print "KicadfIle",kicadFile + # print "INFOLINE",infoline + # print "OPTIONINFO",optionInfo + # print "Device MODEL LIST ",devicemodelList + # print "SUBCKT ",subcktList + # print "OUTPUTOPTION",outputOption + # print "KicadfIle",kicadFile # To avoid writing optionInfo twice in final netlist store_optionInfo = list(optionInfo) # checking if analysis files is present (projpath, filename) = os.path.split(self.kicadFile) analysisFileLoc = os.path.join(projpath, "analysis") - #print "Analysis File Location",analysisFileLoc + # print "Analysis File Location",analysisFileLoc if os.path.exists(analysisFileLoc): try: f = open(analysisFileLoc) @@ -553,7 +570,8 @@ class MainWindow(QtGui.QWidget): f.close() except BaseException: - print("Error While opening Project Analysis file. Please check it") + print("Error While opening Project Analysis file.\ + Please check it") sys.exit() else: print(analysisFileLoc + " does not exist") @@ -569,22 +587,25 @@ class MainWindow(QtGui.QWidget): else: pass - #print "Option Info",optionInfo + # print "Option Info",optionInfo analysisOption = [] initialCondOption = [] simulatorOption = [] - # includeOption=[] #Don't know why to use it - # model = [] #Don't know why to use it + # includeOption=[] # Don't know why to use it + # model = [] # Don't know why to use it for eachline in store_optionInfo: words = eachline.split() option = words[0] - if (option == '.ac' or option == '.dc' or option == '.disto' or option == '.noise' or - option == '.op' or option == '.pz' or option == '.sens' or option == '.tf' or + if (option == '.ac' or option == '.dc' or option == + '.disto' or option == '.noise' or + option == '.op' or option == '.pz' or option == + '.sens' or option == '.tf' or option == '.tran'): analysisOption.append(eachline + '\n') - elif (option == '.save' or option == '.print' or option == '.plot' or option == '.four'): + elif (option == '.save' or option == '.print' or option == + '.plot' or option == '.four'): eachline = eachline.strip('.') outputOption.append(eachline + '\n') elif (option == '.nodeset' or option == '.ic'): @@ -661,7 +682,8 @@ class MainWindow(QtGui.QWidget): subcktInfo += words[i] + " " continue if words[0] == ".end" or words[0] == ".ac" or words[0] == ".dc" or words[0] == ".tran" or words[0] == '.disto' or words[ - 0] == '.noise' or words[0] == '.op' or words[0] == '.pz' or words[0] == '.sens' or words[0] == '.tf': + 0] == '.noise' or words[0] == '.op' or words[0] ==\ + '.pz' or words[0] == '.sens' or words[0] == '.tf': continue elif words[0] == ".control": while words[0] != ".endc": diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index 7366a593..7ae41791 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -1,7 +1,7 @@ from PyQt4 import QtGui import json from . import TrackWidget -#from xml.etree import ElementTree as ET +# from xml.etree import ElementTree as ET import os @@ -48,7 +48,7 @@ class Model(QtGui.QWidget): self.setLayout(self.grid) for line in modelList: - #print "ModelList Item:",line + # print "ModelList Item:",line # Adding title label for model # Key: Tag name,Value:Entry widget number tag_dict = {} @@ -59,8 +59,8 @@ class Model(QtGui.QWidget): # line[7] is parameter dictionary holding parameter tags. i = 0 for key, value in line[7].items(): - #print "Key : ",key - #print "Value : ",value + # print "Key : ",key + # print "Value : ",value # Check if value is iterable if hasattr(value, '__iter__'): # For tag having vector value @@ -68,16 +68,22 @@ class Model(QtGui.QWidget): for item in value: paramLabel = QtGui.QLabel(item) 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]: - self.obj_trac.model_entry_var[self.nextcount].setText( - str(list(json_data["model"][mod]["values"][i].values())[0])) + if json_data["model"][mod]["type"] ==\ + line[2] and mod == line[3]: + self.obj_trac.model_entry_var + [self.nextcount].setText( + str(list( + json_data["model"][mod]["values"] + [i].values())[0])) i = i + 1 except BaseException: pass @@ -90,16 +96,22 @@ 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]: - self.obj_trac.model_entry_var[self.nextcount].setText( - str(list(json_data["model"][mod]["values"][i].values())[0])) + if json_data["model"][mod]["type"] ==\ + line[2] and mod == line[3]: + self.obj_trac.model_entry_var + [self.nextcount].setText( + str(list(json_data + ["model"][mod]["values"] + [i].values())[0])) i = i + 1 except BaseException: pass @@ -109,13 +121,15 @@ class Model(QtGui.QWidget): self.nextrow = self.nextrow + 1 self.end = self.nextcount - 1 - #print "End",self.end + # print "End",self.end modelbox.setLayout(modelgrid) # CSS modelbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(modelbox) @@ -129,7 +143,8 @@ class Model(QtGui.QWidget): line[4] = comment line[5] = title line[6] = type i.e analog or digital - Now adding start,end and tag_dict which will be line[7],line[8] and line[9] respectively + Now adding start,end and tag_dict which will be line[7], + line[8] and line[9] respectively ''' # This keeps the track of Model Tab Widget @@ -152,6 +167,6 @@ class Model(QtGui.QWidget): if check == 0: self.obj_trac.modelTrack.append(lst) - #print "The tag dictionary : ",tag_dict + # print "The tag dictionary : ",tag_dict self.show() diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index a175ac8b..efc30c16 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -103,7 +103,8 @@ class PrcocessNetlist: pw = ' Enter pulse width (seconds): ' tp = ' Enter period (seconds): ' sourcelist.append( - [index, compline, words[3], Title, v1, v2, td, tr, tf, pw, tp]) + [index, compline, words[3], + Title, v1, v2, td, tr, tf, pw, tp]) elif words[3] == "sine": Title = "Add parameters for sine source " + compName @@ -113,11 +114,13 @@ class PrcocessNetlist: td = ' Enter delay time (seconds): ' theta = ' Enter damping factor (1/seconds): ' sourcelist.append( - [index, compline, words[3], Title, vo, va, freq, td, theta]) + [index, compline, words[3], + Title, vo, va, freq, td, theta]) elif words[3] == "pwl": Title = "Add parameters for pwl source " + compName - t_v = ' Enter in pwl format without bracket i.e t1 v1 t2 v2.... ' + t_v = ' Enter in pwl format without bracket\ + i.e t1 v1 t2 v2.... ' sourcelist.append([index, compline, words[3], Title, t_v]) elif words[3] == "ac": @@ -136,7 +139,8 @@ class PrcocessNetlist: td2 = ' Enter fall time (seconds): ' tau2 = ' Enter fall time constant (seconds): ' sourcelist.append( - [index, compline, words[3], Title, v1, v2, td1, tau1, td2, tau2]) + [index, compline, words[3], + Title, v1, v2, td1, tau1, td2, tau2]) elif words[3] == "dc": Title = "Add parameters for DC source " + compName @@ -166,7 +170,7 @@ class PrcocessNetlist: schematicInfo = schematicInfo + schematicInfo1 print("Source List : ", sourcelist) - #print schematicInfo + # print schematicInfo return schematicInfo, sourcelist def convertICintoBasicBlocks( @@ -187,8 +191,8 @@ class PrcocessNetlist: for compline in schematicInfo: words = compline.split() compName = words[0] - #print "Compline----------------->",compline - #print "compName-------------->",compName + # print "Compline----------------->",compline + # print "compName-------------->",compName # Find the IC from schematic if compName[0] == 'u' or compName[0] == 'U': # Find the component from the circuit @@ -199,12 +203,14 @@ class PrcocessNetlist: # e.g compLine : u1 1 2 gain # compType : gain # compName : u1 - #print "Compline",compline - #print "CompType",compType - #print "Words",words - #print "compName",compName + # print "Compline",compline + # print "CompType",compType + # print "Words",words + # print "compName",compName # Looking if model file is present - if compType != "port" and compType != "ic" and compType not in plotList and compType != 'transfo': + if compType != "port" and compType != "ic" and \ + compType not in plotList and \ + compType != 'transfo': xmlfile = compType + ".xml" # XML Model File count = 0 # Check if model of same name is present modelPath = [] @@ -223,10 +229,11 @@ class PrcocessNetlist: elif count == 1: try: print( - "Start Parsing Previous Values XML for ngspice model :", modelPath) + "Start Parsing Previous Values XML\ + for ngspice model :", modelPath) tree = ET.parse(modelPath[0]) - root = tree.getroot() + root = tree.getroot() # noqa # Getting number of nodes for model and title for child in tree.iter(): if child.tag == 'node_number': @@ -243,33 +250,37 @@ class PrcocessNetlist: for param in tree.findall('param'): for item in param: - #print "Tags ",item.tag - #print "Value",item.text + # print "Tags ",item.tag + # print "Value",item.text if 'vector'in item.attrib: - #print "Tag having vector attribute",item.tag,item.attrib['vector'] + # print "Tag having vector attribute",\ + # item.tag,item.attrib['vector'] temp_count = 1 temp_list = [] for i in range(0, int( item.attrib['vector'])): temp_list.append( - item.text + " " + str(temp_count)) + item.text + " " + str( + temp_count)) temp_count += 1 if 'default' in item.attrib: paramDict[item.tag + ":" + - item.attrib['default']] = temp_list + item.attrib['default']] \ + = temp_list else: paramDict[item.tag] = item.text else: if 'default' in item.attrib: paramDict[item.tag + ":" + - item.attrib['default']] = item.text + item.attrib['default']]\ + = item.text else: paramDict[item.tag] = item.text - #print "Number of Nodes : ",num_of_nodes - #print "Title : ",title - #print "Parameters",paramDict + # print "Number of Nodes : ",num_of_nodes + # print "Title : ",title + # print "Parameters",paramDict # Creating line for adding model line in schematic if splitDetail == 'None': modelLine = "a" + str(k) + " " @@ -281,28 +292,30 @@ class PrcocessNetlist: print("Split Details :", splitDetail) modelLine = "a" + str(k) + " " vectorDetail = splitDetail.split(':') - #print "Vector Details",vectorDetail + # print "Vector Details",vectorDetail pos = 1 # Node position for item in vectorDetail: try: if item.split("-")[1] == 'V': - #print "Vector" + # print "Vector" if compType == "aswitch": modelLine += "(" for i in range(0, int( item.split("-")[0])): - modelLine += words[pos] + " " + modelLine += words[pos] +\ + " " pos += 1 modelLine += ") " else: modelLine += "[" for i in range(0, int( item.split("-")[0])): - modelLine += words[pos] + " " + modelLine += words[pos] + \ + " " pos += 1 modelLine += "] " elif item.split("-")[1] == 'NV': - #print "Non Vector" + # print "Non Vector" for i in range(0, int( item.split("-")[0])): modelLine += words[pos] + " " @@ -310,28 +323,33 @@ class PrcocessNetlist: except BaseException: print( - "There is error while processing Vector Details") + "There is error while processing\ + Vector Details") sys.exit(2) modelLine += compName - #print "Final Model Line :",modelLine + # print "Final Model Line :",modelLine try: schematicInfo.append(modelLine) k = k + 1 except Exception as e: print( - "Error while appending ModelLine ", modelLine) + "Error while appending \ + ModelLine ", modelLine) print("Exception Message : ", str(e)) # Insert comment at remove line schematicInfo.insert(index, "* " + compline) - comment = "* Schematic Name: " + compType + ", NgSpice Name: " + modelname + comment = "* Schematic Name:\ + " + compType + ", NgSpice Name: " + modelname # Here instead of adding compType(use for XML), # added modelName(Unique Model Name) modelList.append( - [index, compline, modelname, compName, comment, title, type, paramDict]) + [index, compline, modelname, compName, + comment, title, type, paramDict]) except Exception as e: print( - "Unable to parse the model, Please check your your XML file") + "Unable to parse the model, \ + Please check your your XML file") print("Exception Message : ", str(e)) sys.exit(2) elif compType == "ic": @@ -343,7 +361,8 @@ class PrcocessNetlist: text = "Enter initial voltage at node for " + compline paramDict[title] = text modelList.append( - [index, compline, modelname, compName, comment, title, type, paramDict]) + [index, compline, modelname, compName, + comment, title, type, paramDict]) elif compType in plotList: schematicInfo.insert(index, "* " + compline) @@ -358,7 +377,8 @@ class PrcocessNetlist: words = compline.split() # Adding zero voltage source to netlist schematicInfo.append( - "v_" + words[0] + " " + words[1] + " " + words[2] + " " + "0") + "v_" + words[0] + " " + + words[1] + " " + words[2] + " " + "0") plotText.append("plot i(v_" + words[0] + ")") elif compType == 'plot_log': words = compline.split() @@ -374,20 +394,23 @@ class PrcocessNetlist: schematicInfo.insert(index, "* " + compline) # For Primary Couple - modelLine = "a" + str(k) + " (" + words[1] + " " + words[2] + ") (interNode_" + str( + modelLine = "a" + str(k) + + " (" + words[1] + " " + words[2] + ") (interNode_" + str( interMediateNodeCount) + " " + words[3] + ") " modelLine += compName + "_primary" schematicInfo.append(modelLine) k = k + 1 # For iron core - modelLine = "a" + str(k) + " (" + words[4] + " " + words[2] + ") (interNode_" + str( + modelLine = "a" + str(k) + " (" + words[4] + " " + words[2] + ") \ + (interNode_" + str( interMediateNodeCount + 1) + " " + words[3] + ") " modelLine += compName + "_secondary" schematicInfo.append(modelLine) k = k + 1 # For Secondary Couple modelLine = "a" + str(k) + " (interNode_" + str( - interMediateNodeCount) + " interNode_" + str(interMediateNodeCount + 1) + ") " + interMediateNodeCount) + " interNode_" + \ + str(interMediateNodeCount + 1) + ") " modelLine += compName + "_iron_core" schematicInfo.append(modelLine) k = k + 1 @@ -396,16 +419,21 @@ class PrcocessNetlist: modelname = "transfo" comment = "* " + compline title = "Transformer details for model " + compName - type = "NA" # It is model but do not load from xml and lib file + type = "NA" + # It is model but do not load from xml and lib file paramDict['h1_array'] = "Enter the H1 array " - paramDict['primary_turns'] = "Enter the primary number of turns (default=310) " + paramDict['primary_turns'] = "Enter the primary number \ + of turns (default=310) " paramDict['area'] = "Enter iron core area (default=1)" - paramDict['secondar_turns'] = "Enter the secondary number of turns (default=620)" - paramDict['length'] = "Enter iron core length (default=0.01)" + paramDict['secondar_turns'] = "Enter the secondary number\ + of turns (default=620)" + paramDict['length'] = "Enter iron core length \ + (default=0.01)" paramDict['b1_array'] = "Enter the B1 array " modelList.append( - [index, compline, modelname, compName, comment, title, type, paramDict]) + [index, compline, modelname, compName, + comment, title, type, paramDict]) else: schematicInfo.insert(index, "* " + compline) @@ -418,4 +446,7 @@ class PrcocessNetlist: multipleModelList) print("Model List Details : ", modelList) - return schematicInfo, outputOption, modelList, unknownModelList, multipleModelList, plotText + return ( + schematicInfo, outputOption, modelList, unknownModelList, + multipleModelList, plotText + ) diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py index 613b7b36..8649ce93 100644 --- a/src/kicadtoNgspice/Source.py +++ b/src/kicadtoNgspice/Source.py @@ -1,7 +1,7 @@ import os from PyQt4 import QtGui from . import TrackWidget -#from xml.etree import ElementTree as ET +# from xml.etree import ElementTree as ET import json @@ -20,14 +20,15 @@ class Source(QtGui.QWidget): self.end = 0 self.row = 0 self.entry_var = {} - #self.font = QtGui.QFont("Times",20,QtGui.QFont.Bold,True) + # self.font = QtGui.QFont("Times",20,QtGui.QFont.Bold,True) # Creating Source Widget self.createSourceWidget(sourcelist, sourcelisttrack) def createSourceWidget(self, sourcelist, sourcelisttrack): """ - This function dynamically create source widget in the Source tab of KicadtoNgSpice window + This function dynamically create source widget in the + Source tab of KicadtoNgSpice window """ kicadFile = self.clarg1 (projpath, filename) = os.path.split(kicadFile) @@ -51,10 +52,10 @@ class Source(QtGui.QWidget): if sourcelist: for line in sourcelist: - #print "Voltage source line index: ",line[0] + # print "Voltage source line index: ",line[0] print("SourceList line: ", line) track_id = line[0] - #print "track_id is ",track_id + # print "track_id is ",track_id if line[2] == 'ac': acbox = QtGui.QGroupBox() acbox.setTitle(line[3]) @@ -83,11 +84,18 @@ class Source(QtGui.QWidget): templist1 = line[1] templist2 = templist1.split(' ') - if key == templist2[0] and json_data["source"][key]["type"] == line[2]: + if key == templist2[0] and \ + json_data["source"][key]["type"]\ + == line[2]: self.entry_var[self.count - 2].setText( - str(json_data["source"][key]["values"][0]["Amplitude"])) + str( + json_data + ["source"][key]["values"][0] + ["Amplitude"])) self.entry_var[self.count - 1].setText( - str(json_data["source"][key]["values"][1]["Phase"])) + str( + json_data["source"][key] + ["values"][1]["Phase"])) except BaseException: pass @@ -100,8 +108,10 @@ class Source(QtGui.QWidget): # CSS acbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(acbox) @@ -126,9 +136,13 @@ class Source(QtGui.QWidget): templist1 = line[1] templist2 = templist1.split(' ') - if key == templist2[0] and json_data["source"][key]["type"] == line[2]: + if key == templist2[0] and \ + json_data["source"][key]["type"]\ + == line[2]: self.entry_var[self.count].setText( - str(json_data["source"][key]["values"][0]["Value"])) + str( + json_data["source"][key] + ["values"][0]["Value"])) except BaseException: pass @@ -140,8 +154,10 @@ class Source(QtGui.QWidget): # CSS dcbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(dcbox) @@ -168,9 +184,14 @@ class Source(QtGui.QWidget): for key in json_data["source"]: templist1 = line[1] templist2 = templist1.split(' ') - if key == templist2[0] and json_data["source"][key]["type"] == line[2]: + if key == templist2[0] and \ + json_data["source"][key]["type"]\ + == line[2]: self.entry_var[self.count].setText( - str(list(json_data["source"][key]["values"][it - 4].values())[0])) + str( + list(json_data["source"] + [key]["values"] + [it - 4].values())[0])) except BaseException: pass @@ -181,8 +202,10 @@ class Source(QtGui.QWidget): # CSS sinebox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(sinebox) @@ -209,9 +232,13 @@ class Source(QtGui.QWidget): templist1 = line[1] templist2 = templist1.split(' ') - if key == templist2[0] and json_data["source"][key]["type"] == line[2]: + if key == templist2[0] and \ + json_data["source"][key]["type"]\ + == line[2]: self.entry_var[self.count].setText( - str(list(json_data["source"][key]["values"][it - 4].values())[0])) + str(list( + json_data["source"][key] + ["values"][it - 4].values())[0])) except BaseException: pass @@ -222,8 +249,10 @@ class Source(QtGui.QWidget): # CSS pulsebox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(pulsebox) @@ -246,9 +275,12 @@ class Source(QtGui.QWidget): for key in json_data["source"]: templist1 = line[1] templist2 = templist1.split(' ') - if key == templist2[0] and json_data["source"][key]["type"] == line[2]: + if key == templist2[0] and \ + json_data["source"][key]["type"] \ + == line[2]: self.entry_var[self.count].setText( - str(json_data["source"][key]["values"][0]["Enter in pwl format"])) + str(json_data["source"][key] + ["values"][0]["Enter in pwl format"])) except BaseException: pass @@ -259,8 +291,10 @@ class Source(QtGui.QWidget): # CSS pwlbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius: \ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(pwlbox) @@ -286,9 +320,16 @@ class Source(QtGui.QWidget): for key in json_data["source"]: templist1 = line[1] templist2 = templist1.split(' ') - if key == templist2[0] and json_data["source"][key]["type"] == line[2]: + if key == templist2[0] and \ + json_data["source"][key]["type"]\ + == line[2]: self.entry_var[self.count].setText( - str(list(json_data["source"][key]["values"][it - 4].values())[0])) + str( + list( + json_data["source"][key] + ["values"][it - 4].values())[0] + ) + ) except BaseException: pass @@ -299,8 +340,10 @@ class Source(QtGui.QWidget): # CSS expbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: \ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(expbox) diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py index 249b636b..b9c6402b 100644 --- a/src/kicadtoNgspice/SubcircuitTab.py +++ b/src/kicadtoNgspice/SubcircuitTab.py @@ -3,7 +3,7 @@ import json from . import TrackWidget from projManagement import Validation import os -#from xml.etree import ElementTree as ET +# from xml.etree import ElementTree as ET class SubcircuitTab(QtGui.QWidget): @@ -68,7 +68,8 @@ class SubcircuitTab(QtGui.QWidget): try: for key in json_data["subcircuit"]: if key[0] == eachline[0] and key[1] == eachline[1]: - #print "Subcircuit MATCHING---",child.tag[0], child.tag[1], eachline[0], eachline[1] + # print "Subcircuit MATCHING---",child.tag[0], \ + # child.tag[1], eachline[0], eachline[1] try: if os.path.exists( json_data["subcircuit"][key][0]): @@ -85,7 +86,8 @@ class SubcircuitTab(QtGui.QWidget): subgrid.addWidget(self.entry_var[self.count], self.row, 1) self.addbtn = QtGui.QPushButton("Add") self.addbtn.setObjectName("%d" % self.count) - # Send the number of ports specified with the given subcircuit for verification. + # Send the number of ports specified with the given\ + # subcircuit for verification. # eg. If the line is 'x1 4 0 3 ua741', there are 3 ports(4, 0 # and 3). self.numPorts.append(len(words) - 2) @@ -96,8 +98,10 @@ class SubcircuitTab(QtGui.QWidget): # CSS subbox.setStyleSheet(" \ - QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ ") self.grid.addWidget(subbox) @@ -123,7 +127,7 @@ class SubcircuitTab(QtGui.QWidget): This function is use to keep track of all Subcircuit widget """ sending_btn = self.sender() - #print "Object Called is ",sending_btn.objectName() + # print "Object Called is ",sending_btn.objectName() self.widgetObjCount = int(sending_btn.objectName()) self.subfile = str( @@ -150,7 +154,8 @@ class SubcircuitTab(QtGui.QWidget): elif self.reply == "DIREC": self.msg = QtGui.QErrorMessage(self) self.msg.showMessage( - "Please select a valid Subcircuit directory (Containing '.sub' file).") + "Please select a valid Subcircuit directory \ + (Containing '.sub' file).") self.msg.setWindowTitle("Error Message") self.msg.show() @@ -178,6 +183,7 @@ class SubcircuitTab(QtGui.QWidget): elif self.reply == "DIREC": self.msg = QtGui.QErrorMessage(self) self.msg.showMessage( - "Please select a valid Subcircuit directory (Containing '.sub' file).") + "Please select a valid Subcircuit directory \ + (Containing '.sub' file).") self.msg.setWindowTitle("Error Message") self.msg.show()
\ No newline at end of file |