From 65c2f99de14c204a22c42c6ad22dfa5d77ffbd3c Mon Sep 17 00:00:00 2001 From: PatelVatsalB21 Date: Thu, 26 May 2022 08:15:11 +0530 Subject: Added Functionality of add_Hex --- src/kicadtoNgspice/KicadtoNgspice.py | 156 ++++++++++++++++++++------- src/kicadtoNgspice/Model.py | 198 +++++++++++++---------------------- 2 files changed, 192 insertions(+), 162 deletions(-) (limited to 'src/kicadtoNgspice') diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index 28294be1..deabe97f 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -16,18 +16,20 @@ # REVISION: Saturday 25 July 2020 # ========================================================================= -import sys import os +import sys +from xml.etree import ElementTree as ET + from PyQt5 import QtWidgets -from .Processing import PrcocessNetlist + from . import Analysis -from . import Source -from . import Model +from . import Convert from . import DeviceModel +from . import Model +from . import Source from . import SubcircuitTab -from . import Convert from . import TrackWidget -from xml.etree import ElementTree as ET +from .Processing import PrcocessNetlist class MainWindow(QtWidgets.QWidget): @@ -93,10 +95,11 @@ class MainWindow(QtWidgets.QWidget): schematicInfo, sourcelist) # List storing model detail - global modelList, outputOption,\ - unknownModelList, multipleModelList, plotText + global modelList, outputOption, unknownModelList, multipleModelList, \ + plotText, microcontrollerList modelList = [] + microcontrollerList = [] outputOption = [] plotText = [] ( @@ -109,6 +112,10 @@ class MainWindow(QtWidgets.QWidget): ) = obj_proc.convertICintoBasicBlocks( schematicInfo, outputOption, modelList, plotText ) + for line in modelList: + if line[6] == "Nghdl": + microcontrollerList.append(line) + modelList.remove(line) # print("=======================================") # print("Model available in the Schematic :", modelList) @@ -124,7 +131,7 @@ class MainWindow(QtWidgets.QWidget): self.msg.setModal(True) self.msg.setWindowTitle("Unknown Models") self.content = "Your schematic contain unknown model " + \ - ', '.join(unknownModelList) + ', '.join(unknownModelList) self.msg.showMessage(self.content) self.msg.exec_() @@ -134,7 +141,7 @@ class MainWindow(QtWidgets.QWidget): self.msg.setWindowTitle("Multiple Models") self.mcontent = "Look like you have duplicate model in \ modelParamXML directory " + \ - ', '.join(multipleModelList[0]) + ', '.join(multipleModelList[0]) self.msg.showMessage(self.mcontent) self.msg.exec_() @@ -179,6 +186,9 @@ class MainWindow(QtWidgets.QWidget): - Subcircuits => obj_subcircuitTab => SubcircuitTab.SubcircuitTab(`schematicInfo`,`path_to_projFile`) + - Microcontrollers => obj_microcontroller + => Model.Model(schematicInfo, microcontrollerList, self.clarg1) + - Finally pass each of these objects, to widgets - convertWindow > mainLayout > tabWidgets > AnalysisTab, SourceTab ... """ @@ -213,6 +223,12 @@ class MainWindow(QtWidgets.QWidget): schematicInfo, self.clarg1) self.subcircuitTab.setWidget(obj_subcircuitTab) self.subcircuitTab.setWidgetResizable(True) + global obj_microcontroller + self.microcontrollerTab = QtWidgets.QScrollArea() + obj_microcontroller = Model.Model(schematicInfo, microcontrollerList, + self.clarg1) + self.microcontrollerTab.setWidget(obj_microcontroller) + self.microcontrollerTab.setWidgetResizable(True) self.tabWidget = QtWidgets.QTabWidget() # self.tabWidget.TabShape(QtWidgets.QTabWidget.Rounded) @@ -221,6 +237,7 @@ class MainWindow(QtWidgets.QWidget): self.tabWidget.addTab(self.modelTab, "Ngspice Model") self.tabWidget.addTab(self.deviceModelTab, "Device Modeling") self.tabWidget.addTab(self.subcircuitTab, "Subcircuits") + self.tabWidget.addTab(self.microcontrollerTab, "Microcontroller") self.mainLayout = QtWidgets.QVBoxLayout() self.mainLayout.addWidget(self.tabWidget) # self.mainLayout.addStretch(1) @@ -247,9 +264,9 @@ class MainWindow(QtWidgets.QWidget): try: fr = open( - os.path.join( - projpath, project_name + "_Previous_Values.xml"), 'r' - ) + os.path.join( + projpath, project_name + "_Previous_Values.xml"), 'r' + ) temp_tree = ET.parse(fr) temp_root = temp_tree.getroot() except BaseException: @@ -530,7 +547,8 @@ class MainWindow(QtWidgets.QWidget): for grand_child in child: if i <= end: grand_child.text = \ - str(obj_model.obj_trac.model_entry_var[i].text()) + str(obj_model.obj_trac.model_entry_var[ + i].text()) i = i + 1 tmp_check = 1 @@ -538,24 +556,24 @@ class MainWindow(QtWidgets.QWidget): attr_ui = ET.SubElement(attr_model, line[3], name="type") attr_ui.text = line[2] for key, value in line[7].items(): - if( - hasattr(value, '__iter__') and - i <= end and not isinstance(value, str) + if ( + hasattr(value, '__iter__') and + i <= end and not isinstance(value, str) ): for item in value: ET.SubElement( attr_ui, "field" + str(i + 1), name=item ).text = str( - obj_model.obj_trac.model_entry_var[i].text() - ) + obj_model.obj_trac.model_entry_var[i].text() + ) i = i + 1 else: ET.SubElement( attr_ui, "field" + str(i + 1), name=value ).text = str( - obj_model.obj_trac.model_entry_var[i].text() - ) + obj_model.obj_trac.model_entry_var[i].text() + ) i = i + 1 # Writing Device Model values @@ -574,7 +592,7 @@ class MainWindow(QtWidgets.QWidget): while it <= end: ET.SubElement(attr_var, "field").text = \ - str(obj_devicemodel.entry_var[it].text()) + str(obj_devicemodel.entry_var[it].text()) it = it + 1 # Writing Subcircuit values @@ -593,9 +611,71 @@ class MainWindow(QtWidgets.QWidget): while it <= end: ET.SubElement(attr_var, "field").text = \ - str(obj_subcircuitTab.entry_var[it].text()) + str(obj_subcircuitTab.entry_var[it].text()) it = it + 1 + # Writing for Microcontroller + + if check == 0: + attr_model = ET.SubElement(attr_parent, "microcontroller") + if check == 1: + for child in attr_parent: + if child.tag == "microcontroller": + attr_model = child + i = 0 + + # tmp_check is a variable to check for duplicates in the xml file + tmp_check = 0 + # tmp_i is the iterator in case duplicates are there; + # then in that case we need to replace only the child node and + # not create a new parent node + + for line in modelList: + tmp_check = 0 + if line[6] == "Nghdl": + for rand_itr in obj_model.obj_trac.modelTrack: + if rand_itr[2] == line[2] and rand_itr[3] == line[3]: + start = rand_itr[7] + end = rand_itr[8] + + i = start + for child in attr_model: + if child.text == line[2] and child.tag == line[3]: + for grand_child in child: + if i <= end: + grand_child.text = str( + obj_model.obj_trac.model_entry_var[ + i].text()) + i = i + 1 + tmp_check = 1 + + if tmp_check == 0: + attr_ui = ET.SubElement(attr_model, line[3], name="type") + attr_ui.text = line[2] + + for key, value in line[7].items(): + if ( + hasattr(value, '__iter__') and + i <= end and not isinstance(value, str) + ): + for item in value: + ET.SubElement( + attr_ui, "field" + str(i + 1), name=item + ).text = str( + obj_microcontroller.obj_trac. + model_entry_var[i].text() + ) + i = i + 1 + + else: + ET.SubElement( + attr_ui, "field" + str(i + 1), name=value + ).text = str( + obj_microcontroller.obj_trac.model_entry_var[ + i].text() + ) + i = i + 1 + # xml written to previous value file for the project tree = ET.ElementTree(attr_parent) tree.write(fw) @@ -739,14 +819,14 @@ class MainWindow(QtWidgets.QWidget): words = eachline.split() option = words[0] if (option == '.ac' or option == '.dc' or option == - '.disto' or option == '.noise' or - option == '.op' or option == '.pz' or option == - '.sens' or option == '.tf' or + '.disto' or option == '.noise' or + option == '.op' or option == '.pz' or option == + '.sens' or option == '.tf' or option == '.tran'): analysisOption.append(eachline + '\n') elif (option == '.save' or option == '.print' or option == - '.plot' or option == '.four'): + '.plot' or option == '.four'): eachline = eachline.strip('.') outputOption.append(eachline + '\n') elif (option == '.nodeset' or option == '.ic'): @@ -827,17 +907,17 @@ class MainWindow(QtWidgets.QWidget): for i in range(2, len(words) - 1): subcktInfo += words[i] + " " continue - if( - words[0] == ".end" or - words[0] == ".ac" or - words[0] == ".dc" or - words[0] == ".tran" or - words[0] == '.disto' or - words[0] == '.noise' or - words[0] == '.op' or - words[0] == '.pz' or - words[0] == '.sens' or - words[0] == '.tf' + if ( + words[0] == ".end" or + words[0] == ".ac" or + words[0] == ".dc" or + words[0] == ".tran" or + words[0] == '.disto' or + words[0] == '.noise' or + words[0] == '.op' or + words[0] == '.pz' or + words[0] == '.sens' or + words[0] == '.tf' ): continue elif words[0] == ".control": diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index 1389e556..f12e7af2 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -1,68 +1,64 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -from PyQt5 import QtWidgets, QtCore, QtGui -from PyQt5.QtCore import QObject, pyqtSlot -from . import TrackWidget -from xml.etree import ElementTree as ET import os -import sys +from configparser import ConfigParser +from xml.etree import ElementTree as ET +from PyQt5 import QtWidgets, QtCore + +from . import TrackWidget -class Model(QtWidgets.QWidget): +class Model(QtWidgets.QWidget): """ - This class creates Model Tab of KicadtoNgspice window. The widgets are created dynamically in the Model Tab. """ - # by Sumanto and Jay + # by Sumanto, Jay and Vatsal def addHex(self): """ This function is use to keep track of all Device Model widget """ + if os.name == 'nt': + self.home = os.path.join('library', 'config') + else: + self.home = os.path.expanduser('~') - # print("Calling Track Device Model Library funtion") - - init_path = "../../../" - if os.name == "nt": - init_path = "" + self.parser = ConfigParser() + self.parser.read(os.path.join( + self.home, os.path.join('.nghdl', 'config.ini'))) + self.nghdl_home = self.parser.get('NGHDL', 'NGHDL_HOME') self.hexfile = QtCore.QDir.toNativeSeparators( QtWidgets.QFileDialog.getOpenFileName( - self, "Open Hex Directory", init_path + "home", "*.hex" + self, "Open Hex Directory", os.path.expanduser('~'), + "Text files (*.txt);;HEX files (*.hex)" )[0] ) + self.text = open(self.hexfile).read() chosen_file_path = os.path.abspath(self.hexfile) + filename = os.path.basename(chosen_file_path) - # By Sumanto and Jay + path1 = os.sep + "src" + os.sep + "xspice" + os.sep + "icm" \ + + os.sep + "ghdl" + os.sep + self.model_name + path2 = os.sep + "DUTghdl" + os.sep - def uploadHex(self): - """ - This function is use to keep track of all Device Model widget - """ + path_new = self.nghdl_home + path1 + path2 - # print("Calling Track Device Model Library funtion") - - path1 = os.path.expanduser("~") - path2 = "/ngspice-nghdl/src/xspice/icm/ghdl" - init_path = path1 + path2 - if os.name == "nt": - init_path = "" - - self.hexloc = QtWidgets.QFileDialog.getExistingDirectory( - self, "Open Hex Directory", init_path - ) - self.file = open(self.hexloc + "/hex.txt", "w") + self.hexloc = path_new + filename + self.file = open(self.hexloc, "w") self.file.write(self.text) self.file.close() + self.entry_var[self.nextcount - 1].setText(chosen_file_path) def __init__( - self, - schematicInfo, - modelList, - clarg1, + self, + schematicInfo, + modelList, + clarg1, ): QtWidgets.QWidget.__init__(self) @@ -110,7 +106,6 @@ class Model(QtWidgets.QWidget): self.setLayout(self.grid) for line in modelList: - # print "ModelList Item:",line # Adding title label for model # Key: Tag name,Value:Entry widget number @@ -120,6 +115,7 @@ class Model(QtWidgets.QWidget): modelgrid = QtWidgets.QGridLayout() modelbox.setTitle(line[5]) self.start = self.nextcount + self.model_name = line[2] # line[7] is parameter dictionary holding parameter tags. @@ -134,73 +130,41 @@ class Model(QtWidgets.QWidget): temp_tag = [] for item in value: + paramLabel = QtWidgets.QLabel(item) modelgrid.addWidget(paramLabel, self.nextrow, 0) self.obj_trac.model_entry_var[ self.nextcount ] = QtWidgets.QLineEdit() - modelgrid.addWidget( - self.obj_trac.model_entry_var[self.nextcount], - self.nextrow, - 1, - ) + self.entry_var[self.count] = QtWidgets.QLineEdit() + self.entry_var[self.count].setText("") + + if value == "Path of your .hex file": + self.entry_var[self.nextcount].setReadOnly(True) + self.add_hex_btn(modelgrid, modelbox) try: for child in root: if ( - child.text == line[2] - and child.tag == line[3] + child.text == line[2] + and child.tag == line[3] ): self.obj_trac.model_entry_var [self.nextcount].setText(child[i].text) + self.entry_var[self.count].setText( + child[0].text) i = i + 1 except BaseException: pass + modelgrid.addWidget(self.entry_var[self.nextcount], + self.nextrow, 1) temp_tag.append(self.nextcount) self.nextcount = self.nextcount + 1 self.nextrow = self.nextrow + 1 - if "upload_hex_file:1" in tag_dict: - self.addbtn = QtWidgets.QPushButton("Add Hex File") - self.addbtn.setObjectName("%d" % self.nextcount) - self.addbtn.clicked.connect(self.addHex) - modelgrid.addWidget(self.addbtn, self.nextrow, 2) - modelbox.setLayout(modelgrid) - - # CSS - - modelbox.setStyleSheet( - " \ - QGroupBox { border: 1px solid gray; border-radius:\ - 9px; margin-top: 0.5em; } \ - QGroupBox::title {subcontrol-origin: margin; left:\ - 10px; padding: 0 3px 0 3px; } \ - " - ) - - self.grid.addWidget(modelbox) - self.addbtn = QtWidgets.QPushButton( - "Upload Hex File" - ) - self.addbtn.setObjectName("%d" % self.nextcount) - self.addbtn.clicked.connect(self.uploadHex) - modelgrid.addWidget(self.addbtn, self.nextrow, 3) - modelbox.setLayout(modelgrid) - - # CSS - - modelbox.setStyleSheet( - " \ - QGroupBox { border: 1px solid gray; border-radius:\ - 9px; margin-top: 0.5em; } \ - QGroupBox::title {subcontrol-origin: margin; left:\ - 10px; padding: 0 3px 0 3px; } \ - " - ) - - self.grid.addWidget(modelbox) tag_dict[key] = temp_tag + else: paramLabel = QtWidgets.QLabel(value) @@ -208,11 +172,12 @@ class Model(QtWidgets.QWidget): self.obj_trac.model_entry_var[ self.nextcount ] = QtWidgets.QLineEdit() - modelgrid.addWidget( - self.obj_trac.model_entry_var[self.nextcount], - self.nextrow, - 1, - ) + self.entry_var[self.nextcount] = QtWidgets.QLineEdit() + self.entry_var[self.nextcount].setText("") + + if value == "Path of your .hex file": + self.entry_var[self.nextcount].setReadOnly(True) + self.add_hex_btn(modelgrid, modelbox) try: for child in root: @@ -220,50 +185,16 @@ class Model(QtWidgets.QWidget): self.obj_trac.model_entry_var[ self.nextcount ].setText(child[i].text) + self.entry_var[self.count].setText( + child[0].text) i = i + 1 except BaseException: pass - + modelgrid.addWidget(self.entry_var[self.nextcount], + self.nextrow, 1) tag_dict[key] = self.nextcount self.nextcount = self.nextcount + 1 self.nextrow = self.nextrow + 1 - if "upload_hex_file:1" in tag_dict: - self.addbtn = QtWidgets.QPushButton("Add Hex File") - self.addbtn.setObjectName("%d" % self.nextcount) - self.addbtn.clicked.connect(self.addHex) - modelgrid.addWidget(self.addbtn, self.nextrow, 2) - modelbox.setLayout(modelgrid) - - # CSS - - modelbox.setStyleSheet( - " \ - QGroupBox { border: 1px solid gray; border-radius:\ - 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left:\ - 10px; padding: 0 3px 0 3px; } \ - " - ) - - self.grid.addWidget(modelbox) - self.addbtn = QtWidgets.QPushButton("Upload Hex File") - self.addbtn.setObjectName("%d" % self.nextcount) - self.addbtn.clicked.connect(self.uploadHex) - modelgrid.addWidget(self.addbtn, self.nextrow, 3) - modelbox.setLayout(modelgrid) - - # CSS - - modelbox.setStyleSheet( - " \ - QGroupBox { border: 1px solid gray; border-radius:\ - 9px; margin-top: 0.5em; } \ - QGroupBox::title { subcontrol-origin: margin; left:\ - 10px; padding: 0 3px 0 3px; } \ - " - ) - - self.grid.addWidget(modelbox) self.end = self.nextcount - 1 modelbox.setLayout(modelgrid) @@ -303,3 +234,22 @@ class Model(QtWidgets.QWidget): self.obj_trac.modelTrack.append(lst) self.show() + + def add_hex_btn(self, modelgrid, modelbox): + self.addbtn = QtWidgets.QPushButton("Add Hex File") + self.addbtn.setObjectName("%d" % self.nextcount) + self.addbtn.clicked.connect(self.addHex) + modelgrid.addWidget(self.addbtn, self.nextrow, 2) + modelbox.setLayout(modelgrid) + + # CSS + + modelbox.setStyleSheet( + " \ + QGroupBox { border: 1px solid gray; border-radius:\ + 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left:\ + 10px; padding: 0 3px 0 3px; } \ + " + ) + self.grid.addWidget(modelbox) -- cgit From b60d9dd4bb88e459b83c1074493430461a580dce Mon Sep 17 00:00:00 2001 From: PatelVatsalB21 Date: Thu, 1 Sep 2022 14:14:06 +0530 Subject: File Path Disabled for KicadToNgspice Tabs --- src/kicadtoNgspice/DeviceModel.py | 4 ++++ src/kicadtoNgspice/SubcircuitTab.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/kicadtoNgspice') diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index 5fd4d829..c52ea2d0 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -82,6 +82,7 @@ class DeviceModel(QtWidgets.QWidget): words[4]) self.entry_var[self.count] = QtWidgets.QLineEdit() self.entry_var[self.count].setText("") + self.entry_var[self.count].setReadOnly(True) global path_name try: @@ -146,6 +147,7 @@ class DeviceModel(QtWidgets.QWidget): words[3]) self.entry_var[self.count] = QtWidgets.QLineEdit() self.entry_var[self.count].setText("") + self.entry_var[self.count].setReadOnly(True) # global path_name try: for child in root: @@ -209,6 +211,7 @@ class DeviceModel(QtWidgets.QWidget): words[4]) self.entry_var[self.count] = QtWidgets.QLineEdit() self.entry_var[self.count].setText("") + self.entry_var[self.count].setReadOnly(True) # global path_name try: for child in root: @@ -273,6 +276,7 @@ class DeviceModel(QtWidgets.QWidget): words[5]) self.entry_var[self.count] = QtWidgets.QLineEdit() self.entry_var[self.count].setText("") + self.entry_var[self.count].setReadOnly(True) mosfetgrid.addWidget(self.entry_var[self.count], self.row, 1) self.addbtn = QtWidgets.QPushButton("Add") self.addbtn.setObjectName("%d" % self.count) diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py index 6b98167d..59bc3ffb 100644 --- a/src/kicadtoNgspice/SubcircuitTab.py +++ b/src/kicadtoNgspice/SubcircuitTab.py @@ -71,7 +71,7 @@ class SubcircuitTab(QtWidgets.QWidget): subbox.setTitle("Add subcircuit for " + words[len(words) - 1]) self.entry_var[self.count] = QtWidgets.QLineEdit() self.entry_var[self.count].setText("") - + self.entry_var[self.count].setReadOnly(True) global path_name try: for child in root: -- cgit From 73b784851e40ab6b607a70bf151fe2fa4443e218 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Sat, 17 Sep 2022 23:29:49 +0530 Subject: fix circuit component element out of range crash --- src/kicadtoNgspice/Analysis.py | 12 ++--- src/kicadtoNgspice/KicadtoNgspice.py | 90 ++++++++++++++++++++++-------------- src/kicadtoNgspice/Processing.py | 10 ++-- 3 files changed, 67 insertions(+), 45 deletions(-) (limited to 'src/kicadtoNgspice') diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py index 32902a81..f3784287 100644 --- a/src/kicadtoNgspice/Analysis.py +++ b/src/kicadtoNgspice/Analysis.py @@ -734,7 +734,7 @@ class Analysis(QtWidgets.QWidget): self.parameter_cnt = 0 self.start_combobox = QtWidgets.QComboBox() - self.start_combobox.addItem("Sec") + self.start_combobox.addItem("sec") self.start_combobox.addItem("ms") self.start_combobox.addItem("us") self.start_combobox.addItem("ns") @@ -744,13 +744,13 @@ class Analysis(QtWidgets.QWidget): try: self.tran_parameter[self.parameter_cnt] = str(root[2][3].text) except BaseException: - self.tran_parameter[self.parameter_cnt] = "Sec" + self.tran_parameter[self.parameter_cnt] = "sec" self.start_combobox.activated[str].connect(self.start_combo_change) self.parameter_cnt += 1 self.step_combobox = QtWidgets.QComboBox() - self.step_combobox.addItem("Sec") + self.step_combobox.addItem("sec") self.step_combobox.addItem("ms") self.step_combobox.addItem("us") self.step_combobox.addItem("ns") @@ -759,13 +759,13 @@ class Analysis(QtWidgets.QWidget): try: self.tran_parameter[self.parameter_cnt] = str(root[2][4].text) except BaseException: - self.tran_parameter[self.parameter_cnt] = "Sec" + self.tran_parameter[self.parameter_cnt] = "sec" self.step_combobox.activated[str].connect(self.step_combo_change) self.parameter_cnt += 1 self.stop_combobox = QtWidgets.QComboBox() - self.stop_combobox.addItem("Sec") + self.stop_combobox.addItem("sec") self.stop_combobox.addItem("ms") self.stop_combobox.addItem("us") self.stop_combobox.addItem("ns") @@ -774,7 +774,7 @@ class Analysis(QtWidgets.QWidget): try: self.tran_parameter[self.parameter_cnt] = str(root[2][5].text) except BaseException: - self.tran_parameter[self.parameter_cnt] = "Sec" + self.tran_parameter[self.parameter_cnt] = "sec" self.stop_combobox.activated[str].connect(self.stop_combo_change) self.parameter_cnt += 1 diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index 28294be1..6a919de9 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -10,10 +10,10 @@ # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com -# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in +# MODIFIED: Rahul Paknikar, rahulp@cse.iitb.ac.in # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Wednesday 04 March 2015 -# REVISION: Saturday 25 July 2020 +# REVISION: Sunday 18 September 2022 # ========================================================================= import sys @@ -376,9 +376,9 @@ class MainWindow(QtWidgets.QWidget): if child.tag == "source": attr_source = child - count = 1 + count = 0 grand_child_count = 0 - keys = list(obj_source.entry_var.keys()) + entry_var_keys = list(obj_source.entry_var.keys()) for i in store_schematicInfo: tmp_check = 0 @@ -390,7 +390,7 @@ class MainWindow(QtWidgets.QWidget): for grand_child in child: grand_child.text = \ str(obj_source.entry_var - [keys[grand_child_count]].text()) + [entry_var_keys[grand_child_count]].text()) grand_child_count += 1 if tmp_check == 0: words = i.split(' ') @@ -406,102 +406,124 @@ class MainWindow(QtWidgets.QWidget): # attr_ac = ET.SubElement(attr_var, "ac") ET.SubElement( attr_var, "field1", name="Amplitude" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field2", name="Phase" - ).text = str(obj_source.entry_var[count].text()) - count += 2 + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) + count += 1 elif words[len(words) - 1] == "dc": # attr_dc = ET.SubElement(attr_var, "dc") ET.SubElement( attr_var, "field1", name="Value" - ).text = str(obj_source.entry_var[count].text()) - count += 2 + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) + count += 1 elif words[len(words) - 1] == "sine": # attr_sine = ET.SubElement(attr_var, "sine") ET.SubElement( attr_var, "field1", name="Offset Value" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field2", name="Amplitude" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field3", name="Frequency" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field4", name="Delay Time" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field5", name="Damping Factor" - ).text = str(obj_source.entry_var[count].text()) - count += 2 + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) + count += 1 elif words[len(words) - 1] == "pulse": # attr_pulse=ET.SubElement(attr_var,"pulse") ET.SubElement( attr_var, "field1", name="Initial Value" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field2", name="Pulse Value" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field3", name="Delay Time" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field4", name="Rise Time" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field5", name="Fall Time" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field5", name="Pulse width" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field5", name="Period" - ).text = str(obj_source.entry_var[count].text()) - count += 2 + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) + count += 1 elif words[len(words) - 1] == "pwl": # attr_pwl=ET.SubElement(attr_var,"pwl") ET.SubElement( attr_var, "field1", name="Enter in pwl format" - ).text = str(obj_source.entry_var[count].text()) - count += 2 + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) + count += 1 elif words[len(words) - 1] == "exp": # attr_exp=ET.SubElement(attr_var,"exp") ET.SubElement( attr_var, "field1", name="Initial Value" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field2", name="Pulsed Value" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field3", name="Rise Delay Time" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field4", name="Rise Time Constant" - ).text = str(obj_source.entry_var[count].text()) + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( - attr_var, "field5", name="Fall TIme" - ).text = str(obj_source.entry_var[count].text()) + attr_var, "field5", name="Fall Time" + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) count += 1 ET.SubElement( attr_var, "field6", name="Fall Time Constant" - ).text = str(obj_source.entry_var[count].text()) - count += 2 + ).text = str(obj_source.entry_var + [entry_var_keys[count]].text()) + count += 1 if check == 0: attr_model = ET.SubElement(attr_parent, "model") diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index 94a2e51f..a0b20ada 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -143,8 +143,8 @@ class PrcocessNetlist: index = schematicInfo.index(compline) if words[3] == "pulse": Title = "Add parameters for pulse source " + compName - v1 = ' Enter initial value(Volts/Amps): ' - v2 = ' Enter pulsed value(Volts/Amps): ' + v1 = ' Enter initial value (Volts/Amps): ' + v2 = ' Enter pulsed value (Volts/Amps): ' td = ' Enter delay time (seconds): ' tr = ' Enter rise time (seconds): ' tf = ' Enter fall time (seconds): ' @@ -180,8 +180,8 @@ class PrcocessNetlist: elif words[3] == "exp": Title = "Add parameters for exponential source " + compName - v1 = ' Enter initial value(Volts/Amps): ' - v2 = ' Enter pulsed value(Volts/Amps): ' + v1 = ' Enter initial value (Volts/Amps): ' + v2 = ' Enter pulsed value (Volts/Amps): ' td1 = ' Enter rise delay time (seconds): ' tau1 = ' Enter rise time constant (seconds): ' td2 = ' Enter fall time (seconds): ' @@ -192,7 +192,7 @@ class PrcocessNetlist: elif words[3] == "dc": Title = "Add parameters for DC source " + compName - v1 = ' Enter value(Volts/Amps): ' + v1 = ' Enter value (Volts/Amps): ' v2 = ' Enter zero frequency: ' sourcelist.append( [index, compline, words[3], Title, v1, v2]) -- cgit