diff options
author | fahim | 2015-06-26 15:20:04 +0530 |
---|---|---|
committer | fahim | 2015-06-26 15:20:04 +0530 |
commit | cccbbb3827b898b471131d905b197795ba4b5e5b (patch) | |
tree | 50fc073bc94f5552bf2ca5def13c7e338bbc0a0b | |
parent | 1de6706596194718b45ea0209538e70811bc3f4b (diff) | |
download | eSim-cccbbb3827b898b471131d905b197795ba4b5e5b.tar.gz eSim-cccbbb3827b898b471131d905b197795ba4b5e5b.tar.bz2 eSim-cccbbb3827b898b471131d905b197795ba4b5e5b.zip |
Subject: Added feature for initial voltage condition
Description: Added feature for initial voltage condition
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 37 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 19 | ||||
-rw-r--r-- | src/projManagement/Kicad.py | 2 |
4 files changed, 49 insertions, 15 deletions
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/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 diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index d7202b4f..fdaa3187 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -138,7 +138,7 @@ class Kicad: self.project = os.path.join(self.projDir,self.projName) #Creating a command to run - self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py "+self.project+".cir " + self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py " +self.project+".cir " self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() |