From 687a4bf4cd1e027df9fb371d5c173c02d7db767b Mon Sep 17 00:00:00 2001 From: fahim Date: Fri, 5 Jun 2015 12:25:17 +0530 Subject: Subject: Changes in device library,ModelEditor.py,Convert.py. Added more kicad library Description: Changes in device library,ModelEditor.py,Convert.py. Added more --- src/deviceModelLibrary/Diode/D.lib | 23 +++- src/deviceModelLibrary/Diode/D.xml | 24 +--- src/deviceModelLibrary/IGBT/NIGBT.lib | 21 +-- src/deviceModelLibrary/IGBT/NIGBT.xml | 15 +-- src/deviceModelLibrary/IGBT/PIGBT.xml | 2 +- src/deviceModelLibrary/JFET/NJF.xml | 2 +- src/deviceModelLibrary/JFET/PJF.xml | 2 +- src/deviceModelLibrary/MOS/NMOS-0.5um.xml | 2 +- src/deviceModelLibrary/MOS/NMOS-180nm.xml | 2 +- src/deviceModelLibrary/MOS/NMOS-5um.xml | 2 +- src/deviceModelLibrary/MOS/PMOS-0.5um.xml | 2 +- src/deviceModelLibrary/MOS/PMOS-180nm.xml | 2 +- src/deviceModelLibrary/MOS/PMOS-5um.xml | 2 +- src/deviceModelLibrary/Misc/CORE.lib | 11 +- src/deviceModelLibrary/Misc/CORE.xml | 12 +- src/deviceModelLibrary/Templates/CORE.lib | 11 +- src/deviceModelLibrary/Templates/CORE.xml | 12 +- src/deviceModelLibrary/Templates/D.xml | 2 +- src/deviceModelLibrary/Templates/NIGBT.xml | 2 +- src/deviceModelLibrary/Templates/NJF.xml | 2 +- src/deviceModelLibrary/Templates/NMOS-0.5um.xml | 2 +- src/deviceModelLibrary/Templates/NMOS-180nm.xml | 2 +- src/deviceModelLibrary/Templates/NMOS-5um.xml | 2 +- src/deviceModelLibrary/Templates/NPN.xml | 2 +- src/deviceModelLibrary/Templates/PIGBT.xml | 2 +- src/deviceModelLibrary/Templates/PJF.xml | 2 +- src/deviceModelLibrary/Templates/PMOS-0.5um.xml | 2 +- src/deviceModelLibrary/Templates/PMOS-180nm.xml | 2 +- src/deviceModelLibrary/Templates/PMOS-5um.xml | 2 +- src/deviceModelLibrary/Templates/PNP.xml | 2 +- .../User Libraries/userDiode.lib | 20 +++ .../User Libraries/userDiode.xml | 1 + src/frontEnd/Application.py | 1 - src/kicadtoNgspice/Convert.py | 2 +- src/modelEditor/ModelEditor.py | 149 ++++++++++++++++++--- 35 files changed, 233 insertions(+), 113 deletions(-) create mode 100644 src/deviceModelLibrary/User Libraries/userDiode.lib create mode 100644 src/deviceModelLibrary/User Libraries/userDiode.xml (limited to 'src') diff --git a/src/deviceModelLibrary/Diode/D.lib b/src/deviceModelLibrary/Diode/D.lib index 890c37fe..ef18bb50 100755 --- a/src/deviceModelLibrary/Diode/D.lib +++ b/src/deviceModelLibrary/Diode/D.lib @@ -1,3 +1,20 @@ -.model D1N750 D( Is=880.5E-18 Rs=.25 Ikf=0 N=1 Xti=3 Eg=1.11 Cjo=175p M=.5516 -+ Vj=.75 Fc=.5 Isr=1.859n Nr=2 Bv=8.1 Ibv=20.245m Nbv=1.6989 Ibvl=1.9556m -+ Nbvl=14.976 Tbv1=-21.277u) +.MODEL D1N750 D( ++ Vj=.75 ++ Nbvl=14.976 ++ Cjo=175p ++ Rs=.25 ++ Isr=1.859n ++ Eg=1.11 ++ M=.5516 ++ Nbv=1.6989 ++ N=1 ++ Tbv1=-21.277u ++ Bv=8.1 ++ Fc=.5 ++ Ikf=0 ++ Nr=2 ++ Ibv=20.245m ++ Is=880.5E-18 ++ Xti=3 ++ Ibvl=1.9556m +) \ No newline at end of file diff --git a/src/deviceModelLibrary/Diode/D.xml b/src/deviceModelLibrary/Diode/D.xml index 61312a8a..8b806d17 100644 --- a/src/deviceModelLibrary/Diode/D.xml +++ b/src/deviceModelLibrary/Diode/D.xml @@ -1,24 +1,4 @@ D -D1N750 - - 880.5E-18 - .25 - 0 - 1 - 3 - 1.11 - 175p - .5516 - .75 - .5 - 1.859n - 2 - 8.1 - 20.245m - 1.6989 - 1.9556m - 14.976 - -21.277u - - +D1N750 +.7514.976175p.251.859n1.11.55161.69891-21.277u8.1.50220.245m880.5E-1831.9556m \ No newline at end of file diff --git a/src/deviceModelLibrary/IGBT/NIGBT.lib b/src/deviceModelLibrary/IGBT/NIGBT.lib index 8c09dcbc..86cd1b4e 100755 --- a/src/deviceModelLibrary/IGBT/NIGBT.lib +++ b/src/deviceModelLibrary/IGBT/NIGBT.lib @@ -1,10 +1,11 @@ -.MODEL IXGH40N60 NIGBT ( -+ TAU=287.56E-9 -+ KP=50.034 -+ AREA=37.500E-6 -+ AGD=18.750E-6 -+ VT=4.1822 -+ KF=.36047 -+ CGS=31.942E-9 -+ COXD=53.188E-9 -+ VTD=2.6570) +.MODEL IXGH40N60 NIGBT( ++ TAU=287.56E-9 ++ KF=.36047 ++ AREA=37.500E-6 ++ AGD=18.750E-6 ++ KP=50.034 ++ VT=4.1822 ++ CGS=31.942E-9 ++ COXD=53.188E-9 ++ VTD=2.6570 +) \ No newline at end of file diff --git a/src/deviceModelLibrary/IGBT/NIGBT.xml b/src/deviceModelLibrary/IGBT/NIGBT.xml index a945522a..38d9d094 100644 --- a/src/deviceModelLibrary/IGBT/NIGBT.xml +++ b/src/deviceModelLibrary/IGBT/NIGBT.xml @@ -1,15 +1,4 @@ NIGBT -IXGH40N60 - -287.56E-9 -50.034 -37.500E-6 -18.750E-6 -4.1822 -.36047 -31.942E-9 -53.188E-9 -2.6570 - - +IXGH40N60 +287.56E-9.3604737.500E-618.750E-650.0344.182231.942E-953.188E-92.6570 \ No newline at end of file diff --git a/src/deviceModelLibrary/IGBT/PIGBT.xml b/src/deviceModelLibrary/IGBT/PIGBT.xml index 2e316860..1e57f2e3 100644 --- a/src/deviceModelLibrary/IGBT/PIGBT.xml +++ b/src/deviceModelLibrary/IGBT/PIGBT.xml @@ -1,6 +1,6 @@ PIGBT -IXGH40N60 +IXGH40N60 287.56E-9 50.034 diff --git a/src/deviceModelLibrary/JFET/NJF.xml b/src/deviceModelLibrary/JFET/NJF.xml index 1b73fc73..94753691 100644 --- a/src/deviceModelLibrary/JFET/NJF.xml +++ b/src/deviceModelLibrary/JFET/NJF.xml @@ -1,6 +1,6 @@ NJF -J2N3819 +J2N3819 1.304m -.5 diff --git a/src/deviceModelLibrary/JFET/PJF.xml b/src/deviceModelLibrary/JFET/PJF.xml index 05184f6f..f682f8cb 100644 --- a/src/deviceModelLibrary/JFET/PJF.xml +++ b/src/deviceModelLibrary/JFET/PJF.xml @@ -1,6 +1,6 @@ PJF -J2N3820 +J2N3820 1.304m -.5 diff --git a/src/deviceModelLibrary/MOS/NMOS-0.5um.xml b/src/deviceModelLibrary/MOS/NMOS-0.5um.xml index 9ee36496..08fdf0e3 100644 --- a/src/deviceModelLibrary/MOS/NMOS-0.5um.xml +++ b/src/deviceModelLibrary/MOS/NMOS-0.5um.xml @@ -1,6 +1,6 @@ NMOS -mos_n +mos_n 1 9.5n diff --git a/src/deviceModelLibrary/MOS/NMOS-180nm.xml b/src/deviceModelLibrary/MOS/NMOS-180nm.xml index fc3b7a47..d0249bb6 100644 --- a/src/deviceModelLibrary/MOS/NMOS-180nm.xml +++ b/src/deviceModelLibrary/MOS/NMOS-180nm.xml @@ -1,6 +1,6 @@ NMOS -CMOSN +CMOSN 8 3.2 diff --git a/src/deviceModelLibrary/MOS/NMOS-5um.xml b/src/deviceModelLibrary/MOS/NMOS-5um.xml index a72abbf1..358fbdbe 100644 --- a/src/deviceModelLibrary/MOS/NMOS-5um.xml +++ b/src/deviceModelLibrary/MOS/NMOS-5um.xml @@ -1,6 +1,6 @@ NMOS -mos_n +mos_n 0.4n 85n diff --git a/src/deviceModelLibrary/MOS/PMOS-0.5um.xml b/src/deviceModelLibrary/MOS/PMOS-0.5um.xml index a4555169..013d461c 100644 --- a/src/deviceModelLibrary/MOS/PMOS-0.5um.xml +++ b/src/deviceModelLibrary/MOS/PMOS-0.5um.xml @@ -1,6 +1,6 @@ PMOS -mos_p +mos_p -1 9.5n diff --git a/src/deviceModelLibrary/MOS/PMOS-180nm.xml b/src/deviceModelLibrary/MOS/PMOS-180nm.xml index 99916972..6696752d 100644 --- a/src/deviceModelLibrary/MOS/PMOS-180nm.xml +++ b/src/deviceModelLibrary/MOS/PMOS-180nm.xml @@ -1,6 +1,6 @@ PMOS -CMOSP +CMOSP 8 3.2 diff --git a/src/deviceModelLibrary/MOS/PMOS-5um.xml b/src/deviceModelLibrary/MOS/PMOS-5um.xml index b82c5ae6..f68bada2 100644 --- a/src/deviceModelLibrary/MOS/PMOS-5um.xml +++ b/src/deviceModelLibrary/MOS/PMOS-5um.xml @@ -1,6 +1,6 @@ PMOS -mos_p +mos_p 0.4n 85n diff --git a/src/deviceModelLibrary/Misc/CORE.lib b/src/deviceModelLibrary/Misc/CORE.lib index c48c4b51..a7581029 100755 --- a/src/deviceModelLibrary/Misc/CORE.lib +++ b/src/deviceModelLibrary/Misc/CORE.lib @@ -1,2 +1,9 @@ -.model K3019PL_3C8 Core(MS=415.2K A=44.82 C=.4112 K=25.74 -+ Area=1.38 Path=4.52) +.MODEL K3019PL_3C8 Core( ++ A=44.82 ++ C=.4112 ++ abc=123 ++ Area=1.38 ++ K=25.74 ++ MS=415.2K ++ Path=4.52 +) \ No newline at end of file diff --git a/src/deviceModelLibrary/Misc/CORE.xml b/src/deviceModelLibrary/Misc/CORE.xml index 09129f74..c95d9db0 100644 --- a/src/deviceModelLibrary/Misc/CORE.xml +++ b/src/deviceModelLibrary/Misc/CORE.xml @@ -1,12 +1,4 @@ Core -K3019PL_3C8 - -415.2K -44.82 -.4112 -25.74 -1.38 -4.52 - - +K3019PL_3C8 +44.82 .41121231.3825.74415.2K4.52 diff --git a/src/deviceModelLibrary/Templates/CORE.lib b/src/deviceModelLibrary/Templates/CORE.lib index c48c4b51..a7581029 100755 --- a/src/deviceModelLibrary/Templates/CORE.lib +++ b/src/deviceModelLibrary/Templates/CORE.lib @@ -1,2 +1,9 @@ -.model K3019PL_3C8 Core(MS=415.2K A=44.82 C=.4112 K=25.74 -+ Area=1.38 Path=4.52) +.MODEL K3019PL_3C8 Core( ++ A=44.82 ++ C=.4112 ++ abc=123 ++ Area=1.38 ++ K=25.74 ++ MS=415.2K ++ Path=4.52 +) \ No newline at end of file diff --git a/src/deviceModelLibrary/Templates/CORE.xml b/src/deviceModelLibrary/Templates/CORE.xml index 09129f74..c95d9db0 100644 --- a/src/deviceModelLibrary/Templates/CORE.xml +++ b/src/deviceModelLibrary/Templates/CORE.xml @@ -1,12 +1,4 @@ Core -K3019PL_3C8 - -415.2K -44.82 -.4112 -25.74 -1.38 -4.52 - - +K3019PL_3C8 +44.82 .41121231.3825.74415.2K4.52 diff --git a/src/deviceModelLibrary/Templates/D.xml b/src/deviceModelLibrary/Templates/D.xml index 61312a8a..546d1156 100644 --- a/src/deviceModelLibrary/Templates/D.xml +++ b/src/deviceModelLibrary/Templates/D.xml @@ -1,6 +1,6 @@ D -D1N750 +D1N750 880.5E-18 .25 diff --git a/src/deviceModelLibrary/Templates/NIGBT.xml b/src/deviceModelLibrary/Templates/NIGBT.xml index a945522a..97f33196 100644 --- a/src/deviceModelLibrary/Templates/NIGBT.xml +++ b/src/deviceModelLibrary/Templates/NIGBT.xml @@ -1,6 +1,6 @@ NIGBT -IXGH40N60 +IXGH40N60 287.56E-9 50.034 diff --git a/src/deviceModelLibrary/Templates/NJF.xml b/src/deviceModelLibrary/Templates/NJF.xml index 1b73fc73..94753691 100644 --- a/src/deviceModelLibrary/Templates/NJF.xml +++ b/src/deviceModelLibrary/Templates/NJF.xml @@ -1,6 +1,6 @@ NJF -J2N3819 +J2N3819 1.304m -.5 diff --git a/src/deviceModelLibrary/Templates/NMOS-0.5um.xml b/src/deviceModelLibrary/Templates/NMOS-0.5um.xml index 9ee36496..08fdf0e3 100644 --- a/src/deviceModelLibrary/Templates/NMOS-0.5um.xml +++ b/src/deviceModelLibrary/Templates/NMOS-0.5um.xml @@ -1,6 +1,6 @@ NMOS -mos_n +mos_n 1 9.5n diff --git a/src/deviceModelLibrary/Templates/NMOS-180nm.xml b/src/deviceModelLibrary/Templates/NMOS-180nm.xml index fc3b7a47..d0249bb6 100644 --- a/src/deviceModelLibrary/Templates/NMOS-180nm.xml +++ b/src/deviceModelLibrary/Templates/NMOS-180nm.xml @@ -1,6 +1,6 @@ NMOS -CMOSN +CMOSN 8 3.2 diff --git a/src/deviceModelLibrary/Templates/NMOS-5um.xml b/src/deviceModelLibrary/Templates/NMOS-5um.xml index a72abbf1..358fbdbe 100644 --- a/src/deviceModelLibrary/Templates/NMOS-5um.xml +++ b/src/deviceModelLibrary/Templates/NMOS-5um.xml @@ -1,6 +1,6 @@ NMOS -mos_n +mos_n 0.4n 85n diff --git a/src/deviceModelLibrary/Templates/NPN.xml b/src/deviceModelLibrary/Templates/NPN.xml index f0679885..b2698bb1 100644 --- a/src/deviceModelLibrary/Templates/NPN.xml +++ b/src/deviceModelLibrary/Templates/NPN.xml @@ -1,6 +1,6 @@ NPN -Q2N2222 +Q2N2222 14.34f 3 diff --git a/src/deviceModelLibrary/Templates/PIGBT.xml b/src/deviceModelLibrary/Templates/PIGBT.xml index 2e316860..1e57f2e3 100644 --- a/src/deviceModelLibrary/Templates/PIGBT.xml +++ b/src/deviceModelLibrary/Templates/PIGBT.xml @@ -1,6 +1,6 @@ PIGBT -IXGH40N60 +IXGH40N60 287.56E-9 50.034 diff --git a/src/deviceModelLibrary/Templates/PJF.xml b/src/deviceModelLibrary/Templates/PJF.xml index 05184f6f..f682f8cb 100644 --- a/src/deviceModelLibrary/Templates/PJF.xml +++ b/src/deviceModelLibrary/Templates/PJF.xml @@ -1,6 +1,6 @@ PJF -J2N3820 +J2N3820 1.304m -.5 diff --git a/src/deviceModelLibrary/Templates/PMOS-0.5um.xml b/src/deviceModelLibrary/Templates/PMOS-0.5um.xml index a4555169..013d461c 100644 --- a/src/deviceModelLibrary/Templates/PMOS-0.5um.xml +++ b/src/deviceModelLibrary/Templates/PMOS-0.5um.xml @@ -1,6 +1,6 @@ PMOS -mos_p +mos_p -1 9.5n diff --git a/src/deviceModelLibrary/Templates/PMOS-180nm.xml b/src/deviceModelLibrary/Templates/PMOS-180nm.xml index 99916972..6696752d 100644 --- a/src/deviceModelLibrary/Templates/PMOS-180nm.xml +++ b/src/deviceModelLibrary/Templates/PMOS-180nm.xml @@ -1,6 +1,6 @@ PMOS -CMOSP +CMOSP 8 3.2 diff --git a/src/deviceModelLibrary/Templates/PMOS-5um.xml b/src/deviceModelLibrary/Templates/PMOS-5um.xml index b82c5ae6..f68bada2 100644 --- a/src/deviceModelLibrary/Templates/PMOS-5um.xml +++ b/src/deviceModelLibrary/Templates/PMOS-5um.xml @@ -1,6 +1,6 @@ PMOS -mos_p +mos_p 0.4n 85n diff --git a/src/deviceModelLibrary/Templates/PNP.xml b/src/deviceModelLibrary/Templates/PNP.xml index a25276a9..681b3fd9 100644 --- a/src/deviceModelLibrary/Templates/PNP.xml +++ b/src/deviceModelLibrary/Templates/PNP.xml @@ -1,6 +1,6 @@ PNP -Q2N2907A +Q2N2907A 650.6E-18 3 diff --git a/src/deviceModelLibrary/User Libraries/userDiode.lib b/src/deviceModelLibrary/User Libraries/userDiode.lib new file mode 100644 index 00000000..ef18bb50 --- /dev/null +++ b/src/deviceModelLibrary/User Libraries/userDiode.lib @@ -0,0 +1,20 @@ +.MODEL D1N750 D( ++ Vj=.75 ++ Nbvl=14.976 ++ Cjo=175p ++ Rs=.25 ++ Isr=1.859n ++ Eg=1.11 ++ M=.5516 ++ Nbv=1.6989 ++ N=1 ++ Tbv1=-21.277u ++ Bv=8.1 ++ Fc=.5 ++ Ikf=0 ++ Nr=2 ++ Ibv=20.245m ++ Is=880.5E-18 ++ Xti=3 ++ Ibvl=1.9556m +) \ No newline at end of file diff --git a/src/deviceModelLibrary/User Libraries/userDiode.xml b/src/deviceModelLibrary/User Libraries/userDiode.xml new file mode 100644 index 00000000..d8584e1d --- /dev/null +++ b/src/deviceModelLibrary/User Libraries/userDiode.xml @@ -0,0 +1 @@ +DD1N750880.5E-1814.976175p.251.859n1.11.55161.69891-21.277u8.1.5032.7520.245m1.9556m \ No newline at end of file diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index e4bddac9..c08c1974 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -29,7 +29,6 @@ import DockArea import os import sys import time -import shutil from PyQt4.Qt import QSize class Application(QtGui.QMainWindow): diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 3610382a..25576f53 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -356,7 +356,7 @@ class Convert: #Extracting Value from XML libtree = ET.parse(library) for child in libtree.iter(): - if child.tag == 'refrence': + if child.tag == 'ref_model': retVal = child.text else: pass diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index 0ce32a61..68f0735c 100644 --- a/src/modelEditor/ModelEditor.py +++ b/src/modelEditor/ModelEditor.py @@ -3,6 +3,7 @@ from PyQt4.Qt import QTableWidgetItem import xml.etree.ElementTree as ET import os + class ModelEditorclass(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) @@ -12,6 +13,8 @@ class ModelEditorclass(QtGui.QWidget): self.splitter= QtGui.QSplitter() self.grid= QtGui.QGridLayout() self.splitter.setOrientation(QtCore.Qt.Vertical) + + self.modeltable = QtGui.QTableWidget() self.newbtn = QtGui.QPushButton('New') self.newbtn.clicked.connect(self.opennew) @@ -26,10 +29,12 @@ class ModelEditorclass(QtGui.QWidget): self.addbtn = QtGui.QPushButton('Add') self.addbtn.setHidden(True) self.addbtn.clicked.connect(self.addparameters) - #self.splitter.addWidget(self.newbtn) + self.uploadbtn = QtGui.QPushButton('Upload') + self.uploadbtn.clicked.connect(self.converttoxml) self.grid.addWidget(self.newbtn, 1,2) self.grid.addWidget(self.editbtn, 1,3) self.grid.addWidget(self.savebtn, 1,4) + self.grid.addWidget(self.uploadbtn, 1,5) self.grid.addWidget(self.removebtn, 8,4) self.grid.addWidget(self.addbtn, 5,4) @@ -70,10 +75,7 @@ class ModelEditorclass(QtGui.QWidget): self.grid.addWidget(self.jfet,6,1) self.grid.addWidget(self.igbt,7,1) self.grid.addWidget(self.magnetic,8,1) - - #self.layout.addWidget(self.splitter) self.setLayout(self.grid) - #self.setLayout(self.layout) self.show() '''To create New Model file ''' @@ -83,6 +85,7 @@ class ModelEditorclass(QtGui.QWidget): self.modeltable.setHidden(True) except: pass + os.chdir(self.savepathtest) text, ok = QtGui.QInputDialog.getText(self, 'New Model','Enter Model Name:') if ok: self.newflag=1 @@ -215,6 +218,7 @@ class ModelEditorclass(QtGui.QWidget): pass def openedit(self): + os.chdir(self.savepathtest) self.newflag=0 self.addbtn.setHidden(True) self.types.setHidden(True) @@ -225,7 +229,6 @@ class ModelEditorclass(QtGui.QWidget): self.bjt.setDisabled(True) self.magnetic.setDisabled(True) self.editfile=str(QtGui.QFileDialog.getOpenFileName(self)) - #self.path='/home/workspace/eSim/src/deviceModelLibrary/Diode' self.createtable(self.editfile) '''Creates the model table by parsinf th .xml file ''' @@ -244,8 +247,8 @@ class ModelEditorclass(QtGui.QWidget): self.tree = ET.parse(self.modelfile) self.root= self.tree.getroot() - for elem in self.tree.iter(tag='refrence'): - self.reference = elem.text + for elem in self.tree.iter(tag='ref_model'): + self.ref_model = elem.text for elem in self.tree.iter(tag='model_name'): self.model_name = elem.text row=0 @@ -311,7 +314,7 @@ class ModelEditorclass(QtGui.QWidget): def createXML(self,model_name): root = ET.Element("library") ET.SubElement(root, "model_name").text = model_name - ET.SubElement(root, "refrence").text = self.modelname + ET.SubElement(root, "ref_model").text = self.modelname param = ET.SubElement(root, "param") for tags, text in self.modeldict.items(): ET.SubElement(param, tags).text = text @@ -324,7 +327,7 @@ class ModelEditorclass(QtGui.QWidget): txtfile = open(self.modelname+'.lib', 'w') txtfile.write('.MODEL ' + self.modelname +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - txtfile.write('+ ' + tags + ' = ' + text +'\n') + txtfile.write('+ ' + tags + '=' + text +'\n') txtfile.write(')') tree.write(self.modelname +".xml") if self.mos.isChecked(): @@ -333,7 +336,7 @@ class ModelEditorclass(QtGui.QWidget): txtfile = open(self.modelname+'.lib', 'w') txtfile.write('.MODEL ' + self.modelname +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - txtfile.write('+ ' + tags + ' = ' + text +'\n') + txtfile.write('+ ' + tags + '=' + text +'\n') txtfile.write(')') tree.write(self.modelname +".xml") if self.jfet.isChecked(): @@ -342,7 +345,7 @@ class ModelEditorclass(QtGui.QWidget): txtfile = open(self.modelname+'.lib', 'w') txtfile.write('.MODEL ' + self.modelname +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - txtfile.write('+ ' + tags + ' = ' + text +'\n') + txtfile.write('+ ' + tags + '=' + text +'\n') txtfile.write(')') tree.write(self.modelname +".xml") if self.igbt.isChecked(): @@ -351,7 +354,7 @@ class ModelEditorclass(QtGui.QWidget): txtfile = open(self.modelname+'.lib', 'w') txtfile.write('.MODEL ' + self.modelname +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - txtfile.write('+ ' + tags + ' = ' + text +'\n') + txtfile.write('+ ' + tags + '=' + text +'\n') txtfile.write(')') tree.write(self.modelname +".xml") if self.magnetic.isChecked(): @@ -360,7 +363,7 @@ class ModelEditorclass(QtGui.QWidget): txtfile = open(self.modelname+'.lib', 'w') txtfile.write('.MODEL ' + self.modelname +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - txtfile.write('+ ' + tags + ' = ' + text +'\n') + txtfile.write('+ ' + tags + '=' + text +'\n') txtfile.write(')') tree.write(self.modelname +".xml") if self.bjt.isChecked(): @@ -369,7 +372,7 @@ class ModelEditorclass(QtGui.QWidget): txtfile = open(self.modelname+'.lib', 'w') txtfile.write('.MODEL ' + self.modelname +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - txtfile.write('+ ' + tags + ' = ' + text +'\n') + txtfile.write('+ ' + tags + '=' + text +'\n') txtfile.write(')') tree.write(self.modelname +".xml") txtfile.close() @@ -378,6 +381,7 @@ class ModelEditorclass(QtGui.QWidget): '''Checks if the file with the name already exists''' def validation(self,text): newfilename = text+'.xml' + all_dir = [x[0] for x in os.walk(self.savepathtest)] for each_dir in all_dir: all_files = os.listdir(each_dir) @@ -393,9 +397,9 @@ class ModelEditorclass(QtGui.QWidget): filename = os.path.splitext(file)[0] libpath = os.path.join(xmlpath,filename+'.lib') libfile = open(libpath, 'w') - libfile.write('.MODEL ' + self.reference +' ' + self.model_name + '(\n' ) + libfile.write('.MODEL ' + self.ref_model +' ' + self.model_name + '(\n' ) for tags, text in self.modeldict.items(): - libfile.write('+ ' + tags + ' = ' + text +'\n') + libfile.write('+ ' + tags + '=' + text +'\n') libfile.write(')') libfile.close() for params in self.tree.findall('param'): @@ -412,4 +416,115 @@ class ModelEditorclass(QtGui.QWidget): remove_item = self.modeltable.item(index.row(),0).text() self.modeltable.removeRow(index.row()) del self.modeldict[str(remove_item)] - \ No newline at end of file + + def converttoxml(self): + os.chdir(self.savepathtest) + self.addbtn.setHidden(True) + self.removebtn.setHidden(True) + self.modeltable.setHidden(True) + model_dict = {} + stringof = [] + self.libfile = str(QtGui.QFileDialog.getOpenFileName(self)) + libopen = open(self.libfile) + filedata = libopen.read().split() + modelcount=0 + for words in filedata: + modelcount= modelcount +1 + if words.lower() == '.model': + print "model found" + break + ref_model = filedata[modelcount] + model_name = filedata[modelcount+1] + model_name = list(model_name) + modelnamecnt= 0 + flag= 0 + for chars in model_name: + modelnamecnt = modelnamecnt +1 + if chars == '(': + flag = 1 + break + if flag == 1 : + model_name = ''.join(model_name[0:modelnamecnt-1]) + else: + model_name = ''.join(model_name) + + libopen1 = open(self.libfile) + while True: + char = libopen1.read(1) + if not char: + break + stringof.append(char) + + count = 0 + for chars in stringof: + count = count +1 + if chars == '(': + break + count1=0 + for chars in stringof: + count1 = count1 +1 + if chars == ')': + break + stringof = stringof[count:count1-1] + stopcount=[] + listofname = [] + stopcount.append(0) + count = 0 + for chars in stringof: + count = count +1 + if chars == '=': + stopcount.append(count) + stopcount.append(count) + + i = 0 + for no in stopcount: + try: + listofname.append(''.join(stringof[int(stopcount[i]):int(stopcount[i+1])])) + i = i +1 + except: + pass + listoflist =[] + listofname2 = [el.replace('\t', '').replace('\n', ' ').replace('+', '').replace(')', '').replace('=', '') for el in listofname] + ''' + listofname = [el.replace('\n', ' ') for el in listofname2] + listofname2 = [el.replace('+', '') for el in listofname] + listofname = [el.replace(')', '') for el in listofname2] + listofname2 = [el.replace('=', '') for el in listofname] + ''' + listofname=[] + for item in listofname2: + listofname.append(item.rstrip().lstrip()) + for values in listofname: + valuelist = values.split(' ') + listoflist.append(valuelist) + for i in range(1, len(listoflist)): + model_dict[listoflist[0][0]]=listoflist[1][0] + try: + model_dict[listoflist[i][-1]]= listoflist[i+1][0] + except: + pass + root = ET.Element("library") + ET.SubElement(root, "model_name").text = model_name + ET.SubElement(root, "ref_model").text = ref_model + param = ET.SubElement(root, "param") + for tags, text in model_dict.items(): + ET.SubElement(param, tags).text = text + tree = ET.ElementTree(root) + + defaultcwd = os.getcwd() + savepath = os.path.join(self.savepathtest, 'User Libraries') + savefilepath= os.path.join(savepath, model_name +".xml") + #self.obj_valid.validateNewproj(savepath) + #self.reply = self.obj_valid.validateNewproj(savefilepath) + os.chdir(savepath) + text, ok1 = QtGui.QInputDialog.getText(self, 'Model Name','Enter Model Library Name') + if ok1: + tree.write(text+".xml") + fileopen = open(text+".lib",'w') + f = open(self.libfile) + fileopen.write(f.read()) + f.close() + fileopen.close() + os.chdir(defaultcwd) + libopen.close() + libopen1.close() \ No newline at end of file -- cgit