diff options
Diffstat (limited to 'src/kicadtoNgspice')
-rw-r--r-- | src/kicadtoNgspice/Analysis.py | 45 | ||||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 23 | ||||
-rw-r--r-- | src/kicadtoNgspice/DeviceModel.py | 29 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 97 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 8 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 43 | ||||
-rw-r--r-- | src/kicadtoNgspice/Source.py | 10 | ||||
-rw-r--r-- | src/kicadtoNgspice/SubcircuitTab.py | 17 |
8 files changed, 96 insertions, 176 deletions
diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py index 9ce4342b..a573c540 100644 --- a/src/kicadtoNgspice/Analysis.py +++ b/src/kicadtoNgspice/Analysis.py @@ -2,7 +2,6 @@ from PyQt4 import QtGui import TrackWidget import os -import sys from xml.etree import ElementTree as ET class Analysis(QtGui.QWidget): @@ -36,12 +35,11 @@ class Analysis(QtGui.QWidget): kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) if os.path.isfile(os.path.join(projpath, 'analysis')): - print "analysis present" + print "Analysis file is present" analysisfile = open(os.path.join(projpath,'analysis')) content = analysisfile.readline() - print "content", content + print "Content of Analysis file :", content contentlist= content.split() - print "contenlist", contentlist if contentlist[0]== '.ac': self.checkAC.setChecked(True) self.acbox.setDisabled(False) @@ -64,7 +62,6 @@ class Analysis(QtGui.QWidget): self.acbox.setDisabled(True) self.trbox.setDisabled(True) self.track_obj.set_CheckBox["ITEMS"]="DC" - #self.enableBox() elif contentlist[0]== '.tran': self.checkTRAN.setChecked(True) @@ -81,10 +78,8 @@ class Analysis(QtGui.QWidget): self.check.setChecked(True) except: self.checkTRAN.setChecked(True) - #self.trbox.setDisabled(False) self.track_obj.set_CheckBox["ITEMS"]="TRAN" - - + self.setLayout(self.grid) self.show() @@ -101,24 +96,15 @@ class Analysis(QtGui.QWidget): self.checkgroupbtn.addButton(self.checkDC) self.checkgroupbtn.addButton(self.checkTRAN) self.checkgroupbtn.setExclusive(True) - #self.checkAC.setChecked(True) self.checkgroupbtn.buttonClicked.connect(self.enableBox) self.checkgrid.addWidget(self.checkAC,0,0) self.checkgrid.addWidget(self.checkDC,0,1) self.checkgrid.addWidget(self.checkTRAN,0,2) self.checkbox.setLayout(self.checkgrid) - - #CSS - ''' - self.checkbox.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; } \ - ") - ''' - + return self.checkbox - #return self.checkgroupbtn + def enableBox(self): if self.checkAC.isChecked(): @@ -143,7 +129,6 @@ class Analysis(QtGui.QWidget): kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -154,7 +139,7 @@ class Analysis(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "AC Previous Values XML is Empty" self.acbox = QtGui.QGroupBox() self.acbox.setTitle("AC Analysis") @@ -174,7 +159,6 @@ class Analysis(QtGui.QWidget): self.acgrid.addWidget(self.Lin,1,1) self.acgrid.addWidget(self.Dec,1,2) self.acgrid.addWidget(self.Oct,1,3) - #self.acbox.setDisabled(True) self.acbox.setLayout(self.acgrid) self.scale = QtGui.QLabel("Scale") @@ -214,8 +198,7 @@ class Analysis(QtGui.QWidget): except: self.ac_parameter[self.parameter_cnt]= "Hz" self.start_fre_combo.activated[str].connect(self.start_combovalue) - - + self.parameter_cnt=self.parameter_cnt + 1 self.stop_fre_combo = QtGui.QComboBox() self.stop_fre_combo.addItem("Hz") @@ -265,7 +248,7 @@ class Analysis(QtGui.QWidget): index=self.stop_fre_combo.findText(root[0][7].text) self.stop_fre_combo.setCurrentIndex(index) except: - print "XML Parse Error" + print "AC Analysis XML Parse Error" return self.acbox @@ -290,7 +273,6 @@ class Analysis(QtGui.QWidget): kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -301,7 +283,7 @@ class Analysis(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "DC Previous Values XML is empty" self.dcbox = QtGui.QGroupBox() self.dcbox.setTitle("DC Analysis") @@ -371,7 +353,6 @@ class Analysis(QtGui.QWidget): self.dcgrid.addWidget(self.dc_entry_var[self.count],8,1) self.dc_entry_var[self.count].setMaximumWidth(150) - self.parameter_cnt=0 self.start_combo=QtGui.QComboBox(self) self.start_combo.setMaximumWidth(150) @@ -464,7 +445,6 @@ class Analysis(QtGui.QWidget): self.stop_combo2.activated[str].connect(self.stop_changecombo2) self.parameter_cnt= self.parameter_cnt+1 - self.check=QtGui.QCheckBox('Operating Point Analysis',self) try: self.track_obj.op_check.append(str(root[1][4].text())) @@ -511,7 +491,7 @@ class Analysis(QtGui.QWidget): else: self.check.setChecked(False) except: - print "XML Parse Error" + print "DC Analysis XML Parse Error" return self.dcbox @@ -543,7 +523,6 @@ class Analysis(QtGui.QWidget): kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -554,7 +533,7 @@ class Analysis(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "Transient Previous Values XML is Empty" self.trbox = QtGui.QGroupBox() self.trbox.setTitle("Transient Analysis") @@ -647,7 +626,7 @@ class Analysis(QtGui.QWidget): index=self.stop_combobox.findText(root[2][5].text) self.stop_combobox.setCurrentIndex(index) except: - print "XML Parse Error" + print "Transient Analysis XML Parse Error" return self.trbox diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 78a39c2f..c7e03210 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -1,7 +1,6 @@ from PyQt4 import QtGui import os -import sys import shutil import TrackWidget from xml.etree import ElementTree as ET @@ -11,7 +10,6 @@ class Convert: This class has all the necessary function required to convert kicad netlist to ngspice netlist. """ def __init__(self,sourcelisttrack,source_entry_var,schematicInfo,clarg1): - print "Start Conversion" self.sourcelisttrack = sourcelisttrack self.schematicInfo = schematicInfo self.entry_var = source_entry_var @@ -23,10 +21,7 @@ class Convert: """ This function add the source details to schematicInfo """ - #print "Adding Source parameter" - #print "SourceListTrack : ",self.sourcelisttrack - #print "Schematic Info ",self.schematicInfo - #print "Entry Var",self.entry_var + self.start = 0 self.end = 0 @@ -207,8 +202,6 @@ class Convert: #print "Model Track :",line if line[2] == 'transfo': try: - print "Transformer-------------->" - print "Line ---------->",line start=line[7] end=line[8] num_turns=str(self.obj_track.model_entry_var[start].text()) @@ -307,20 +300,16 @@ class Convert: schematicInfo.append(item[2]) #Adding Comment schematicInfo.append(item[1]) #Adding model line - print "Schematic Info after ngspice Model------->",schematicInfo - print "Model Parameter Value ",modelParamValue return schematicInfo def addDeviceLibrary(self,schematicInfo,kicadFile): """ This function add the library details to schematicInfo """ - print "Adding Device library to Schematic info file" - + (projpath,filename) = os.path.split(kicadFile) - print "Project Path",projpath - + deviceLibList = self.obj_track.deviceModelTrack deviceLine = {} #Key:Index, Value:with its updated line in the form of list includeLine = [] #All .include line list @@ -392,15 +381,13 @@ class Convert: """ This function add the subcircuit to schematicInfo """ - print "Adding Subcircuit to Schematic info file" - + (projpath,filename) = os.path.split(kicadFile) subList = self.obj_track.subcircuitTrack subLine = {} #Key:Index, Value:with its updated line in the form of list includeLine = [] #All .include line list - print "self.obj_track.subcircuitList--->",self.obj_track.subcircuitList - print "self.obj_track.subcircuitTrack--->",self.obj_track.subcircuitTrack + if len(self.obj_track.subcircuitList) != len(self.obj_track.subcircuitTrack): self.msg = QtGui.QErrorMessage() self.msg.showMessage("Conversion failed. Please add all Subcircuits.") diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index aaf02f45..a982d05f 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -1,5 +1,4 @@ from PyQt4 import QtGui -import sys import os from xml.etree import ElementTree as ET @@ -18,7 +17,6 @@ class DeviceModel(QtGui.QWidget): kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -29,7 +27,7 @@ class DeviceModel(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "Device Model Previous XML is Empty" QtGui.QWidget.__init__(self) @@ -54,11 +52,12 @@ class DeviceModel(QtGui.QWidget): #Set Layout self.grid = QtGui.QGridLayout() self.setLayout(self.grid) + print "Reading Device model details from Schematic" for eachline in schematicInfo: words = eachline.split() if eachline[0] == 'q': - print "Words ",words[0] + print "Device Model Transistor: ",words[0] self.devicemodel_dict_beg[words[0]]=self.count transbox=QtGui.QGroupBox() transgrid=QtGui.QGridLayout() @@ -77,7 +76,7 @@ class DeviceModel(QtGui.QWidget): else: self.entry_var[self.count].setText("") except: - print "ERROR WHEN SET TEXT" + print "Error when set text of device model transistor" except: pass transgrid.addWidget(self.entry_var[self.count],self.row,1) @@ -109,7 +108,7 @@ class DeviceModel(QtGui.QWidget): self.count = self.count+1 elif eachline[0] == 'd': - print "Words",words[0] + print "Device Model Diode:",words[0] self.devicemodel_dict_beg[words[0]]=self.count diodebox=QtGui.QGroupBox() diodegrid=QtGui.QGridLayout() @@ -120,7 +119,7 @@ class DeviceModel(QtGui.QWidget): try: for child in root: if child.tag[0]==eachline[0] and child.tag[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(child[0].text): path_name=child[0].text @@ -128,7 +127,7 @@ class DeviceModel(QtGui.QWidget): else: self.entry_var[self.count].setText("") except: - print "ERROR WHEN SET TEXT" + print "Error when set text of device model diode" except: pass diodegrid.addWidget(self.entry_var[self.count],self.row,1) @@ -160,7 +159,7 @@ class DeviceModel(QtGui.QWidget): self.count = self.count+1 elif eachline[0] == 'j': - print "Words",words[0] + print "Device Model JFET:",words[0] self.devicemodel_dict_beg[words[0]]=self.count jfetbox=QtGui.QGroupBox() jfetgrid=QtGui.QGridLayout() @@ -171,7 +170,7 @@ class DeviceModel(QtGui.QWidget): try: for child in root: if child.tag[0]==eachline[0] and child.tag[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(child[0].text): self.entry_var[self.count].setText(child[0].text) @@ -179,7 +178,7 @@ class DeviceModel(QtGui.QWidget): else: self.entry_var[self.count].setText("") except: - print "ERROR WHEN SET TEXT" + print "Error when set text of Device Model JFET " except: pass jfetgrid.addWidget(self.entry_var[self.count],self.row,1) @@ -269,7 +268,7 @@ class DeviceModel(QtGui.QWidget): try: for child in root: if child.tag[0]==eachline[0] and child.tag[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(child[i-beg].text) if (i-beg)==0: @@ -300,7 +299,7 @@ class DeviceModel(QtGui.QWidget): """ This function is use to keep track of all Device Model widget """ - print "Calling Track Library funtion" + print "Calling Track Device Model Library funtion" sending_btn = self.sender() #print "Object Called is ",sending_btn.objectName() self.widgetObjCount = int(sending_btn.objectName()) @@ -331,7 +330,7 @@ class DeviceModel(QtGui.QWidget): """ This function is use to keep track of all Device Model widget """ - print "Calling Track Library funtion" + print "Calling Track Library function Without Button" #print "Object Called is ",sending_btn.objectName() self.widgetObjCount = iter_value print "self.widgetObjCount-----",self.widgetObjCount @@ -352,9 +351,7 @@ class DeviceModel(QtGui.QWidget): if width == "" : width="100u" if length == "": length="100u" if multifactor == "": multifactor="1" - self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile+":"+"W="+width+" L="+length+" M="+multifactor - else: self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index a8c24893..4215f6f8 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -17,7 +17,7 @@ #=============================================================================== import sys import os -from PyQt4 import QtGui,QtCore +from PyQt4 import QtGui from Processing import PrcocessNetlist import Analysis import Source @@ -49,7 +49,7 @@ class MainWindow(QtGui.QWidget): self.kicadFile = clarg1 self.clarg1=clarg1 self.clarg2=clarg2 - + #Create object of track widget self.obj_track = TrackWidget.TrackWidget() @@ -67,31 +67,28 @@ class MainWindow(QtGui.QWidget): # Read the netlist kicadNetlist = obj_proc.readNetlist(self.kicadFile) + print "Given Kicad Schematic Netlist Info :",kicadNetlist + # Construct parameter information param = obj_proc.readParamInfo(kicadNetlist) - + # Replace parameter with values netlist,infoline = obj_proc.preprocessNetlist(kicadNetlist,param) - print "NETLIST ",netlist - print "INFOLINE",infoline + print "Schematic Info after processing Kicad Netlist: ",netlist + #print "INFOLINE",infoline # Separate option and schematic information optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist) - print "OPTIONINFO",optionInfo - print "SCHEMATICINFO",schematicInfo - - + print "OPTIONINFO in the Netlist",optionInfo + #List for storing source and its value global sourcelist, sourcelisttrack sourcelist=[] sourcelisttrack=[] schematicInfo,sourcelist = obj_proc.insertSpecialSourceParam(schematicInfo,sourcelist) - - print "SOURCELIST",sourcelist - print "SCHEMATICINFO",schematicInfo - + #List storing model detail global modelList,outputOption,unknownModelList,multipleModelList,plotText @@ -99,10 +96,9 @@ class MainWindow(QtGui.QWidget): outputOption = [] plotText = [] schematicInfo,outputOption,modelList,unknownModelList,multipleModelList,plotText = obj_proc.convertICintoBasicBlocks(schematicInfo,outputOption,modelList,plotText) - print "Unknown Model List",unknownModelList - print "Multiple Model List",multipleModelList - print "Model List",modelList - + + 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 @@ -115,7 +111,6 @@ class MainWindow(QtGui.QWidget): self.msg.setWindowTitle("Unknown Models") elif multipleModelList: - print "Multiple Model List is : ",multipleModelList self.msg = QtGui.QErrorMessage() self.mcontent = "Look like you have duplicate model in modelParamXML directory "+', '.join(multipleModelList[0]) self.msg.showMessage(self.mcontent) @@ -124,8 +119,6 @@ class MainWindow(QtGui.QWidget): else: self.createMainWindow() - print "Init Schematic Info",schematicInfo - initial_schematicInfo = schematicInfo def createMainWindow(self): """ @@ -137,15 +130,10 @@ class MainWindow(QtGui.QWidget): self.hbox.addStretch(1) self.convertbtn = QtGui.QPushButton("Convert") self.convertbtn.clicked.connect(self.callConvert) - #self.cancelbtn = QtGui.QPushButton("Cancel") - #self.cancelbtn.clicked.connect(self.closeCancel) self.hbox.addWidget(self.convertbtn) self.vbox.addWidget(self.createcreateConvertWidget()) self.vbox.addLayout(self.hbox) - #self.grid.addWidget(self.cancelbtn,1,1) - - #self.setWindowState(QtCore.Qt.WindowMaximized) self.setLayout(self.vbox) self.setWindowTitle("Kicad To NgSpice Converter") self.show() @@ -194,7 +182,6 @@ class MainWindow(QtGui.QWidget): self.convertWindow.setLayout(self.mainLayout) self.convertWindow.show() - return self.convertWindow def callConvert(self): @@ -207,9 +194,7 @@ class MainWindow(QtGui.QWidget): store_schematicInfo = list(schematicInfo) (projpath,filename)=os.path.split(self.kicadFile) project_name=os.path.basename(projpath) - print "PROJ PATH---",projpath - - + check=1 try: fr=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -255,7 +240,7 @@ class MainWindow(QtGui.QWidget): ET.SubElement(attr_dc,"field2",name="Start").text= str(obj_analysis.dc_entry_var[1].text()) ET.SubElement(attr_dc,"field3",name="Increment").text= str(obj_analysis.dc_entry_var[2].text()) ET.SubElement(attr_dc,"field4",name="Stop").text= str(obj_analysis.dc_entry_var[3].text()) - print "OBJ_ANALYSIS.CHECK -----",self.obj_track.op_check[-1] + #print "OBJ_ANALYSIS.CHECK -----",self.obj_track.op_check[-1] ET.SubElement(attr_dc,"field5",name="Operating Point").text=str(self.obj_track.op_check[-1]) ET.SubElement(attr_dc,"field6",name="Start Combo").text= obj_analysis.dc_parameter[0] ET.SubElement(attr_dc,"field7",name="Increment Combo").text=obj_analysis.dc_parameter[1] @@ -276,12 +261,8 @@ class MainWindow(QtGui.QWidget): ET.SubElement(attr_tran,"field4",name="Start Combo").text= obj_analysis.tran_parameter[0] ET.SubElement(attr_tran,"field5",name="Step Combo").text= obj_analysis.tran_parameter[1] ET.SubElement(attr_tran,"field6",name="Stop Combo").text= obj_analysis.tran_parameter[2] - print "TRAN PARAMETER 2-----",obj_analysis.tran_parameter[2] - - #tree=ET.ElementTree(attr_analysis) - #tree.write(f) - - + #print "TRAN PARAMETER 2-----",obj_analysis.tran_parameter[2] + if check==0: attr_source=ET.SubElement(attr_parent,"source") if check==1: @@ -290,8 +271,7 @@ class MainWindow(QtGui.QWidget): attr_source=child count=1 grand_child_count=1 - #global tmp_check - #tmp_check=0 + for i in store_schematicInfo: tmp_check=0 words=i.split(' ') @@ -369,11 +349,7 @@ class MainWindow(QtGui.QWidget): else: pass - #tree=ET.ElementTree(attr_source) - #tree.write(f1) - - - + if check==0: attr_model=ET.SubElement(attr_parent,"model") if check==1: @@ -386,7 +362,6 @@ class MainWindow(QtGui.QWidget): #tmp_i is the iterator in case duplicates are there; then in that case we need to replace only the child node and not create a new parent node for line in modelList: - print "i for each line in model List------",i tmp_check=0 for rand_itr in obj_model.obj_trac.modelTrack: if rand_itr[2]==line[2] and rand_itr[3]==line[3]: @@ -398,9 +373,7 @@ class MainWindow(QtGui.QWidget): for grand_child in child: if i<=end: grand_child.text=str(obj_model.obj_trac.model_entry_var[i].text()) - print "STR OF MODEL----",str(obj_model.obj_trac.model_entry_var[i].text()) i=i+1 - print "i incremented to ",i else: pass tmp_check=1 @@ -412,15 +385,13 @@ class MainWindow(QtGui.QWidget): if hasattr(value, '__iter__') and i<=end: for item in value: ET.SubElement(attr_ui,"field"+str(i+1),name=item).text=str(obj_model.obj_trac.model_entry_var[i].text()) - print "STR OF MODEL----",str(obj_model.obj_trac.model_entry_var[i].text()) i=i+1 - print "i incremented to ",i + else: ET.SubElement(attr_ui,"field"+str(i+1),name=value).text=str(obj_model.obj_trac.model_entry_var[i].text()) - print "STR OF MODEL----",str(obj_model.obj_trac.model_entry_var[i].text()) + i=i+1 - print "i incremented to ",i - ################################################################################################################# + if check==0: attr_devicemodel=ET.SubElement(attr_parent,"devicemodel") if check==1: @@ -428,9 +399,8 @@ class MainWindow(QtGui.QWidget): if child.tag=="devicemodel": del child[:] attr_devicemodel=child - #print "Device model dict",obj_devicemodel.devicemodel_dict_beg - #print "Device model dict end",obj_devicemodel.devicemodel_dict_end - ########################## + + for i in obj_devicemodel.devicemodel_dict_beg: attr_var=ET.SubElement(attr_devicemodel,i) it=obj_devicemodel.devicemodel_dict_beg[i] @@ -446,7 +416,7 @@ class MainWindow(QtGui.QWidget): if child.tag=="subcircuit": del child[:] attr_subcircuit=child - ########################## + for i in obj_subcircuitTab.subcircuit_dict_beg: attr_var=ET.SubElement(attr_subcircuit,i) it=obj_subcircuitTab.subcircuit_dict_beg[i] @@ -468,15 +438,19 @@ class MainWindow(QtGui.QWidget): try: #Adding Source Value to Schematic Info store_schematicInfo = self.obj_convert.addSourceParameter() + print "Netlist After Adding Source details :",store_schematicInfo #Adding Model Value to store_schematicInfo store_schematicInfo = self.obj_convert.addModelParameter(store_schematicInfo) - + print "Netlist After Adding Ngspice Model :",store_schematicInfo + #Adding Device Library to SchematicInfo store_schematicInfo = self.obj_convert.addDeviceLibrary(store_schematicInfo,self.kicadFile) + print "Netlist After Adding Device Model Library :",store_schematicInfo #Adding Subcircuit Library to SchematicInfo store_schematicInfo = self.obj_convert.addSubcircuit(store_schematicInfo, self.kicadFile) + print "Netlist After Adding subcircuits :",store_schematicInfo analysisoutput = self.obj_convert.analysisInsertor(self.obj_track.AC_entry_var["ITEMS"], self.obj_track.DC_entry_var["ITEMS"], @@ -487,18 +461,15 @@ class MainWindow(QtGui.QWidget): self.obj_track.TRAN_Parameter["ITEMS"], self.obj_track.AC_type["ITEMS"], self.obj_track.op_check) - #print "SchematicInfo after adding Model Details",schematicInfo - - print "Analysis OutPut------>",analysisoutput + + print "Analysis OutPut ",analysisoutput #Calling netlist file generation function self.createNetlistFile(store_schematicInfo,plotText) self.msg = "The Kicad to Ngspice Conversion completed successfully!!!!!!" QtGui.QMessageBox.information(self, "Information", self.msg, QtGui.QMessageBox.Ok) - #self.obj_track.subcircuitList[:]=[] - #self.obj_track.modelTrack[:]=[] - #self.close() + except Exception as e: print "Exception Message: ",e print "There was error while converting kicad to ngspice" @@ -585,7 +556,7 @@ class MainWindow(QtGui.QWidget): out.writelines(infoline) out.writelines('\n') sections=[simulatorOption, initialCondOption, store_schematicInfo, analysisOption] - print "SECTIONS",sections + for section in sections: if len(section) == 0: continue diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index c7ca7b47..25a23d8c 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -3,7 +3,6 @@ from PyQt4 import QtGui import TrackWidget from xml.etree import ElementTree as ET -import sys import os @@ -21,7 +20,6 @@ class Model(QtGui.QWidget): kicadFile = clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - #print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -32,7 +30,7 @@ class Model(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "Model Previous Values XML is Empty" @@ -101,7 +99,7 @@ class Model(QtGui.QWidget): self.nextcount = self.nextcount+1 self.nextrow = self.nextrow+1 self.end= self.nextcount-1 - print "End",self.end + #print "End",self.end modelbox.setLayout(modelgrid) #CSS @@ -134,7 +132,7 @@ 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 diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index 55c7b702..fd9795e6 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -84,6 +84,8 @@ class PrcocessNetlist: #Inser Special source parameter schematicInfo1=[] + print "Reading schematic info for source details" + for compline in schematicInfo: words=compline.split() compName=words[0] @@ -147,12 +149,13 @@ class PrcocessNetlist: schematicInfo1.append(compName+" "+words[1]+" "+words[2]+" "+"V"+compName+" "+words[5]) schematicInfo=schematicInfo+schematicInfo1 - #print sourcelist + print "Source List : ",sourcelist #print schematicInfo return schematicInfo,sourcelist def convertICintoBasicBlocks(self,schematicInfo,outputOption,modelList,plotText): + print "Reading Schematic info for Model" #Insert details of Ngspice model unknownModelList = [] multipleModelList = [] @@ -162,8 +165,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 @@ -174,10 +177,10 @@ 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': xmlfile = compType+".xml" #XML Model File @@ -196,7 +199,7 @@ class PrcocessNetlist: unknownModelList.append(compType) elif count == 1: try: - print "Start Parsing :",modelPath + print "Start Parsing Previous Values XML for ngspice model :",modelPath tree = ET.parse(modelPath[0]) root = tree.getroot() @@ -220,7 +223,7 @@ class PrcocessNetlist: #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'])): @@ -238,9 +241,9 @@ class PrcocessNetlist: 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)+" " @@ -252,12 +255,12 @@ 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])): @@ -271,7 +274,7 @@ class PrcocessNetlist: 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]+" " pos += 1 @@ -281,7 +284,7 @@ class PrcocessNetlist: sys.exit(2) modelLine += compName - print "Final Model Line :",modelLine + #print "Final Model Line :",modelLine try: schematicInfo.append(modelLine) k=k+1 @@ -348,11 +351,9 @@ class PrcocessNetlist: else: schematicInfo.insert(index,"* "+compline) - - - #print "Count",count - #print "UnknownModelList",unknownModelList - #print "MultipleModelList",multipleModelList + print "UnknownModelList Used in the Schematic",unknownModelList + print "Multiple Model XML file with same name ",multipleModelList + print "Model List Details : ",modelList return schematicInfo,outputOption,modelList,unknownModelList,multipleModelList,plotText diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py index c1bec121..1cf1487d 100644 --- a/src/kicadtoNgspice/Source.py +++ b/src/kicadtoNgspice/Source.py @@ -1,12 +1,8 @@ -import sys import os from PyQt4 import QtGui -from Processing import PrcocessNetlist import TrackWidget from xml.etree import ElementTree as ET - - class Source(QtGui.QWidget): """ This class create Source Tab of KicadtoNgSpice Window. @@ -36,7 +32,6 @@ class Source(QtGui.QWidget): kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -47,7 +42,7 @@ class Source(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "Source Previous Values XML is Empty" self.grid = QtGui.QGridLayout() self.setLayout(self.grid) @@ -56,7 +51,7 @@ class Source(QtGui.QWidget): if sourcelist: for line in sourcelist: #print "Voltage source line index: ",line[0] - print "SourceList line Test: ",line + print "SourceList line: ",line track_id=line[0] #print "track_id is ",track_id if line[2]=='ac': @@ -277,7 +272,6 @@ class Source(QtGui.QWidget): self.row=self.row+1 self.count=self.count+1 self.end=self.count-1 - print "End",self.end expbox.setLayout(expgrid) #CSS diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py index fa51ac6a..e7a9ed66 100644 --- a/src/kicadtoNgspice/SubcircuitTab.py +++ b/src/kicadtoNgspice/SubcircuitTab.py @@ -3,11 +3,8 @@ from PyQt4 import QtGui import TrackWidget from projManagement import Validation import os -import sys from xml.etree import ElementTree as ET - - class SubcircuitTab(QtGui.QWidget): """ This class creates Subcircuit Tab in KicadtoNgspice Window @@ -15,11 +12,9 @@ class SubcircuitTab(QtGui.QWidget): """ def __init__(self,schematicInfo,clarg1): - kicadFile = clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) - print "PROJECT NAME---------",project_name check=1 try: f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') @@ -30,7 +25,7 @@ class SubcircuitTab(QtGui.QWidget): root=child except: check=0 - print "Empty XML" + print "Subcircuit Previous values XML is Empty" QtGui.QWidget.__init__(self) @@ -58,7 +53,7 @@ class SubcircuitTab(QtGui.QWidget): for eachline in schematicInfo: words = eachline.split() if eachline[0] == 'x': - print "Words",words[0] + print "Subcircuit : Words",words[0] self.obj_trac.subcircuitList[project_name+words[0]]=words self.subcircuit_dict_beg[words[0]]=self.count subbox=QtGui.QGroupBox() @@ -69,7 +64,6 @@ class SubcircuitTab(QtGui.QWidget): global path_name try: - print "ROOT ----===-=-",root for child in root: if child.tag[0]==eachline[0] and child.tag[1]==eachline[1]: print "Subcircuit MATCHING---",child.tag[0],child.tag[1],eachline[0],eachline[1] @@ -80,9 +74,9 @@ class SubcircuitTab(QtGui.QWidget): else: self.entry_var[self.count].setText("") except: - print "ERROR WHEN SET TEXT" + print "Error when set text of subcircuit" except: - print "ERROR BEFORE Subcircuit" + print "Error before subcircuit" subgrid.addWidget(self.entry_var[self.count],self.row,1) @@ -91,7 +85,7 @@ class SubcircuitTab(QtGui.QWidget): #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) - print "NUMPORTS",self.numPorts + print "Number of ports of sub circuit : ",self.numPorts self.addbtn.clicked.connect(self.trackSubcircuit) subgrid.addWidget(self.addbtn,self.row,2) subbox.setLayout(subgrid) @@ -125,7 +119,6 @@ class SubcircuitTab(QtGui.QWidget): """ This function is use to keep track of all Subcircuit widget """ - print "Calling Track Subcircuit function" sending_btn = self.sender() #print "Object Called is ",sending_btn.objectName() self.widgetObjCount = int(sending_btn.objectName()) |