summaryrefslogtreecommitdiff
path: root/src/kicadtoNgspice
diff options
context:
space:
mode:
authorrahulp132020-02-14 15:16:35 +0530
committerrahulp132020-02-14 15:16:35 +0530
commitcb55e59de7ee4383c04edfae7c39ad9ae9552b36 (patch)
treede1b292a10e8196689bf1a208fe6fe32f4618846 /src/kicadtoNgspice
parent08d4a0336550a0e610709970a0c5d366e109fe82 (diff)
downloadeSim-cb55e59de7ee4383c04edfae7c39ad9ae9552b36.tar.gz
eSim-cb55e59de7ee4383c04edfae7c39ad9ae9552b36.tar.bz2
eSim-cb55e59de7ee4383c04edfae7c39ad9ae9552b36.zip
common code for Win and Linux, merged py2 changes
Diffstat (limited to 'src/kicadtoNgspice')
-rw-r--r--src/kicadtoNgspice/Analysis.py104
-rw-r--r--src/kicadtoNgspice/Convert.py52
-rw-r--r--src/kicadtoNgspice/DeviceModel.py42
-rw-r--r--src/kicadtoNgspice/KicadtoNgspice.py96
-rw-r--r--src/kicadtoNgspice/Model.py6
-rw-r--r--src/kicadtoNgspice/Processing.py108
-rw-r--r--src/kicadtoNgspice/Source.py11
-rw-r--r--src/kicadtoNgspice/SubcircuitTab.py16
-rw-r--r--src/kicadtoNgspice/TrackWidget.py10
9 files changed, 208 insertions, 237 deletions
diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py
index b24f24c7..e5c05ebe 100644
--- a/src/kicadtoNgspice/Analysis.py
+++ b/src/kicadtoNgspice/Analysis.py
@@ -1,29 +1,27 @@
-
-from PyQt4 import QtGui
+from PyQt4 import QtGui, QtCore
from . import TrackWidget
import os
-# from xml.etree import ElementTree as ET
import json
class Analysis(QtGui.QWidget):
"""
- This class create Analysis Tab in KicadtoNgspice Window. 4 sections -
- - - Select Analysis Type
- - - AC Analysis
- - - DC Analysis
- - - Transient Analysis
- - Set various track widget options here, for tracking purposes across\
- different functions and modules -
- - - AC_entry_var
- - - AC_Parameter
- - - DC_entry_var
- - - DC_Parameter
- - - TRAN_entry_var
- - - TRAN_Parameter
- - - set_Checkbox
- - - AC_type
- - - op_check
+ - Select Analysis Type
+ - AC Analysis
+ - DC Analysis
+ - Transient Analysis
+ - Set various track widget options here, for tracking purposes across \
+ different functions and modules -
+ - AC_entry_var
+ - AC_Parameter
+ - DC_entry_var
+ - DC_Parameter
+ - TRAN_entry_var
+ - TRAN_Parameter
+ - set_Checkbox
+ - AC_type
+ - op_check
"""
def __init__(self, clarg1):
@@ -42,19 +40,21 @@ class Analysis(QtGui.QWidget):
def createAnalysisWidget(self):
"""
- - Create the main anaylsis widget overwiew
- - - Checkbox for analysis type
- - - Place, `AC`, `DC` and `TRANSIENT` analysis tab
- - - `self.acbox`, `self.dcbox`,`self.trbox`...
+ - Create the main anaylsis widget overwiew:
+ - Checkbox for analysis type
+ - Place, `AC`, `DC` and `TRANSIENT` analysis tab
+ - `self.acbox`, `self.dcbox`, `self.trbox`...
- Check for `analysis` file, if any in projDir, extract data from it
- Else set the default checkbox to `TRAN`
- Accordingly set state for track widget options, as `TRAN`, `AC` ...
"""
self.grid = QtGui.QGridLayout()
- self.grid.addWidget(self.createCheckBox(), 0, 0)
- self.grid.addWidget(self.createACgroup(), 1, 0)
- self.grid.addWidget(self.createDCgroup(), 2, 0)
- self.grid.addWidget(self.createTRANgroup(), 3, 0)
+ self.setLayout(self.grid)
+
+ self.grid.addWidget(self.createCheckBox(), 0, 0, QtCore.Qt.AlignTop)
+ self.grid.addWidget(self.createACgroup(), 1, 0, 5, 0)
+ self.grid.addWidget(self.createDCgroup(), 1, 0, 5, 0)
+ self.grid.addWidget(self.createTRANgroup(), 1, 0, 5, 0)
try:
kicadFile = self.clarg1
@@ -74,6 +74,10 @@ class Analysis(QtGui.QWidget):
self.acbox.setDisabled(False)
self.dcbox.setDisabled(True)
self.trbox.setDisabled(True)
+
+ self.acbox.setVisible(True)
+ self.dcbox.setVisible(False)
+ self.trbox.setVisible(False)
self.track_obj.set_CheckBox["ITEMS"] = "AC"
if contentlist[1] == 'lin':
self.Lin.setChecked(True)
@@ -90,6 +94,10 @@ class Analysis(QtGui.QWidget):
self.dcbox.setDisabled(False)
self.acbox.setDisabled(True)
self.trbox.setDisabled(True)
+
+ self.dcbox.setVisible(True)
+ self.acbox.setVisible(False)
+ self.trbox.setVisible(False)
self.track_obj.set_CheckBox["ITEMS"] = "DC"
elif contentlist[0] == '.tran':
@@ -97,6 +105,10 @@ class Analysis(QtGui.QWidget):
self.trbox.setDisabled(False)
self.acbox.setDisabled(True)
self.dcbox.setDisabled(True)
+
+ self.trbox.setVisible(True)
+ self.dcbox.setVisible(False)
+ self.acbox.setVisible(False)
self.track_obj.set_CheckBox["ITEMS"] = "TRAN"
elif contentlist[0] == '.op':
@@ -104,6 +116,10 @@ class Analysis(QtGui.QWidget):
self.dcbox.setDisabled(False)
self.acbox.setDisabled(True)
self.trbox.setDisabled(True)
+
+ self.dcbox.setVisible(True)
+ self.acbox.setVisible(False)
+ self.trbox.setVisible(False)
self.check.setChecked(True)
self.track_obj.set_CheckBox["ITEMS"] = "DC"
@@ -111,7 +127,6 @@ class Analysis(QtGui.QWidget):
self.checkTRAN.setChecked(True)
self.track_obj.set_CheckBox["ITEMS"] = "TRAN"
- self.setLayout(self.grid)
self.show()
def createCheckBox(self):
@@ -151,25 +166,37 @@ class Analysis(QtGui.QWidget):
self.acbox.setDisabled(False)
self.dcbox.setDisabled(True)
self.trbox.setDisabled(True)
+
+ self.acbox.setVisible(True)
+ self.dcbox.setVisible(False)
+ self.trbox.setVisible(False)
self.track_obj.set_CheckBox["ITEMS"] = "AC"
elif self.checkDC.isChecked():
self.dcbox.setDisabled(False)
self.acbox.setDisabled(True)
self.trbox.setDisabled(True)
+
+ self.dcbox.setVisible(True)
+ self.acbox.setVisible(False)
+ self.trbox.setVisible(False)
self.track_obj.set_CheckBox["ITEMS"] = "DC"
elif self.checkTRAN.isChecked():
self.trbox.setDisabled(False)
self.acbox.setDisabled(True)
self.dcbox.setDisabled(True)
+
+ self.trbox.setVisible(True)
+ self.acbox.setVisible(False)
+ self.dcbox.setVisible(False)
self.track_obj.set_CheckBox["ITEMS"] = "TRAN"
def createACgroup(self):
"""
- Designing of AC group in analysis tab
- 3 radio buttons - Lin | Dec | Oct
- - 3 input boxes, with top 2 combos\
+ - 3 input boxes, with top 2 combos
- If previous values exist then fill default values from
previous value json file
"""
@@ -194,6 +221,7 @@ class Analysis(QtGui.QWidget):
self.acbox = QtGui.QGroupBox()
self.acbox.setTitle("AC Analysis")
self.acbox.setDisabled(True)
+ self.acbox.setVisible(False)
self.acgrid = QtGui.QGridLayout()
self.radiobuttongroup = QtGui.QButtonGroup()
self.Lin = QtGui.QRadioButton("Lin")
@@ -320,11 +348,10 @@ class Analysis(QtGui.QWidget):
'''
- Below 2 functions handle combo value event listeners for
- - - start frequency for ac
- - - stop frequency for ac
+ - start frequency for ac
+ - stop frequency for ac
- And accordingly set the ac_parameters
'''
-
def start_combovalue(self, text):
"""
- Handle start_fre_combo box event
@@ -343,7 +370,7 @@ class Analysis(QtGui.QWidget):
def set_ac_type(self):
"""
- - Set track object for AC, according to the type of radio box selected
+ Sets track object for AC, according to the type of radio box selected.
"""
self.parameter_cnt = 0
@@ -353,17 +380,15 @@ class Analysis(QtGui.QWidget):
self.track_obj.AC_type["ITEMS"] = "dec"
elif self.Oct.isChecked():
self.track_obj.AC_type["ITEMS"] = "oct"
- else:
- pass
def createDCgroup(self):
"""
- Create DC area under analysis tab
- Source 1 and 2, each having 4 input boxes as follows
- - - Source
- - - Start
- - - Increment
- - - Stop
+ - Source
+ - Start
+ - Increment
+ - Stop
- The last 3 have combo box pertaining to their unit as well
- Also in the end a checkbox, for operating system point analysis
"""
@@ -388,6 +413,7 @@ class Analysis(QtGui.QWidget):
self.dcbox = QtGui.QGroupBox()
self.dcbox.setTitle("DC Analysis")
self.dcbox.setDisabled(True)
+ self.dcbox.setVisible(False)
self.dcgrid = QtGui.QGridLayout()
self.dcbox.setLayout(self.dcgrid)
@@ -811,10 +837,10 @@ class Analysis(QtGui.QWidget):
print("Transient Analysis JSON Parse Error")
return self.trbox
+
'''
- Below 3 functions handle event for the combo box in transient group
'''
-
def start_combo_change(self, text):
"""Handle start combo box, ie. units, as second, ms"""
self.tran_parameter[0] = str(text)
diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py
index 883ba534..99f8768a 100644
--- a/src/kicadtoNgspice/Convert.py
+++ b/src/kicadtoNgspice/Convert.py
@@ -1,5 +1,4 @@
from PyQt4 import QtGui
-
import os
import shutil
from . import TrackWidget
@@ -9,15 +8,15 @@ from xml.etree import ElementTree as ET
class Convert:
"""
- This class has all the necessary function required to convert \
- kicad netlist to ngspice netlist.
+ kicad netlist to ngspice netlist.
- Method List
- - - addDeviceLibrary
- - - addModelParameter
- - - addSourceParameter
- - - addSubcircuit
- - - analysisInsertor
- - - converttosciform
- - - defaultvalue
+ - addDeviceLibrary
+ - addModelParameter
+ - addSourceParameter
+ - addSubcircuit
+ - analysisInsertor
+ - converttosciform
+ - defaultvalue
"""
def __init__(self, sourcelisttrack, source_entry_var,
@@ -32,12 +31,12 @@ class Convert:
"""
- This function extracts the source details to schematicInfo
- keywords recognised and parsed -
- - - sine
- - - pulse
- - - pwl
- - - ac
- - - dc
- - - exp
+ - sine
+ - pulse
+ - pwl
+ - ac
+ - dc
+ - exp
- Return updated schematic
"""
@@ -355,7 +354,7 @@ class Convert:
def addModelParameter(self, schematicInfo):
"""
- This function add the Ngspice Model details to schematicInfo
+ This function adds the Ngspice Model details to schematicInfo
"""
# Create object of TrackWidget
@@ -446,8 +445,6 @@ class Convert:
# end = line[8]
addmodelLine = ".model " + line[3] + " " + line[2] + "("
for key, value in line[9].items():
- # print "Tags: ",key
- # print "Value: ",value
# Checking for default value and accordingly assign
# param and default.
if ':' in key:
@@ -457,7 +454,7 @@ class Convert:
else:
param = key
default = 0
- # Cheking if value is iterable.its for vector
+ # Checking if value is iterable.its for vector
if (
not isinstance(value, str) and
hasattr(value, '__iter__')
@@ -516,17 +513,16 @@ class Convert:
includeLine = [] # All .include line list
if not deviceLibList:
- print("No Library Added in the schematic")
- pass
+ print("No library added in the schematic")
else:
for eachline in schematicInfo:
words = eachline.split()
if words[0] in deviceLibList:
- print("Found Library line")
+ # print("Found Library line")
index = schematicInfo.index(eachline)
completeLibPath = deviceLibList[words[0]]
(libpath, libname) = os.path.split(completeLibPath)
- print("Library Path :", libpath)
+ # print("Library Path :", libpath)
# Copying library from devicemodelLibrary to Project Path
# Special case for MOSFET
if eachline[0] == 'm':
@@ -562,9 +558,6 @@ class Convert:
dst = projpath
shutil.copy2(src, dst)
- else:
- pass
-
# Adding device line to schematicInfo
for index, value in deviceLine.items():
# Update the device line
@@ -582,7 +575,6 @@ class Convert:
"""
This function add the subcircuit to schematicInfo
"""
-
(projpath, filename) = os.path.split(kicadFile)
subList = self.obj_track.subcircuitTrack
@@ -600,7 +592,6 @@ class Convert:
raise Exception('All subcircuit directories need to be specified.')
elif not subList:
print("No Subcircuit Added in the schematic")
- pass
else:
for eachline in schematicInfo:
words = eachline.split()
@@ -624,8 +615,6 @@ class Convert:
if os.path.isfile(os.path.join(src, files)):
if files != "analysis":
shutil.copy2(os.path.join(src, files), dst)
- else:
- pass
# Adding subcircuit line to schematicInfo
for index, value in subLine.items():
@@ -649,6 +638,5 @@ class Convert:
for child in libtree.iter():
if child.tag == 'ref_model':
retVal = child.text
- else:
- pass
+
return retVal
diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py
index 7f63a43b..41faa6f0 100644
--- a/src/kicadtoNgspice/DeviceModel.py
+++ b/src/kicadtoNgspice/DeviceModel.py
@@ -1,6 +1,5 @@
from PyQt4 import QtGui
import os
-# from xml.etree import ElementTree as ET
import json
from . import TrackWidget
@@ -12,13 +11,13 @@ class DeviceModel(QtGui.QWidget):
transistor and jfet.
- Same function as the subCircuit file, except for
this takes different parameters in the if block
- - - q TRANSISTOR
- - - d DIODE
- - - j JFET
- - - m MOSFET
+ - q TRANSISTOR
+ - d DIODE
+ - j JFET
+ - m MOSFET
- Other 2 functions same as the ones in subCircuit
- - - trackLibrary
- - - trackLibraryWithoutButton
+ - trackLibrary
+ - trackLibraryWithoutButton
"""
def __init__(self, schematicInfo, clarg1):
@@ -62,14 +61,14 @@ class DeviceModel(QtGui.QWidget):
# Set Layout
self.grid = QtGui.QGridLayout()
self.setLayout(self.grid)
- print("Reading Device model details from Schematic")
+ # print("Reading Device model details from Schematic")
for eachline in schematicInfo:
print("=========================================")
print(eachline)
words = eachline.split()
if eachline[0] == 'q':
- print("Device Model Transistor: ", words[0])
+ # print("Device Model Transistor: ", words[0])
self.devicemodel_dict_beg[words[0]] = self.count
transbox = QtGui.QGroupBox()
transgrid = QtGui.QGridLayout()
@@ -85,8 +84,6 @@ class DeviceModel(QtGui.QWidget):
try:
for key in json_data["deviceModel"]:
if key == words[0]:
- # print "DEVICE MODEL MATCHING---",child.tag[0],\
- # child.tag[1],eachline[0],eachline[1]
try:
if os.path.exists(
json_data["deviceModel"][key][0]):
@@ -128,7 +125,7 @@ class DeviceModel(QtGui.QWidget):
self.grid.addWidget(transbox)
- # Adding Device Details
+ # Adding Device Details #
# Increment row and widget count
self.row = self.row + 1
@@ -136,7 +133,7 @@ class DeviceModel(QtGui.QWidget):
self.count = self.count + 1
elif eachline[0] == 'd':
- print("Device Model Diode:", words[0])
+ # print("Device Model Diode:", words[0])
self.devicemodel_dict_beg[words[0]] = self.count
diodebox = QtGui.QGroupBox()
diodegrid = QtGui.QGridLayout()
@@ -151,8 +148,6 @@ class DeviceModel(QtGui.QWidget):
try:
for key in json_data["deviceModel"]:
if key == words[0]:
- # print "DEVICE MODEL MATCHING---",child.tag[0],\
- # child.tag[1],eachline[0],eachline[1]
try:
if os.path.exists(
json_data["deviceModel"][key][0]):
@@ -193,7 +188,7 @@ class DeviceModel(QtGui.QWidget):
self.grid.addWidget(diodebox)
- # Adding Device Details
+ # Adding Device Details #
# Increment row and widget count
self.row = self.row + 1
@@ -201,7 +196,7 @@ class DeviceModel(QtGui.QWidget):
self.count = self.count + 1
elif eachline[0] == 'j':
- print("Device Model JFET:", words[0])
+ # print("Device Model JFET:", words[0])
self.devicemodel_dict_beg[words[0]] = self.count
jfetbox = QtGui.QGroupBox()
jfetgrid = QtGui.QGridLayout()
@@ -216,8 +211,6 @@ class DeviceModel(QtGui.QWidget):
try:
for key in json_data["deviceModel"]:
if key == words[0]:
- # print "DEVICE MODEL MATCHING---",child.tag[0],\
- # child.tag[1],eachline[0],eachline[1]
try:
if os.path.exists(
json_data["deviceModel"][key][0]):
@@ -258,7 +251,8 @@ class DeviceModel(QtGui.QWidget):
self.grid.addWidget(jfetbox)
- # Adding Device Details
+ # Adding Device Details #
+
# Increment row and widget count
self.row = self.row + 1
self.devicemodel_dict_end[words[0]] = self.count
@@ -329,8 +323,6 @@ class DeviceModel(QtGui.QWidget):
try:
for key in json_data["deviceModel"]:
if key == words[0]:
- # print "DEVICE MODEL MATCHING---",child.tag[0],\
- # child.tag[1],eachline[0],eachline[1]
while i <= end:
self.entry_var[i].setText(
json_data["deviceModel"][key][i - beg])
@@ -367,7 +359,6 @@ class DeviceModel(QtGui.QWidget):
"""
print("Calling Track Device Model Library funtion")
sending_btn = self.sender()
- # print "Object Called is ",sending_btn.objectName()
self.widgetObjCount = int(sending_btn.objectName())
self.libfile = str(
@@ -376,14 +367,12 @@ class DeviceModel(QtGui.QWidget):
"Open Library Directory",
"../deviceModelLibrary",
"*.lib"))
- # print "Selected Library File :",self.libfile
# Setting Library to Text Edit Line
self.entry_var[self.widgetObjCount].setText(self.libfile)
self.deviceName = self.deviceDetail[self.widgetObjCount]
# Storing to track it during conversion
-
if self.deviceName[0] == 'm':
width = str(self.entry_var[self.widgetObjCount + 1].text())
length = str(self.entry_var[self.widgetObjCount + 2].text())
@@ -406,19 +395,16 @@ class DeviceModel(QtGui.QWidget):
This function is use to keep track of all Device Model widget
"""
print("Calling Track Library function Without Button")
- # print "Object Called is ",sending_btn.objectName()
self.widgetObjCount = iter_value
print("self.widgetObjCount-----", self.widgetObjCount)
self.libfile = path_value
print("PATH VALUE", path_value)
- # print "Selected Library File :",self.libfile
# Setting Library to Text Edit Line
self.entry_var[self.widgetObjCount].setText(self.libfile)
self.deviceName = self.deviceDetail[self.widgetObjCount]
# Storing to track it during conversion
-
if self.deviceName[0] == 'm':
width = str(self.entry_var[self.widgetObjCount + 1].text())
length = str(self.entry_var[self.widgetObjCount + 2].text())
diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py
index ef9201cb..ab2e55e8 100644
--- a/src/kicadtoNgspice/KicadtoNgspice.py
+++ b/src/kicadtoNgspice/KicadtoNgspice.py
@@ -1,5 +1,4 @@
# =========================================================================
-#
# FILE: kicadtoNgspice.py
#
# USAGE: ---
@@ -11,10 +10,12 @@
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
# CREATED: Wednesday 04 March 2015
-# REVISION: ---
+# REVISION: Friday 14 February 2020
# =========================================================================
+
import sys
import os
from PyQt4 import QtGui
@@ -28,8 +29,6 @@ from . import Convert
from . import TrackWidget
import json
-# from xml.etree import ElementTree as ET
-
class MainWindow(QtGui.QWidget):
"""
@@ -37,7 +36,7 @@ class MainWindow(QtGui.QWidget):
- And Call Convert function if convert button is pressed.
- The convert function takes all the value entered by user and create
a final netlist "*.cir.out".
- - This final netlist is compatible with NgSpice.
+ - This final netlist is compatible with Ngspice.
- clarg1 is the path to the .cir file
- clarg2 is either None or "sub" depending on the analysis type
"""
@@ -54,10 +53,10 @@ class MainWindow(QtGui.QWidget):
self.clarg2 = clarg2
# Create object of track widget
- # Track the dynamically created widget of KicadtoNgSpice Window
+ # Track the dynamically created widget of KicadtoNgspice Window
self.obj_track = TrackWidget.TrackWidget()
- # Clear Dictionary/List item of sub circuit and ngspice model
+ # Clear Dictionary/List item of sub circuit and Ngspice model
# Dictionary
self.obj_track.subcircuitList.clear()
self.obj_track.subcircuitTrack.clear()
@@ -70,22 +69,21 @@ class MainWindow(QtGui.QWidget):
# Read the netlist, ie the .cir file
kicadNetlist = obj_proc.readNetlist(self.kicadFile)
- print("=============================================================")
- print("Given Kicad Schematic Netlist Info :", kicadNetlist)
+ # print("=============================================================")
+ # print("Given Kicad Schematic Netlist Info :", kicadNetlist)
# Construct parameter information
param = obj_proc.readParamInfo(kicadNetlist)
# Replace parameter with values
netlist, infoline = obj_proc.preprocessNetlist(kicadNetlist, param)
- print("=============================================================")
- print("Schematic Info after processing Kicad Netlist: ", netlist)
- # print "INFOLINE",infoline
+ # print("=============================================================")
+ # print("Schematic Info after processing Kicad Netlist: ", netlist)
# Separate option and schematic information
optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist)
- print("=============================================================")
- print("OPTIONINFO in the Netlist", optionInfo)
+ # print("=============================================================")
+ # print("OPTIONINFO in the Netlist", optionInfo)
# List for storing source and its value
global sourcelist, sourcelisttrack
@@ -111,8 +109,8 @@ class MainWindow(QtGui.QWidget):
) = obj_proc.convertICintoBasicBlocks(
schematicInfo, outputOption, modelList, plotText
)
- print("=======================================")
- print("Model available in the Schematic :", modelList)
+ # print("=======================================")
+ # print("Model available in the Schematic :", modelList)
"""
- Checking if any unknown model is used in schematic which is not
@@ -141,13 +139,13 @@ class MainWindow(QtGui.QWidget):
def createMainWindow(self):
"""
- - This function create main window of Kicad to Ngspice converter
+ - This function create main window of KiCad to Ngspice converter
- Two components
- - - createcreateConvertWidget
- - - Convert button => callConvert
+ - createcreateConvertWidget
+ - Convert button => callConvert
"""
- self.vbox = QtGui.QVBoxLayout(self)
- self.hbox = QtGui.QHBoxLayout(self)
+ self.vbox = QtGui.QVBoxLayout()
+ self.hbox = QtGui.QHBoxLayout()
self.hbox.addStretch(1)
self.convertbtn = QtGui.QPushButton("Convert")
self.convertbtn.clicked.connect(self.callConvert)
@@ -162,23 +160,23 @@ class MainWindow(QtGui.QWidget):
def createcreateConvertWidget(self):
"""
- Contains the tabs for various convertor elements
- - - Analysis => obj_analysis
+ - Analysis => obj_analysis
=> Analysis.Analysis(`path_to_projFile`)
- - - Source Details => obj_source
+ - Source Details => obj_source
=> Source.Source(`sourcelist`,`sourcelisttrack`,`path_to_projFile`)
- - - NgSpice Model => obj_model
+ - NgSpice Model => obj_model
=> Model.Model(`schematicInfo`,`modelList`,`path_to_projFile`)
- - - Device Modelling => obj_devicemodel
+ - Device Modelling => obj_devicemodel
=> DeviceModel.DeviceModel(`schematicInfo`,`path_to_projFile`)
- - - Subcircuits => obj_subcircuitTab
+ - Subcircuits => obj_subcircuitTab
=> SubcircuitTab.SubcircuitTab(`schematicInfo`,`path_to_projFile`)
- Finally pass each of these objects, to widgets
- - convertWindow > mainLayout > tabWidgets > AnalysisTab, SourceTab ....
+ - convertWindow > mainLayout > tabWidgets > AnalysisTab, SourceTab ...
"""
global obj_analysis
self.convertWindow = QtGui.QWidget()
@@ -268,8 +266,6 @@ class MainWindow(QtGui.QWidget):
json_data["analysis"]["ac"]["Lin"] = "false"
json_data["analysis"]["ac"]["Dec"] = "false"
json_data["analysis"]["ac"]["Oct"] = "true"
- else:
- pass
json_data["analysis"]["ac"]["Start Frequency"] = str(
obj_analysis.ac_entry_var[0].text())
@@ -594,11 +590,11 @@ class MainWindow(QtGui.QWidget):
print("=========================================================")
self.createNetlistFile(store_schematicInfo, plotText)
- self.msg = "The Kicad to Ngspice Conversion completed\
- successfully!"
+ self.msg = "The Kicad to Ngspice Conversion completed "
+ self.msg += "successfully!"
QtGui.QMessageBox.information(
- self, "Information", self.msg, QtGui.QMessageBox.Ok)
-
+ self, "Information", self.msg, QtGui.QMessageBox.Ok
+ )
except Exception as e:
print("Exception Message: ", e)
print("There was error while converting kicad to ngspice")
@@ -615,31 +611,26 @@ class MainWindow(QtGui.QWidget):
"""
- Creating .cir.out file
- If analysis file present uses that and extract
- - - Simulator
- - - Initial
- - - Analysis
+ - Simulator
+ - Initial
+ - Analysis
- Finally add the following components to .cir.out file
- - - SimulatorOption
- - - InitialCondOption
- - - Store_SchematicInfo
- - - AnalysisOption
+ - SimulatorOption
+ - InitialCondOption
+ - Store_SchematicInfo
+ - AnalysisOption
- In the end add control statements and allv, alli, end statements
"""
print("=============================================================")
print("Creating Final netlist")
- # print "INFOLINE",infoline
- # print "OPTIONINFO",optionInfo
- # print "Device MODEL LIST ",devicemodelList
- # print "SUBCKT ",subcktList
- # print "OUTPUTOPTION",outputOption
- # print "KicadfIle",kicadFile
+
# To avoid writing optionInfo twice in final netlist
store_optionInfo = list(optionInfo)
# checking if analysis files is present
(projpath, filename) = os.path.split(self.kicadFile)
analysisFileLoc = os.path.join(projpath, "analysis")
- # print "Analysis File Location",analysisFileLoc
+
if os.path.exists(analysisFileLoc):
try:
f = open(analysisFileLoc)
@@ -653,7 +644,7 @@ class MainWindow(QtGui.QWidget):
Please check it")
sys.exit()
else:
- print("========================================================")
+ # print("========================================================")
print(analysisFileLoc + " does not exist")
sys.exit()
@@ -664,10 +655,7 @@ class MainWindow(QtGui.QWidget):
if len(eachline) > 1:
if eachline[0] == '.':
store_optionInfo.append(eachline)
- else:
- pass
- # print "Option Info",optionInfo
analysisOption = []
initialCondOption = []
simulatorOption = []
@@ -743,7 +731,7 @@ class MainWindow(QtGui.QWidget):
except BaseException:
print("Error in opening .cir.out file.")
else:
- print("=========================================================")
+ # print("=========================================================")
print(
self.projName +
".cir.out does not exist. Please create a spice netlist.")
@@ -751,8 +739,8 @@ class MainWindow(QtGui.QWidget):
# Read the data from file
data = f.read()
# Close the file
-
f.close()
+
newNetlist = []
netlist = iter(data.splitlines())
for eachline in netlist:
@@ -803,5 +791,5 @@ class MainWindow(QtGui.QWidget):
out.writelines('\n')
out.writelines('.ends ' + self.projName)
- print("=============================================================")
+ # print("=============================================================")
print("The subcircuit has been written in " + self.projName + ".sub")
diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py
index a182dd4e..3cc3a0cb 100644
--- a/src/kicadtoNgspice/Model.py
+++ b/src/kicadtoNgspice/Model.py
@@ -1,7 +1,6 @@
from PyQt4 import QtGui
import json
from . import TrackWidget
-# from xml.etree import ElementTree as ET
import os
@@ -59,8 +58,6 @@ class Model(QtGui.QWidget):
# line[7] is parameter dictionary holding parameter tags.
i = 0
for key, value in line[7].items():
- # print "Key : ",key
- # print "Value : ",value
# Check if value is iterable
if not isinstance(value, str) and hasattr(value, '__iter__'):
# For tag having vector value
@@ -127,7 +124,6 @@ class Model(QtGui.QWidget):
self.nextrow = self.nextrow + 1
self.end = self.nextcount - 1
- # print "End",self.end
modelbox.setLayout(modelgrid)
# CSS
@@ -173,6 +169,4 @@ class Model(QtGui.QWidget):
if check == 0:
self.obj_trac.modelTrack.append(lst)
- # print "The tag dictionary : ",tag_dict
-
self.show()
diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py
index a0f2c79f..1e58daac 100644
--- a/src/kicadtoNgspice/Processing.py
+++ b/src/kicadtoNgspice/Processing.py
@@ -13,30 +13,28 @@ class PrcocessNetlist:
def __init__(self):
pass
- """
- - Read the circuit file and return splitted lines
- """
-
def readNetlist(self, filename):
+ """
+ - Read the circuit file and return splitted lines
+ """
f = open(filename)
data = f.read()
f.close()
- print("=============================================================")
- print("readNetList called, from Processing")
- print("=============================================================")
- print("NETLIST", data.splitlines())
- print("=============================================================")
+ # print("=============================================================")
+ # print("readNetList called, from Processing")
+ # print("=============================================================")
+ # print("NETLIST", data.splitlines())
+ # print("=============================================================")
return data.splitlines()
- """
- - Read Parameter information and store it into dictionary
- - kicadNetlis is the .cir file content
- """
-
- def readParamInfo(self, kicadNetlis):
+ def readParamInfo(self, kicadNetlist):
+ """
+ - Read Parameter information and store it into dictionary
+ - kicadNetlist is the .cir file content
+ """
param = {}
- print("=========================KICADNETLIST========================")
- for eachline in kicadNetlis:
+ # print("=========================KICADNETLIST========================")
+ for eachline in kicadNetlist:
print(eachline)
eachline = eachline.strip()
if len(eachline) > 1:
@@ -46,21 +44,20 @@ class PrcocessNetlist:
for i in range(1, len(words), 1):
paramList = words[i].split('=')
param[paramList[0]] = paramList[1]
- print("=============================================================")
- print("readParamInfo called, from Processing")
- print("=============================================================")
- print("PARAM", param)
- print("=============================================================")
+ # print("=============================================================")
+ # print("readParamInfo called, from Processing")
+ # print("=============================================================")
+ # print("PARAM", param)
+ # print("=============================================================")
return param
- """
- - Preprocess netlist (replace parameters)
- - Separate infoline (first line) from the rest of netlist
- """
-
- def preprocessNetlist(self, kicadNetlis, param):
+ def preprocessNetlist(self, kicadNetlist, param):
+ """
+ - Preprocess netlist (replace parameters)
+ - Separate infoline (first line) from the rest of netlist
+ """
netlist = []
- for eachline in kicadNetlis:
+ for eachline in kicadNetlist:
# Remove leading and trailing blanks spaces from line
eachline = eachline.strip()
# Remove special character $
@@ -89,12 +86,12 @@ class PrcocessNetlist:
# Copy information line
infoline = netlist[0]
netlist.remove(netlist[0])
- print("=============================================================")
+ """print("=============================================================")
print("preprocessNetList called, from Processing")
print("=============================================================")
print("NETLIST", netlist)
print("INFOLINE", infoline)
- print("=============================================================")
+ print("=============================================================")"""
return netlist, infoline
def separateNetlistInfo(self, netlist):
@@ -114,26 +111,25 @@ class PrcocessNetlist:
optionInfo.append(eachline)
else:
schematicInfo.append(eachline)
- print("=============================================================")
+ """print("=============================================================")
print("separateNetlistInfo called, from Processing")
print("=============================================================")
print("OPTIONINFO", optionInfo)
print("SCHEMATICINFO", schematicInfo)
- print("=============================================================")
+ print("=============================================================")"""
return optionInfo, schematicInfo
- """
- - Insert Special source parameter
- - As per the parameters passed create source list, start with v or i
- - Then check for type whether ac, dc, sine, etc...
- - Handle starting with h and f as well
- """
-
def insertSpecialSourceParam(self, schematicInfo, sourcelist):
+ """
+ - Insert Special source parameter
+ - As per the parameters passed create source list, start with v or i
+ - Then check for type whether ac, dc, sine, etc...
+ - Handle starting with h and f as well
+ """
schematicInfo1 = []
- print("=============================================================")
- print("Reading schematic info for source details")
- print("=============================================================")
+ # print("=============================================================")
+ # print("Reading schematic info for source details")
+ # print("=============================================================")
for compline in schematicInfo:
words = compline.split()
compName = words[0]
@@ -217,14 +213,14 @@ class PrcocessNetlist:
words[5])
schematicInfo = schematicInfo + schematicInfo1
- print("Source List : ", sourcelist)
- # print schematicInfo
- print("=============================================================")
+ # print("Source List : ", sourcelist)
+
+ """print("=============================================================")
print("insertSpecialSourceParam called, from Processing")
print("=============================================================")
print("SCHEMATICINFO", schematicInfo)
print("SOURCELIST", sourcelist)
- print("=============================================================")
+ print("=============================================================")"""
return schematicInfo, sourcelist
def convertICintoBasicBlocks(
@@ -239,8 +235,8 @@ class PrcocessNetlist:
- - Plot text
- Parsing info is provided below
"""
- print("=============================================================")
- print("Reading Schematic info for Model")
+ # print("=============================================================")
+ # print("Reading Schematic info for Model")
# Insert details of Ngspice model
unknownModelList = []
multipleModelList = []
@@ -293,8 +289,8 @@ class PrcocessNetlist:
unknownModelList.append(compType)
elif count == 1:
try:
- print("==========================================\
- ===========================")
+ # print("==========================================\
+ # ===========================")
print(
"Start Parsing Previous Values XML\
for ngspice model :", modelPath)
@@ -355,9 +351,9 @@ class PrcocessNetlist:
modelLine += compName
else:
- print("=====================================\
- ================================")
- print("Split Details :", splitDetail)
+ # print("=====================================\
+ # ================================")
+ # print("Split Details :", splitDetail)
modelLine = "a" + str(k) + " "
vectorDetail = splitDetail.split(':')
# print "Vector Details",vectorDetail
@@ -507,7 +503,7 @@ class PrcocessNetlist:
else:
schematicInfo.insert(index, "* " + compline)
- print("=====================================================")
+ # print("=====================================================")
print(
"UnknownModelList Used in the Schematic",
unknownModelList)
@@ -516,7 +512,7 @@ class PrcocessNetlist:
"Multiple Model XML file with same name ",
multipleModelList)
print("=====================================================")
- print("Model List Details : ", modelList)
+ # print("Model List Details : ", modelList)
print("=============================================================")
print("convertICIntoBasicBlocks called, from Processing")
print("=============================================================")
diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py
index 26555197..6c5ae637 100644
--- a/src/kicadtoNgspice/Source.py
+++ b/src/kicadtoNgspice/Source.py
@@ -1,7 +1,6 @@
import os
from PyQt4 import QtGui
from . import TrackWidget
-# from xml.etree import ElementTree as ET
import json
@@ -13,7 +12,7 @@ class Source(QtGui.QWidget):
def __init__(self, sourcelist, sourcelisttrack, clarg1):
QtGui.QWidget.__init__(self)
self.obj_track = TrackWidget.TrackWidget()
- # Variable
+ # Variables
self.count = 1
self.clarg1 = clarg1
self.start = 0
@@ -45,10 +44,10 @@ class Source(QtGui.QWidget):
- Each line in sourcelist corresponds to a source
- According to the source type modify the source and add it to the tab
"""
- print("============================================================")
+ """print("============================================================")
print("SOURCE LIST TRACK", sourcelisttrack)
print("SOURCE LIST", sourcelist)
- print("============================================================")
+ print("============================================================")"""
kicadFile = self.clarg1
(projpath, filename) = os.path.split(kicadFile)
project_name = os.path.basename(projpath)
@@ -71,10 +70,8 @@ class Source(QtGui.QWidget):
if sourcelist:
for line in sourcelist:
- # print "Voltage source line index: ",line[0]
print("SourceList line: ", line)
track_id = line[0]
- # print "track_id is ",track_id
if line[2] == 'ac':
acbox = QtGui.QGroupBox()
acbox.setTitle(line[3])
@@ -372,7 +369,7 @@ class Source(QtGui.QWidget):
else:
print("No source is present in your circuit")
- print("============================================================")
+ # print("============================================================")
# This is used to keep the track of dynamically created widget
self.obj_track.sourcelisttrack["ITEMS"] = sourcelisttrack
self.obj_track.source_entry_var["ITEMS"] = self.entry_var
diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py
index d15407f7..116b70b1 100644
--- a/src/kicadtoNgspice/SubcircuitTab.py
+++ b/src/kicadtoNgspice/SubcircuitTab.py
@@ -3,7 +3,6 @@ import json
from . import TrackWidget
from projManagement import Validation
import os
-# from xml.etree import ElementTree as ET
class SubcircuitTab(QtGui.QWidget):
@@ -61,7 +60,7 @@ class SubcircuitTab(QtGui.QWidget):
for eachline in schematicInfo:
words = eachline.split()
if eachline[0] == 'x':
- print("Subcircuit : Words", words[0])
+ # print("Subcircuit : Words", words[0])
self.obj_trac.subcircuitList[project_name + words[0]] = words
self.subcircuit_dict_beg[words[0]] = self.count
subbox = QtGui.QGroupBox()
@@ -74,8 +73,6 @@ class SubcircuitTab(QtGui.QWidget):
try:
for key in json_data["subcircuit"]:
if key == words[0]:
- # print "Subcircuit MATCHING---",child.tag[0], \
- # child.tag[1], eachline[0], eachline[1]
try:
if os.path.exists(
json_data["subcircuit"][key][0]):
@@ -97,7 +94,7 @@ class SubcircuitTab(QtGui.QWidget):
# eg. If the line is 'x1 4 0 3 ua741', there are 3 ports(4, 0
# and 3).
self.numPorts.append(len(words) - 2)
- print("Number of ports of sub circuit : ", self.numPorts)
+ # print("Number of ports of sub circuit : ", self.numPorts)
self.addbtn.clicked.connect(self.trackSubcircuit)
subgrid.addWidget(self.addbtn, self.row, 2)
subbox.setLayout(subgrid)
@@ -166,8 +163,8 @@ class SubcircuitTab(QtGui.QWidget):
elif self.reply == "DIREC":
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage(
- "Please select a valid Subcircuit directory \
- (Containing '.sub' file).")
+ "Please select a valid Subcircuit directory "
+ "(Containing '.sub' file).")
self.msg.setWindowTitle("Error Message")
self.msg.show()
@@ -189,7 +186,6 @@ class SubcircuitTab(QtGui.QWidget):
self.subName = self.subDetail[self.widgetObjCount]
# Storing to track it during conversion
-
self.obj_trac.subcircuitTrack[self.subName] = self.subfile
elif self.reply == "PORT":
self.msg = QtGui.QErrorMessage(self)
@@ -200,7 +196,7 @@ class SubcircuitTab(QtGui.QWidget):
elif self.reply == "DIREC":
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage(
- "Please select a valid Subcircuit directory \
- (Containing '.sub' file).")
+ "Please select a valid Subcircuit directory "
+ "(Containing '.sub' file).")
self.msg.setWindowTitle("Error Message")
self.msg.show()
diff --git a/src/kicadtoNgspice/TrackWidget.py b/src/kicadtoNgspice/TrackWidget.py
index ec5c2c81..3a8b0dac 100644
--- a/src/kicadtoNgspice/TrackWidget.py
+++ b/src/kicadtoNgspice/TrackWidget.py
@@ -2,11 +2,11 @@ class TrackWidget:
"""
- This Class track the dynamically created widget of KicadtoNgSpice Window.
- Tracks using dictionary and lists ==>
- - - Sources
- - - Parameters
- - - References
- - - Model Details
- - - ... etc
+ - Sources
+ - Parameters
+ - References
+ - Model Details
+ - ... etc
"""
# Track widget list for Source details
sourcelisttrack = {"ITEMS": "None"}