diff options
Diffstat (limited to 'src/modelEditor/ModelEditor.py')
-rw-r--r-- | src/modelEditor/ModelEditor.py | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index 63e7e6a5..1dce456e 100644 --- a/src/modelEditor/ModelEditor.py +++ b/src/modelEditor/ModelEditor.py @@ -81,7 +81,7 @@ class ModelEditorclass(QtGui.QWidget): self.igbt.setDisabled(True) self.magnetic = QtGui.QRadioButton('Magnetic Core') self.magnetic.setDisabled(True) - + self.radiobtnbox.addButton(self.diode) self.diode.clicked.connect(self.diode_click) self.radiobtnbox.addButton(self.bjt) @@ -114,6 +114,7 @@ class ModelEditorclass(QtGui.QWidget): - Change state of other buttons accordingly, ex. enable diode, bjt, ... - Validate filename created, to check if one already exists ''' + def opennew(self): self.addbtn.setHidden(True) try: @@ -146,6 +147,7 @@ class ModelEditorclass(QtGui.QWidget): - Set states for other elements - Diode has no types, so hide that ''' + def diode_click(self): self.openfiletype('Diode') self.types.setHidden(True) @@ -158,6 +160,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def bjt_click(self): self.types.setHidden(False) self.types.clear() @@ -178,6 +181,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def mos_click(self): self.types.setHidden(False) self.types.clear() @@ -199,6 +203,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def jfet_click(self): self.types.setHidden(False) self.types.clear() @@ -207,7 +212,7 @@ class ModelEditorclass(QtGui.QWidget): filetype = str(self.types.currentText()) self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) - + ''' - Set states for other elements - Initialise types combo box elements @@ -216,6 +221,7 @@ class ModelEditorclass(QtGui.QWidget): - Open the default type in the table - Add an event listener for type-selection event ''' + def igbt_click(self): self.types.setHidden(False) self.types.clear() @@ -232,6 +238,7 @@ class ModelEditorclass(QtGui.QWidget): - Add an event listener for type-selection event - No types here, only one view ''' + def magnetic_click(self): self.openfiletype('Magnetic Core') self.types.setHidden(True) @@ -241,6 +248,7 @@ class ModelEditorclass(QtGui.QWidget): - Get the type clicked, from text - Open appropriate table using openfiletype(filetype) ''' + def setfiletype(self, text): self.filetype = str(text) self.openfiletype(self.filetype) @@ -250,6 +258,7 @@ class ModelEditorclass(QtGui.QWidget): - Accordingly call `createtable(path)` to draw tables usingg QTable - Check for the state of button before rendering ''' + def openfiletype(self, filetype): self.path = '../deviceModelLibrary/Templates' if self.diode.isChecked(): @@ -311,6 +320,7 @@ class ModelEditorclass(QtGui.QWidget): - Create table for the selected .lib file using `self.createtable(path)` - Handle exception of no file selected ''' + def openedit(self): os.chdir(self.savepathtest) self.newflag = 0 @@ -345,6 +355,7 @@ class ModelEditorclass(QtGui.QWidget): - Show the extracted data in QTableWidget - Can edit QTable inplace, connect `edit_modeltable` function for editing ''' + def createtable(self, modelfile): self.savebtn.setDisabled(False) self.addbtn.setHidden(False) @@ -386,7 +397,7 @@ class ModelEditorclass(QtGui.QWidget): count = count + 1 self.modeltable.setHorizontalHeaderLabels( ("Parameters;Values").split(";") - ) + ) self.modeltable.show() self.modeltable.itemChanged.connect(self.edit_modeltable) @@ -397,6 +408,7 @@ class ModelEditorclass(QtGui.QWidget): - Edit name and value as per needed - Add the val name pair in the modeldict ''' + def edit_modeltable(self): self.savebtn.setDisabled(False) try: @@ -416,6 +428,7 @@ class ModelEditorclass(QtGui.QWidget): - Accordingly add parameter and value in modeldict as well as table - text1 => parameter, text2 => value ''' + def addparameters(self): text1, ok = QtGui.QInputDialog.getText( self, 'Parameter', 'Enter Parameter') @@ -446,6 +459,7 @@ class ModelEditorclass(QtGui.QWidget): - If new file created, call `createXML` file - Else call `savethefile` ''' + def savemodelfile(self): if self.newflag == 1: self.createXML(self.model_name) @@ -458,6 +472,7 @@ class ModelEditorclass(QtGui.QWidget): - For each component, separate folder is there - Check the contents of .lib and .xml file to understand their structure ''' + def createXML(self, model_name): root = ET.Element("library") ET.SubElement(root, "model_name").text = model_name @@ -469,7 +484,7 @@ class ModelEditorclass(QtGui.QWidget): defaultcwd = os.getcwd() self.savepath = '../deviceModelLibrary' if self.diode.isChecked(): - savepath = os.path.join(self.savepath, 'Diode') + savepath = os.path.join(self.savepath, 'Diode') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -490,7 +505,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.mos.isChecked(): - savepath = os.path.join(self.savepath, 'MOS') + savepath = os.path.join(self.savepath, 'MOS') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -511,7 +526,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.jfet.isChecked(): - savepath = os.path.join(self.savepath, 'JFET') + savepath = os.path.join(self.savepath, 'JFET') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -532,7 +547,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.igbt.isChecked(): - savepath = os.path.join(self.savepath, 'IGBT') + savepath = os.path.join(self.savepath, 'IGBT') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -553,7 +568,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.magnetic.isChecked(): - savepath = os.path.join(self.savepath, 'Misc') + savepath = os.path.join(self.savepath, 'Misc') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -574,7 +589,7 @@ class ModelEditorclass(QtGui.QWidget): ' library created at ' + os.getcwd()) if self.bjt.isChecked(): - savepath = os.path.join(self.savepath, 'Transistor') + savepath = os.path.join(self.savepath, 'Transistor') os.chdir(savepath) txtfile = open(self.modelname + '.lib', 'w') txtfile.write( @@ -601,6 +616,7 @@ class ModelEditorclass(QtGui.QWidget): - This function checks if the file (xml type) with the name already exists - Accordingly show error message ''' + def validation(self, text): newfilename = text + '.xml' @@ -618,6 +634,7 @@ class ModelEditorclass(QtGui.QWidget): - Create .lib and .xml file for the editfile path and replace them - Also print Updated Library with libpath in the command window ''' + def savethefile(self, editfile): xmlpath, file = os.path.split(editfile) filename = os.path.splitext(file)[0] @@ -633,7 +650,7 @@ class ModelEditorclass(QtGui.QWidget): libfile.write('+ ' + tags + '=' + text + '\n') libfile.write(')') libfile.close() - + root = ET.Element("library") ET.SubElement(root, "model_name").text = self.model_name ET.SubElement(root, "ref_model").text = self.ref_model @@ -651,6 +668,7 @@ class ModelEditorclass(QtGui.QWidget): - Remove the whole row from QTable Widget - Remove the param,value pair from modeldict ''' + def removeparameter(self): self.savebtn.setDisabled(False) index = self.modeltable.currentIndex() @@ -667,6 +685,7 @@ class ModelEditorclass(QtGui.QWidget): - Save it in `User Libraries` with the given name, and input from uploaded file ''' + def converttoxml(self): os.chdir(self.savepathtest) self.addbtn.setHidden(True) @@ -701,14 +720,14 @@ class ModelEditorclass(QtGui.QWidget): 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 @@ -727,9 +746,9 @@ class ModelEditorclass(QtGui.QWidget): for chars in stringof: count = count + 1 if chars == '=': - stopcount.append(count) + stopcount.append(count) stopcount.append(count) - + i = 0 for no in stopcount: try: @@ -785,4 +804,4 @@ class ModelEditorclass(QtGui.QWidget): fileopen.close() os.chdir(defaultcwd) libopen.close() - libopen1.close()
\ No newline at end of file + libopen1.close() |