diff options
-rw-r--r-- | src/frontEnd/Workspace.pyc | bin | 3469 -> 3497 bytes | |||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 104 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 51 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.pyc | bin | 4646 -> 5130 bytes | |||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 78 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 18 | ||||
-rw-r--r-- | src/kicadtoNgspice/TrackWidget.py | 8 | ||||
-rw-r--r-- | src/modelParamXML/Analog/gain.xml | 7 | ||||
-rw-r--r-- | src/modelParamXML/Analog/summer.xml | 8 | ||||
-rw-r--r-- | src/modelParamXML/Digital/gains.xml | 11 | ||||
-rw-r--r-- | src/projManagement/openProject.pyc | bin | 1731 -> 1835 bytes |
11 files changed, 236 insertions, 49 deletions
diff --git a/src/frontEnd/Workspace.pyc b/src/frontEnd/Workspace.pyc Binary files differindex 6e876bf3..2d2829a6 100644 --- a/src/frontEnd/Workspace.pyc +++ b/src/frontEnd/Workspace.pyc diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index fff00dab..18006e76 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -1,6 +1,9 @@ import os import sys +import TrackWidget + + class Convert: def __init__(self,sourcelisttrack,source_entry_var,schematicInfo): print "Start Conversion" @@ -107,9 +110,7 @@ class Convert: return self.schematicInfo - def addModelParameter(self,schematicInfo): - print "Schematic info after adding source detail",schematicInfo - + def analysisInsertor(self,ac_entry_var,dc_entry_var, tran_entry_var,set_checkbox,ac_parameter,dc_parameter,tran_parameter,ac_type): self.ac_entry_var = ac_entry_var self.dc_entry_var = dc_entry_var @@ -155,4 +156,99 @@ class Convert: return "e-12" else: return "e-00" -
\ No newline at end of file + + + def addModelParameter(self,schematicInfo): + print "Schematic info after adding source detail",schematicInfo + + #Create object of TrackWidget + self.obj_track = TrackWidget.TrackWidget() + + #List to store model line + addmodelLine = [] + modelParamValue = [] + + for line in self.obj_track.modelTrack: + print "Model Track :",line + if line[2] == 'transfo': + try: + start=line[5] + end=line[6] + num_turns=str(self.obj_track.model_entry_var[start].text()) + if num_turns=="": num_turns="310" + h_array= "H_array = [ " + b_array = "B_array = [ " + h1=str(self.obj_track.model_entry_var[start+1].text()) + b1=str(self.obj_track.model_entry_var[start+2].text()) + if len(h1)!=0 and len(b1)!=0: + h_array=h_array+h1+" " + 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]" + area=str(self.obj_track.model_entry_var[start+3].text()) + length=str(self.obj_track.model_entry_var[start+4].text()) + if area=="": area="1" + if length=="":length="0.01" + num_turns2=str(self.obj_track.model_entry_var[start+5].text()) + if num_turns2=="": num_turns2="620" + addmodelLine=".model "+line[3]+"_primary lcouple (num_turns= "+num_turns+")" + modelParamValue.append([line[0],addmodelLine,line[4]]) + addmodelLine=".model "+line[3]+"_iron_core core ("+bh_array+" area = "+area+" length ="+length +")" + modelParamValue.append([line[0],addmodelLine,line[4]]) + addmodelLine=".model "+line[3]+"_secondary lcouple (num_turns ="+num_turns2+ ")" + modelParamValue.append([line[0],addmodelLine,line[4]]) + except: + print "Caught an exception in transfo model ",line[1] + + else: + try: + start = line[5] + end = line[6] + addmodelLine=".model "+ line[3]+" "+line[2]+"(" + for key,value in line[9].iteritems(): + print "Tags: ",key + print "Value: ",value + #Checking for default value and accordingly assign param and default. + if ':' in key: + key = key.split(':') + param = key[0] + default = key[1] + else: + param = key + default = 0 + #Cheking if value is iterable.its for vector + if hasattr(value, '__iter__'): + addmodelLine += param+"=[" + for lineVar in value: + if str(self.obj_track.model_entry_var[lineVar].text()) == "": + paramVal = default + else: + paramVal = str(self.obj_track.model_entry_var[lineVar].text()) + addmodelLine += paramVal+" " + addmodelLine += "] " + else: + if str(self.obj_track.model_entry_var[value].text()) == "": + paramVal = default + else: + paramVal = str(self.obj_track.model_entry_var[value].text()) + + addmodelLine += param+"="+paramVal+" " + + + + + addmodelLine += ") " + modelParamValue.append([line[0],addmodelLine,line[4]]) + except: + print "Caught an exception in gain model ",line[1] + + + #Adding it to schematic + for item in modelParamValue: + schematicInfo.append(item[2]) #Adding Comment + schematicInfo.append(item[1]) #Adding model line + + + return schematicInfo +
\ No newline at end of file diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index 94d044db..bbde0842 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -66,7 +66,7 @@ class MainWindow(QtGui.QWidget): self.sourceTab.setWidgetResizable(True) self.modelTab = QtGui.QScrollArea() - self.modelTab.setWidget(Model.Model()) + self.modelTab.setWidget(Model.Model(schematicInfo,modelList)) #self.modelTabLayout = QtGui.QVBoxLayout(self.modelTab.widget()) self.modelTab.setWidgetResizable(True) @@ -93,23 +93,31 @@ class MainWindow(QtGui.QWidget): self.obj_track.source_entry_var["ITEMS"], schematicInfo) - #Adding Source Value to Schematic Info - schematicInfo = self.obj_convert.addSourceParameter() - #print "Schematic After adding source parameter",schematicInfo - schematicInfo = self.obj_convert.addModelParameter(schematicInfo) - - analysisoutput = self.obj_convert.analysisInsertor(self.obj_track.AC_entry_var["ITEMS"], - self.obj_track.DC_entry_var["ITEMS"], - self.obj_track.TRAN_entry_var["ITEMS"], - self.obj_track.set_CheckBox["ITEMS"], - self.obj_track.AC_Parameter["ITEMS"], - self.obj_track.DC_Parameter["ITEMS"], - self.obj_track.TRAN_Parameter["ITEMS"], - self.obj_track.AC_type["ITEMS"]) - - - - + try: + #Adding Source Value to Schematic Info + schematicInfo = self.obj_convert.addSourceParameter() + + #Adding Model Value to schematic Info + schematicInfo = self.obj_convert.addModelParameter(schematicInfo) + + analysisoutput = self.obj_convert.analysisInsertor(self.obj_track.AC_entry_var["ITEMS"], + self.obj_track.DC_entry_var["ITEMS"], + self.obj_track.TRAN_entry_var["ITEMS"], + self.obj_track.set_CheckBox["ITEMS"], + self.obj_track.AC_Parameter["ITEMS"], + self.obj_track.DC_Parameter["ITEMS"], + self.obj_track.TRAN_Parameter["ITEMS"], + self.obj_track.AC_type["ITEMS"]) + print "SchematicInfo after adding Model Details",schematicInfo + self.msg = "The Kicad to Ngspice Conversion completed successfully!!!!!!" + QtGui.QMessageBox.information(self, "Information", self.msg, QtGui.QMessageBox.Ok) + self.close() + except Exception as e: + print "Exception Message: ",e + print "SchematicInfo after adding Model Details",schematicInfo + print "There was error while converting kicad to ngspice" + self.close() + def main(args): @@ -164,7 +172,7 @@ def main(args): outputOption = [] schematicInfo,outputOption,modelList,unknownModelList,multipleModelList = obj_proc.convertICintoBasicBlocks(schematicInfo,outputOption,modelList) print "Unknown Model List",unknownModelList - print "Multple Model List",multipleModelList + print "Multiple Model List",multipleModelList print "Model List",modelList @@ -175,7 +183,7 @@ def main(args): sys.exit(2) else: if multipleModelList: - print "ErrorMessage: There are multiple model for same name. Please check it",multipleModelList + print "ErrorMessage: There are multiple model of same name. Please check it",multipleModelList sys.exit(2) else: pass @@ -186,8 +194,7 @@ def main(args): kingWindow = MainWindow() kingWindow.show() sys.exit(app.exec_()) - - + diff --git a/src/kicadtoNgspice/KicadtoNgspice.pyc b/src/kicadtoNgspice/KicadtoNgspice.pyc Binary files differindex b85fc3d8..b61ed5b2 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.pyc +++ b/src/kicadtoNgspice/KicadtoNgspice.pyc diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index 4e2f7865..79f47ce0 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -1,9 +1,83 @@ from PyQt4 import QtGui +import TrackWidget + + class Model(QtGui.QWidget): - def __init__(self): + def __init__(self,schematicInfo,modelList): QtGui.QWidget.__init__(self) print "Start Ngspice Modelling" - + print "Schematic Info in Model Widget",schematicInfo + print "Model List",modelList + + #Creating track widget object + self.obj_trac = TrackWidget.TrackWidget() + + #for increasing row and counting/tracking line edit widget + self.nextrow = 0 + self.nextcount = 0 + + #for storing line edit details position details + self.start = 0 + self.end = 0 + + #Creating GUI dynamically for Model tab + self.grid = QtGui.QGridLayout() + self.setLayout(self.grid) + + for line in modelList: + print "ModelList Item:",line + #Adding title label for model + #Key: Tag name,Value:Entry widget number + tag_dict = {} + titleLable = QtGui.QLabel(line[5]) + self.grid.addWidget(titleLable,self.nextrow,1) + self.start = self.nextcount + self.nextrow=self.nextrow+1 + #line[7] is parameter dictionary holding parameter tags. + for key,value in line[7].iteritems(): + print "Key : ",key + print "Value : ",value + #Check if value is iterable + if hasattr(value, '__iter__'): + #For tag having vector value + temp_tag = [] + for item in value: + paramLabel = QtGui.QLabel(item) + self.grid.addWidget(paramLabel,self.nextrow,0) + self.obj_trac.model_entry_var[self.nextcount]= QtGui.QLineEdit() + self.grid.addWidget(self.obj_trac.model_entry_var[self.nextcount],self.nextrow,1) + temp_tag.append(self.nextcount) + self.nextcount = self.nextcount+1 + self.nextrow = self.nextrow+1 + tag_dict[key] = temp_tag + else: + paramLabel = QtGui.QLabel(value) + self.grid.addWidget(paramLabel,self.nextrow,0) + self.obj_trac.model_entry_var[self.nextcount]= QtGui.QLineEdit() + self.grid.addWidget(self.obj_trac.model_entry_var[self.nextcount],self.nextrow,1) + tag_dict[key] = self.nextcount + self.nextcount = self.nextcount+1 + self.nextrow = self.nextrow+1 + self.end= self.nextcount-1 + ''' + Listing all + line[0] = index + line[1] = compLine + line[2] = compType + line[3] = compName + 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 + ''' + self.obj_trac.modelTrack.append([line[0],line[1],line[2],line[3],line[4],line[5],line[6],self.start,self.end,tag_dict]) + + print "The tag dictionary : ",tag_dict + + + + self.show() + diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index ce19877f..63f38bb2 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -264,7 +264,23 @@ class PrcocessNetlist: for item in param: #print "Tags ",item.tag #print "Value",item.text - paramDict[item.tag] = item.text + if 'vector'in item.attrib: + 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)) + temp_count += 1 + if 'default' in item.attrib: + paramDict[item.tag+":"+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 + else: + paramDict[item.tag] = item.text print "Number of Nodes : ",num_of_nodes diff --git a/src/kicadtoNgspice/TrackWidget.py b/src/kicadtoNgspice/TrackWidget.py index e2321656..3ecbd883 100644 --- a/src/kicadtoNgspice/TrackWidget.py +++ b/src/kicadtoNgspice/TrackWidget.py @@ -3,8 +3,11 @@ class TrackWidget: This Class track the widget of Kicad to NgSpice converter module. """ + #Track widget list for Source details sourcelisttrack = {"ITEMS":"None"} source_entry_var = {"ITEMS":"None"} + + #Track widget for analysis inserter details AC_entry_var = {"ITEMS":"None"} AC_Parameter = {"ITEMS":"None"} DC_entry_var = {"ITEMS":"None"} @@ -13,4 +16,7 @@ class TrackWidget: TRAN_Parameter = {"ITEMS":"None"} set_CheckBox = {"ITEMS":"None"} AC_type = {"ITEMS":"None"} -
\ No newline at end of file + + #Track widget for Model details + modelTrack = [] + model_entry_var = {}
\ No newline at end of file diff --git a/src/modelParamXML/Analog/gain.xml b/src/modelParamXML/Analog/gain.xml index 6e5788ed..20f00004 100644 --- a/src/modelParamXML/Analog/gain.xml +++ b/src/modelParamXML/Analog/gain.xml @@ -5,9 +5,8 @@ <title>Add Parameter for model gain</title> <split>None</split> <param> - <in_offset>Enter offset for input (default=0.0):</in_offset> - <gain>Enter gain (default=1.0):</gain> - <gain abc="OK">Enter gain (default=1.0):</gain> - <out_offset>Enter offset for output (default=0.0):</out_offset> + <in_offset default="0.0">Enter offset for input (default=0.0)</in_offset> + <gain vector="2" default="1.0">Enter gain (default=1.0)</gain> + <out_offset default="0.0">Enter offset for output (default=0.0)</out_offset> </param> </model>
\ No newline at end of file diff --git a/src/modelParamXML/Analog/summer.xml b/src/modelParamXML/Analog/summer.xml index 94c356b1..5f8b3d52 100644 --- a/src/modelParamXML/Analog/summer.xml +++ b/src/modelParamXML/Analog/summer.xml @@ -5,9 +5,9 @@ <title>Add parameters for Summer </title> <split>2-V:1-NV</split> <param> - <in_offset vector="2">Enter offset for input (default=0.0):</in_offset> - <in_gain vector="2">Enter gain for input 1 (default=1.0):</in_gain> - <out_gain>Enter gain for output (default=1.0):</out_gain> - <out_offset>Enter offset for output (default=0.0):</out_offset> + <in_offset vector="2" default="0.0">Enter offset for input (default=0.0):</in_offset> + <in_gain vector="2" default="1.0">Enter gain for input(default=1.0):</in_gain> + <out_gain default="1.0">Enter gain for output (default=1.0):</out_gain> + <out_offset default="0.0">Enter offset for output (default=0.0):</out_offset> </param> </model> diff --git a/src/modelParamXML/Digital/gains.xml b/src/modelParamXML/Digital/gains.xml deleted file mode 100644 index 2bce2a66..00000000 --- a/src/modelParamXML/Digital/gains.xml +++ /dev/null @@ -1,11 +0,0 @@ -<model> -<name>gain</name> -<type>Analog</type> -<node_number>2</node_number> -<title>Add Parameter for model gain</title> -<param> - <in_offset>Enter offset for input (default=0.0):</in_offset> - <gain>Enter gain (default=1.0):</gain> - <out_offset>Enter offset for output (default=0.0):</out_offset> -</param> -</model>
\ No newline at end of file diff --git a/src/projManagement/openProject.pyc b/src/projManagement/openProject.pyc Binary files differindex d9c56fee..441e488f 100644 --- a/src/projManagement/openProject.pyc +++ b/src/projManagement/openProject.pyc |