summaryrefslogtreecommitdiff
path: root/src/modelEditor
diff options
context:
space:
mode:
authornilshah982019-06-07 18:02:20 +0530
committernilshah982019-06-13 12:15:09 +0530
commitf1389bed602bd41b094c8d0e31da9a151f99b1dc (patch)
tree4774da7d77363cc682b354492ffa1ca0e99c5d19 /src/modelEditor
parent7c47d9e2e0458d084ffea649c788a4c2b41520ef (diff)
downloadeSim-f1389bed602bd41b094c8d0e31da9a151f99b1dc.tar.gz
eSim-f1389bed602bd41b094c8d0e31da9a151f99b1dc.tar.bz2
eSim-f1389bed602bd41b094c8d0e31da9a151f99b1dc.zip
modelEditor documentation done
Diffstat (limited to 'src/modelEditor')
-rw-r--r--src/modelEditor/ModelEditor.py228
1 files changed, 209 insertions, 19 deletions
diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py
index 573e506c..464ad17f 100644
--- a/src/modelEditor/ModelEditor.py
+++ b/src/modelEditor/ModelEditor.py
@@ -6,6 +6,28 @@ import os
class ModelEditorclass(QtGui.QWidget):
+ '''
+ - Initialise the layout for dockarea
+ - Use QVBoxLayout, QSplitter, QGridLayout to define the layout
+ - Initalise directory to save new models,
+ savepathtest = '../deviceModelLibrary'
+ - Initialise buttons and options ====>
+ - - Name Function Called
+ ========================================
+ - - New opennew
+ - - Edit openedit
+ - - Save savemodelfile
+ - - Upload converttoxml
+ - - Add addparameters
+ - - Remove removeparameter
+ - - Diode diode_click
+ - - BJT bjt_click
+ - - MOS mos_click
+ - - JFET jfet_click
+ - - IGBT igbt_click
+ - - Magnetic Core magnetic_click
+ '''
+
def __init__(self):
QtGui.QWidget.__init__(self)
self.savepathtest = '../deviceModelLibrary'
@@ -15,7 +37,12 @@ class ModelEditorclass(QtGui.QWidget):
self.splitter = QtGui.QSplitter()
self.grid = QtGui.QGridLayout()
self.splitter.setOrientation(QtCore.Qt.Vertical)
+<<<<<<< HEAD
+=======
+
+ # Initialise the table view
+>>>>>>> 357fd69... pep8 done, model editor documentation
self.modeltable = QtGui.QTableWidget()
self.newbtn = QtGui.QPushButton('New')
@@ -72,6 +99,7 @@ class ModelEditorclass(QtGui.QWidget):
self.radiobtnbox.addButton(self.magnetic)
self.magnetic.clicked.connect(self.magnetic_click)
+ # Dropdown for various types supported by that element, ex bjt -> npn
self.types = QtGui.QComboBox()
self.types.setHidden(True)
@@ -84,9 +112,18 @@ class ModelEditorclass(QtGui.QWidget):
self.grid.addWidget(self.magnetic, 8, 1)
self.setLayout(self.grid)
self.show()
+<<<<<<< HEAD
'''To create New Model file '''
+=======
+
+ '''
+ - To create New Model file
+ - Change state of other buttons accordingly, ex. enable diode, bjt, ...
+ - Validate filename created, to check if one already exists
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def opennew(self):
self.addbtn.setHidden(True)
try:
@@ -95,6 +132,7 @@ class ModelEditorclass(QtGui.QWidget):
except BaseException:
pass
os.chdir(self.savepathtest)
+ # Opens new dialog box
text, ok = QtGui.QInputDialog.getText(
self, 'New Model', 'Enter Model Name:')
if ok:
@@ -108,6 +146,7 @@ class ModelEditorclass(QtGui.QWidget):
self.modelname = (str(text))
else:
pass
+<<<<<<< HEAD
self.validation(text)
@@ -115,15 +154,49 @@ class ModelEditorclass(QtGui.QWidget):
self.openfiletype('Diode')
self.types.setHidden(True)
+=======
+ # Validate if the file created exists already or not
+ # Show error accordingly
+ self.validation(text)
+
+ '''
+ - Call function, openfiletype, which opens the table view for Diode specs
+ - Set states for other elements
+ - Diode has no types, so hide that
+ '''
+ def diode_click(self):
+ self.openfiletype('Diode')
+ self.types.setHidden(True)
+
+ '''
+ - Set states for other elements
+ - Initialise types combo box elements
+ - - NPN
+ - - PNP
+ - Open the default type in the table
+ - Add an event listener for type-selection event
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def bjt_click(self):
self.types.setHidden(False)
self.types.clear()
self.types.addItem('NPN')
self.types.addItem('PNP')
+ # Open in table default
filetype = str(self.types.currentText())
self.openfiletype(filetype)
+ # When element selected from combo box, call setfiletype
self.types.activated[str].connect(self.setfiletype)
+ '''
+ - Set states for other elements
+ - Initialise types combo box elements
+ - - NMOS(Level-1 5um)
+ - - NMOS(Level-3 0.5um)
+ - - ...
+ - 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()
@@ -136,7 +209,19 @@ class ModelEditorclass(QtGui.QWidget):
filetype = str(self.types.currentText())
self.openfiletype(filetype)
self.types.activated[str].connect(self.setfiletype)
+<<<<<<< HEAD
+=======
+
+ '''
+ - Set states for other elements
+ - Initialise types combo box elements
+ - - N-JFET
+ - - P-JFET
+ - Open the default type in the table
+ - Add an event listener for type-selection event
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def jfet_click(self):
self.types.setHidden(False)
self.types.clear()
@@ -145,7 +230,18 @@ class ModelEditorclass(QtGui.QWidget):
filetype = str(self.types.currentText())
self.openfiletype(filetype)
self.types.activated[str].connect(self.setfiletype)
+<<<<<<< HEAD
+=======
+ '''
+ - Set states for other elements
+ - Initialise types combo box elements
+ - - N-IGBT
+ - - P-IGBT
+ - Open the default type in the table
+ - Add an event listener for type-selection event
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def igbt_click(self):
self.types.setHidden(False)
self.types.clear()
@@ -154,20 +250,36 @@ class ModelEditorclass(QtGui.QWidget):
filetype = str(self.types.currentText())
self.openfiletype(filetype)
self.types.activated[str].connect(self.setfiletype)
+<<<<<<< HEAD
+=======
+ '''
+ - Set states for other elements
+ - Initialise types combo box elements
+ - Open the default type in the table
+ - Add an event listener for type-selection event
+ - No types here, only one view
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def magnetic_click(self):
self.openfiletype('Magnetic Core')
self.types.setHidden(True)
+ '''
+ - Triggered when each type selected
+ - Get the type clicked, from text
+ - Open appropriate table using openfiletype(filetype)
+ '''
def setfiletype(self, text):
self.filetype = str(text)
self.openfiletype(self.filetype)
+ '''
+ - Select path for the filetype passed
+ - Accordingly call `createtable(path)` to draw tables usingg QTable
+ - Check for the state of button before rendering
+ '''
def openfiletype(self, filetype):
- '''
- Select the path of the file to be opened \
- depending upon selected file type
- '''
self.path = '../deviceModelLibrary/Templates'
if self.diode.isChecked():
if filetype == 'Diode':
@@ -219,7 +331,19 @@ class ModelEditorclass(QtGui.QWidget):
self.createtable(path)
else:
pass
+<<<<<<< HEAD
+=======
+
+ '''
+ - When `Edit` button clicked, this function called
+ - Set states for other buttons accordingly
+ - Open the file selector box with path as deviceModelLibrary
+ and filetype set as .lib, save it in `self.editfile`
+ - Create table for the selected .lib file using `self.createtable(path)`
+ - Handle exception of no file selected
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def openedit(self):
os.chdir(self.savepathtest)
self.newflag = 0
@@ -242,11 +366,23 @@ class ModelEditorclass(QtGui.QWidget):
except BaseException:
print("No File selected for edit")
pass
+<<<<<<< HEAD
+=======
+
+ '''
+ - Set states for other components
+ - Initialise QTable widget
+ - Set options for QTable widget
+ - Place QTable widget, using `self.grid.addWidget`
+ - Select the `.xml` file from the modelfile passed as `.lib`
+ - Use ET (xml.etree.ElementTree) to parse the xml file
+ - Extract data from the XML and store it in `modeldict`
+ - Show the extracted data in QTableWidget
+ - Can edit QTable inplace, connect `edit_modeltable` function for editing
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def createtable(self, modelfile):
- '''
- This function Creates the model table by parsing the .xml file
- '''
self.savebtn.setDisabled(False)
self.addbtn.setHidden(False)
self.removebtn.setHidden(False)
@@ -269,12 +405,14 @@ class ModelEditorclass(QtGui.QWidget):
for elem in self.tree.iter(tag='model_name'):
self.model_name = elem.text
row = 0
+ # get data from XML and store to dictionary (self.modeldict)
for params in self.tree.findall('param'):
for paramlist in params:
self.modeldict[paramlist.tag] = paramlist.text
row = row + 1
self.modeltable.setRowCount(row)
count = 0
+ # setItem in modeltable, for each item in modeldict
for tags, values in list(self.modeldict.items()):
self.modeltable.setItem(count, 0, QTableWidgetItem(tags))
try:
@@ -287,7 +425,18 @@ class ModelEditorclass(QtGui.QWidget):
QtCore.QString("Parameters;Values").split(";"))
self.modeltable.show()
self.modeltable.itemChanged.connect(self.edit_modeltable)
+<<<<<<< HEAD
+=======
+
+ '''
+ - Called when editing model inplace in QTableWidget
+ - Set states of other components
+ - Get data from the modeltable of the selected row
+ - Edit name and value as per needed
+ - Add the val name pair in the modeldict
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def edit_modeltable(self):
self.savebtn.setDisabled(False)
try:
@@ -299,10 +448,18 @@ class ModelEditorclass(QtGui.QWidget):
self.modeldict[val] = name
except BaseException:
pass
+<<<<<<< HEAD
+=======
+
+ '''
+ - Called when `Add` button clicked beside QTableWidget
+ - Open up dialog box to enter parameter and value accordingly
+ - Validate if parameter already in list of parameters
+ - Accordingly add parameter and value in modeldict as well as table
+ - text1 => parameter, text2 => value
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def addparameters(self):
- '''
- This function is used to add new parameter in the table
- '''
text1, ok = QtGui.QInputDialog.getText(
self, 'Parameter', 'Enter Parameter')
if ok:
@@ -326,16 +483,28 @@ class ModelEditorclass(QtGui.QWidget):
pass
else:
pass
+<<<<<<< HEAD
+=======
+
+ '''
+ - Called when save functon clicked
+ - If new file created, call `createXML` file
+ - Else call `savethefile`
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def savemodelfile(self):
if self.newflag == 1:
self.createXML(self.model_name)
else:
self.savethefile(self.editfile)
+ '''
+ - Create .xml and .lib file if new model is being created
+ - Save it in the corresponding compoenent directory, example Diode, IGBT..
+ - For each component, separate folder is there
+ - Check the contents of .lib and .xml file to understand their structure
+ '''
def createXML(self, model_name):
- '''
- This function creates .xml and .lib files from the model table
- '''
root = ET.Element("library")
ET.SubElement(root, "model_name").text = model_name
ET.SubElement(root, "ref_model").text = self.modelname
@@ -474,10 +643,11 @@ class ModelEditorclass(QtGui.QWidget):
txtfile.close()
os.chdir(defaultcwd)
+ '''
+ - This function checks if the file (xml type) with the name already exists
+ - Accordingly show error message
+ '''
def validation(self, text):
- '''
- This function checks if the file with the name already exists
- '''
newfilename = text + '.xml'
all_dir = [x[0] for x in os.walk(self.savepathtest)]
@@ -489,10 +659,12 @@ class ModelEditorclass(QtGui.QWidget):
'The file with name ' + text + ' already exists.')
self.msg.setWindowTitle("Error Message")
+ '''
+ - This function save the editing in the model table
+ - 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):
- '''
- This function save the editing in the model table
- '''
xmlpath, file = os.path.split(editfile)
filename = os.path.splitext(file)[0]
libpath = os.path.join(xmlpath, filename + '.lib')
@@ -520,13 +692,31 @@ class ModelEditorclass(QtGui.QWidget):
self.obj_appconfig.print_info('Updated library ' + libpath)
+ '''
+ - Get the index of the current selected item
+ - 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()
remove_item = self.modeltable.item(index.row(), 0).text()
self.modeltable.removeRow(index.row())
del self.modeldict[str(remove_item)]
+<<<<<<< HEAD
+=======
+
+ '''
+ - Called when upload button clicked
+ - Used to read file form a certain location for .lib extension
+ - Accordingly parse it and extract modelname and modelref
+ - Also extract param value pairs
+ - Take input the name of the library you want to save it as
+ - Save it in `User Libraries` with the given name,
+ and input from uploaded file
+ '''
+>>>>>>> 357fd69... pep8 done, model editor documentation
def converttoxml(self):
os.chdir(self.savepathtest)
self.addbtn.setHidden(True)