diff options
Diffstat (limited to 'src/kicadtoNgspice')
-rw-r--r-- | src/kicadtoNgspice/Analysis.py | 15 | ||||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 37 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 2 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 19 |
5 files changed, 61 insertions, 18 deletions
diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py index 7c237dde..27dc740f 100644 --- a/src/kicadtoNgspice/Analysis.py +++ b/src/kicadtoNgspice/Analysis.py @@ -422,7 +422,10 @@ class Analysis(QtGui.QWidget): self.start_combobox.addItem("ns") self.start_combobox.addItem("ps") self.trgrid.addWidget(self.start_combobox,1,3) - self.tran_parameter[self.parameter_cnt]= "Sec" + try: + self.tran_parameter[self.parameter_cnt]= str(root[2][3].text) + except: + self.tran_parameter[self.parameter_cnt]= "Sec" self.start_combobox.activated[str].connect(self.start_combo_change) self.parameter_cnt= self.parameter_cnt+1 @@ -433,7 +436,10 @@ class Analysis(QtGui.QWidget): self.step_combobox.addItem("ns") self.step_combobox.addItem("ps") self.trgrid.addWidget(self.step_combobox,2,3) - self.tran_parameter[self.parameter_cnt]= "Sec" + try: + self.tran_parameter[self.parameter_cnt]= str(root[2][4].text) + except: + self.tran_parameter[self.parameter_cnt]= "Sec" self.step_combobox.activated[str].connect(self.step_combo_change) self.parameter_cnt= self.parameter_cnt+1 @@ -444,7 +450,10 @@ class Analysis(QtGui.QWidget): self.stop_combobox.addItem("ns") self.stop_combobox.addItem("ps") self.trgrid.addWidget(self.stop_combobox,3,3) - self.tran_parameter[self.parameter_cnt]= "Sec" + try: + self.tran_parameter[self.parameter_cnt]= str(root[2][5].text) + except: + self.tran_parameter[self.parameter_cnt]= "Sec" self.stop_combobox.activated[str].connect(self.stop_combo_change) self.parameter_cnt= self.parameter_cnt+1 diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index baf842d9..3b87e863 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -227,8 +227,24 @@ class Convert: 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: + except Exception as e: print "Caught an exception in transfo model ",line[1] + print "Exception Message : ",str(e) + + elif line[2] == 'ic': + try: + start=line[5] + end=line[6] + for key,value in line[9].iteritems(): + initVal = str(self.obj_track.model_entry_var[value].text()) + if initVal=="":initVal="0" + node = line[1].split()[1] #Extracting node from model line + addmodelLine = ".ic v("+node+")="+initVal + modelParamValue.append([line[0],addmodelLine,line[4]]) + except Exception as e: + print "Caught an exception in initial condition ",line[1] + print "Exception Message : ",str(e) + else: try: @@ -264,21 +280,24 @@ class Convert: addmodelLine += param+"="+paramVal+" " - - - + addmodelLine += ") " modelParamValue.append([line[0],addmodelLine,line[4]]) - except: - print "Caught an exception in gain model ",line[1] + except Exception as e: + print "Caught an exception in model ",line[1] + print "Exception Message : ",str(e) #Adding it to schematic for item in modelParamValue: - schematicInfo.append(item[2]) #Adding Comment - schematicInfo.append(item[1]) #Adding model line - + if ".ic" in item[1]: + schematicInfo.insert(0,item[1]) + schematicInfo.insert(0,item[2]) + else: + schematicInfo.append(item[2]) #Adding Comment + schematicInfo.append(item[1]) #Adding model line + print "MYSCH------->",schematicInfo return schematicInfo def addDeviceLibrary(self,schematicInfo,kicadFile): diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index c9b5ac02..c3e9d637 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -544,7 +544,7 @@ class MainWindow(QtGui.QWidget): try: f = open(self.project+".cir.out") except : - print("Error in opening circuit file.") + print("Error in opening .cir.out file.") else: print self.projName + ".cir.out does not exist. Please create a spice netlist." diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index 984c47f0..d1edd5a6 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -15,7 +15,9 @@ class Model(QtGui.QWidget): def __init__(self,schematicInfo,modelList): + QtGui.QWidget.__init__(self) + #Processing for getting previous values kicadFile = sys.argv[1] (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) @@ -33,7 +35,7 @@ class Model(QtGui.QWidget): print "Empty XML" - QtGui.QWidget.__init__(self) + #Creating track widget object self.obj_trac = TrackWidget.TrackWidget() @@ -124,7 +126,7 @@ class Model(QtGui.QWidget): #This keeps the track of Model Tab Widget 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 diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index fa75320f..67e7dc9d 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -159,8 +159,10 @@ class PrcocessNetlist: for compline in schematicInfo: words = compline.split() compName = words[0] + print "Compline----------------->",compline + print "compName-------------->",compName # Find the IC from schematic - if compName[0]=='u': + if compName[0]=='u' or compName[0] == 'U': # Find the component from the circuit index=schematicInfo.index(compline) compType=words[len(words)-1]; @@ -174,7 +176,7 @@ class PrcocessNetlist: print "Words",words print "compName",compName #Looking if model file is present - if compType != "port": + if compType != "port" and compType != "ic": xmlfile = compType+".xml" #XML Model File count = 0 #Check if model of same name is present modelPath = [] @@ -281,11 +283,22 @@ class PrcocessNetlist: 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]) - except: + except Exception as e: print "Unable to parse the model, Please check your your XML file" + print "Exception Message : ",str(e) sys.exit(2) + elif compType == "ic": + schematicInfo.insert(index,"* "+compline) + modelname = "ic" + comment = "* "+compline + title = "Initial Condition for "+compName + type = "NA" #Its is not model + text = "Enter initial voltage at node for "+compline + paramDict[title] = text + modelList.append([index,compline,modelname,compName,comment,title,type,paramDict]) else: schematicInfo.insert(index,"* "+compline) + #print "Count",count #print "UnknownModelList",unknownModelList #print "MultipleModelList",multipleModelList |