diff options
author | Sunil Shetye | 2019-06-14 10:38:23 +0530 |
---|---|---|
committer | GitHub | 2019-06-14 10:38:23 +0530 |
commit | fd265d087ff6dc7a09df400b165043e61bb7d0c0 (patch) | |
tree | 2d08a48bcc268154c5e0f25f4c3e94d0ac9e4f7f /src/modelEditor/ModelEditor.py | |
parent | cfc34bb19977e738582620802415ccde27a03039 (diff) | |
parent | 1d4ee6b6c1254657c497673838922e746f339eca (diff) | |
download | eSim-fd265d087ff6dc7a09df400b165043e61bb7d0c0.tar.gz eSim-fd265d087ff6dc7a09df400b165043e61bb7d0c0.tar.bz2 eSim-fd265d087ff6dc7a09df400b165043e61bb7d0c0.zip |
Merge pull request #77 from nilshah98/clean
Bugs resolved and minor fixes
Diffstat (limited to 'src/modelEditor/ModelEditor.py')
-rw-r--r-- | src/modelEditor/ModelEditor.py | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index 0d5ff0cf..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) @@ -385,7 +396,8 @@ class ModelEditorclass(QtGui.QWidget): self.modeltable.setItem(count, 1, valueitem) count = count + 1 self.modeltable.setHorizontalHeaderLabels( - QtCore.QString("Parameters;Values").split(";")) + ("Parameters;Values").split(";") + ) self.modeltable.show() self.modeltable.itemChanged.connect(self.edit_modeltable) @@ -396,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: @@ -415,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') @@ -445,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) @@ -457,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 @@ -468,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( @@ -489,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( @@ -510,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( @@ -531,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( @@ -552,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( @@ -573,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( @@ -600,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' @@ -617,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] @@ -632,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 @@ -650,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() @@ -666,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) @@ -700,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 @@ -726,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: @@ -784,4 +804,4 @@ class ModelEditorclass(QtGui.QWidget): fileopen.close() os.chdir(defaultcwd) libopen.close() - libopen1.close()
\ No newline at end of file + libopen1.close() |