summaryrefslogtreecommitdiff
path: root/src/kicadtoNgspice/Processing.py
diff options
context:
space:
mode:
authorfahim2015-04-09 14:58:02 +0530
committerfahim2015-04-09 14:58:02 +0530
commit09278fca52c3d9779b86c97005f762c5719b88d9 (patch)
tree102d66c4cecfcae783da25ae3c29689a15cea778 /src/kicadtoNgspice/Processing.py
parente10b2de0bec4836b2dc134d56ed573ad1d633ce3 (diff)
downloadeSim-09278fca52c3d9779b86c97005f762c5719b88d9.tar.gz
eSim-09278fca52c3d9779b86c97005f762c5719b88d9.tar.bz2
eSim-09278fca52c3d9779b86c97005f762c5719b88d9.zip
Subject: Analysis inserter functionality
Description: Added by Komal
Diffstat (limited to 'src/kicadtoNgspice/Processing.py')
-rw-r--r--src/kicadtoNgspice/Processing.py78
1 files changed, 74 insertions, 4 deletions
diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py
index 3a2bcb37..ce19877f 100644
--- a/src/kicadtoNgspice/Processing.py
+++ b/src/kicadtoNgspice/Processing.py
@@ -216,6 +216,7 @@ class PrcocessNetlist:
index=schematicInfo.index(compline)
compType=words[len(words)-1];
schematicInfo.remove(compline)
+ paramDict = {}
print "Compline",compline
print "CompType",compType
print "Words",words
@@ -230,20 +231,89 @@ class PrcocessNetlist:
if xmlfile in all_file:
count += 1
modelPath.append(os.path.join(each_dir,xmlfile))
-
+
if count > 1:
multipleModelList.append(modelPath)
elif count == 0:
unknownModelList.append(compType)
elif count == 1:
try:
+ print "Start Parsing :",modelPath
tree = ET.parse(modelPath[0])
- #root = parsemodel.getroot()
+
+ root = tree.getroot()
+ #Getting number of nodes for model and title
for child in tree.iter():
- print "Child Item",child
+ if child.tag == 'node_number':
+ num_of_nodes = int(child.text)
+ elif child.tag == 'title':
+ title = child.text+" "+compName
+ elif child.tag == 'name':
+ modelname = child.text
+ elif child.tag == 'type':
+ #Checking for Analog and Digital
+ type = child.text
+ elif child.tag == 'split':
+ splitDetail = child.text
+
+ #print "Child Item",child
#print "Tag",child.tag
#print "Tag Value",child.text
-
+
+ for param in tree.findall('param'):
+ for item in param:
+ #print "Tags ",item.tag
+ #print "Value",item.text
+ paramDict[item.tag] = item.text
+
+
+ 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)+" "
+ for i in range(1,num_of_nodes+1):
+ modelLine += words[i]+" "
+ modelLine += compName
+
+ else:
+ print "Split Details :",splitDetail
+ modelLine = "a"+str(k)+" "
+ vectorDetail = splitDetail.split(':')
+ print "Vector Details",vectorDetail
+ pos = 1 #Node position
+ for item in vectorDetail:
+ try:
+ if item.split("-")[1] == 'V':
+ print "Vector"
+ modelLine += "["
+ for i in range(0,int(item.split("-")[0])):
+ modelLine += words[pos]+" "
+ pos += 1
+ modelLine += "] "
+ elif item.split("-")[1] == 'NV':
+ print "Non Vector"
+ for i in range(0,int(item.split("-")[0])):
+ modelLine += words[pos]+" "
+ pos += 1
+
+ except:
+ print "There is error while processing Vector Details"
+ sys.exit(2)
+ modelLine += compName
+
+ print "Final Model Line :",modelLine
+ try:
+ schematicInfo.append(modelLine)
+ k=k+1
+ except Exception as e:
+ print "Error while appending ModelLine ",modelLine
+ print "Excpetion Message : ",str(e)
+ #Insert comment at remove line
+ schematicInfo.insert(index,"* "+compline)
+ comment = "* "+modelname+" "+compType
+ modelList.append([index,compline,compType,compName,comment,title,type,paramDict])
except:
print "Unable to parse the model, Please check your your xml file"
sys.exit(2)