diff options
author | fahim | 2015-06-05 17:23:39 +0530 |
---|---|---|
committer | fahim | 2015-06-05 17:23:39 +0530 |
commit | e68620ce4d4f8300059c384b2919acaf9c873374 (patch) | |
tree | f86367241a78e8441ed89e58454b7e72855487b7 /src/kicadtoNgspice/DeviceModel.py | |
parent | 687a4bf4cd1e027df9fb371d5c173c02d7db767b (diff) | |
download | eSim-e68620ce4d4f8300059c384b2919acaf9c873374.tar.gz eSim-e68620ce4d4f8300059c384b2919acaf9c873374.tar.bz2 eSim-e68620ce4d4f8300059c384b2919acaf9c873374.zip |
Subject: Changes for saving previouse values
Description: Changes for saving previouse values of component entered by
User.
Diffstat (limited to 'src/kicadtoNgspice/DeviceModel.py')
-rw-r--r-- | src/kicadtoNgspice/DeviceModel.py | 78 |
1 files changed, 75 insertions, 3 deletions
diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index 0ae421b6..56ffb7f1 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -1,4 +1,7 @@ from PyQt4 import QtGui +import sys +import os +from xml.etree import ElementTree as ET import TrackWidget @@ -10,6 +13,25 @@ class DeviceModel(QtGui.QWidget): """ def __init__(self,schematicInfo): + + kicadFile = sys.argv[1] + (projpath,filename)=os.path.split(kicadFile) + project_name=projpath.split("/") + project_name=project_name[len(project_name)-1] + print "PROJECT NAME---------",project_name + check=1 + try: + f=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r') + tree=ET.parse(f) + parent_root=tree.getroot() + for child in parent_root: + if child.tag=="devicemodel": + root=child + except: + check=0 + print "Empty XML" + + QtGui.QWidget.__init__(self) #Creating track widget object @@ -24,8 +46,8 @@ class DeviceModel(QtGui.QWidget): self.widthLabel = {} self.lengthLabel = {} self.multifactorLable = {} - - + self.devicemodel_dict_beg={} + self.devicemodel_dict_end={} #List to hold information about device self.deviceDetail = {} @@ -37,11 +59,22 @@ class DeviceModel(QtGui.QWidget): words = eachline.split() if eachline[0] == 'q': print "Words ",words[0] + self.devicemodel_dict_beg[words[0]]=self.count transbox=QtGui.QGroupBox() transgrid=QtGui.QGridLayout() transbox.setTitle("Add library for Transistor "+words[0]+" : "+words[4]) self.entry_var[self.count] = QtGui.QLineEdit() self.entry_var[self.count].setText("") + 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] + try: + self.entry_var[self.count].setText(child[0].text) + except: + print "ERROR WHEN SET TEXT" + except: + pass transgrid.addWidget(self.entry_var[self.count],self.row,1) self.addbtn = QtGui.QPushButton("Add") self.addbtn.setObjectName("%d" %self.count) @@ -62,15 +95,27 @@ class DeviceModel(QtGui.QWidget): #Increment row and widget count self.row = self.row+1 + self.devicemodel_dict_end[words[0]]=self.count self.count = self.count+1 elif eachline[0] == 'd': print "Words",words[0] + self.devicemodel_dict_beg[words[0]]=self.count diodebox=QtGui.QGroupBox() diodegrid=QtGui.QGridLayout() diodebox.setTitle("Add library for Diode "+words[0]+" : "+words[3]) self.entry_var[self.count] = QtGui.QLineEdit() self.entry_var[self.count].setText("") + 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] + try: + self.entry_var[self.count].setText(child[0].text) + except: + print "ERROR WHEN SET TEXT" + except: + pass diodegrid.addWidget(self.entry_var[self.count],self.row,1) self.addbtn = QtGui.QPushButton("Add") self.addbtn.setObjectName("%d" %self.count) @@ -91,15 +136,27 @@ class DeviceModel(QtGui.QWidget): #Increment row and widget count self.row = self.row+1 + self.devicemodel_dict_end[words[0]]=self.count self.count = self.count+1 elif eachline[0] == 'j': print "Words",words[0] + self.devicemodel_dict_beg[words[0]]=self.count jfetbox=QtGui.QGroupBox() jfetgrid=QtGui.QGridLayout() jfetbox.setTitle("Add library for JFET "+words[0]+" : "+words[4]) self.entry_var[self.count] = QtGui.QLineEdit() self.entry_var[self.count].setText("") + 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] + try: + self.entry_var[self.count].setText(child[0].text) + except: + print "ERROR WHEN SET TEXT" + except: + pass jfetgrid.addWidget(self.entry_var[self.count],self.row,1) self.addbtn = QtGui.QPushButton("Add") self.addbtn.setObjectName("%d" %self.count) @@ -120,13 +177,17 @@ class DeviceModel(QtGui.QWidget): #Increment row and widget count self.row = self.row+1 + self.devicemodel_dict_end[words[0]]=self.count self.count = self.count+1 elif eachline[0] == 'm': + self.devicemodel_dict_beg[words[0]]=self.count mosfetbox=QtGui.QGroupBox() mosfetgrid=QtGui.QGridLayout() + i=self.count + beg=self.count mosfetbox.setTitle("Add library for MOSFET "+words[0]+" : "+words[5]) self.entry_var[self.count] =QtGui.QLineEdit() self.entry_var[self.count].setText("") @@ -167,12 +228,22 @@ class DeviceModel(QtGui.QWidget): mosfetgrid.addWidget(self.multifactorLable[self.count],self.row,0) self.entry_var[self.count] = QtGui.QLineEdit() self.entry_var[self.count].setText("") + end=self.count self.entry_var[self.count].setMaximumWidth(150) mosfetgrid.addWidget(self.entry_var[self.count],self.row,1) self.row = self.row + 1 + self.devicemodel_dict_end[words[0]]=self.count self.count = self.count+1 mosfetbox.setLayout(mosfetgrid) - + 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] + while i<=end: + self.entry_var[i].setText(child[i-beg].text) + i=i+1 + except: + pass #CSS mosfetbox.setStyleSheet(" \ QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ @@ -180,6 +251,7 @@ class DeviceModel(QtGui.QWidget): ") self.grid.addWidget(mosfetbox) + self.show() |