Model Editor Component
Note
Source : /src/modelEditor/ModelEditor.py
- class modelEditor.ModelEditor.ModelEditorclass(*args: Any, **kwargs: Any)
Initialise the layout for dockarea
Use QVBoxLayout, QSplitter, QGridLayout to define the layout
Initalise directory to save new models, savepathtest = ‘library/deviceModelLibrary’
- Initialise buttons and options ====>
Name Function Called
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
- addparameters()
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
- bjt_click()
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
- converttoxml()
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
- createXML(model_name)
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
- createtable(modelfile)
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
- diode_click()
Call function, openfiletype, which opens the table view for Diode specs
Set states for other elements
Diode has no types, so hide that
- edit_modeltable()
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
- igbt_click()
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
- jfet_click()
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
- magnetic_click()
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
- mos_click()
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
- openedit()
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
- openfiletype(filetype)
Select path for the filetype passed
Accordingly call createtable(path) to draw tables usingg QTable
Check for the state of button before rendering
- opennew()
To create New Model file
Change state of other buttons accordingly, ex. enable diode, bjt, …
Validate filename created, to check if one already exists
- removeparameter()
Get the index of the current selected item
Remove the whole row from QTable Widget
Remove the param,value pair from modeldict
- savemodelfile()
Called when save functon clicked
If new file created, call createXML file
Else call savethefile
- savethefile(editfile)
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
- setfiletype(text)
Triggered when each type selected
Get the type clicked, from text
Open appropriate table using openfiletype(filetype)
- validation(text)
This function checks if the file (xml type) with the name already exists
Accordingly show error message