summaryrefslogtreecommitdiff
path: root/src/kicadtoNgspice
diff options
context:
space:
mode:
authorfahim2015-04-22 17:52:04 +0530
committerfahim2015-04-22 17:52:04 +0530
commit342730ed59f75ebe1b5df0f886ae9e6bcd787ee6 (patch)
tree759bb8348608c67057aa58b4c654d9cb2339f62d /src/kicadtoNgspice
parentaf98d04dd0a438b7dd63ff72c71f0ceb695fe704 (diff)
downloadeSim-342730ed59f75ebe1b5df0f886ae9e6bcd787ee6.tar.gz
eSim-342730ed59f75ebe1b5df0f886ae9e6bcd787ee6.tar.bz2
eSim-342730ed59f75ebe1b5df0f886ae9e6bcd787ee6.zip
Subject: Added Device Libarary Tab.Few Changes in Workspace class.
Description: Completed the Device Library auto creation of Widget. Added the information to schematicInfo.Hence to the final ".cir.out" file. Added sample device library. Deleted/Comment unwanted print statement. Added details of function in the comment.
Diffstat (limited to 'src/kicadtoNgspice')
-rw-r--r--src/kicadtoNgspice/Analysis.py25
-rw-r--r--src/kicadtoNgspice/Analysis.pycbin11829 -> 11920 bytes
-rw-r--r--src/kicadtoNgspice/Convert.py105
-rw-r--r--src/kicadtoNgspice/Convert.pycbin0 -> 11395 bytes
-rw-r--r--src/kicadtoNgspice/DeviceModel.py182
-rw-r--r--src/kicadtoNgspice/DeviceModel.pycbin0 -> 4832 bytes
-rw-r--r--src/kicadtoNgspice/KicadtoNgspice.py66
-rw-r--r--src/kicadtoNgspice/KicadtoNgspice.pycbin7562 -> 7415 bytes
-rw-r--r--src/kicadtoNgspice/Model.py18
-rw-r--r--src/kicadtoNgspice/Model.pycbin0 -> 1945 bytes
-rw-r--r--src/kicadtoNgspice/Processing.py93
-rw-r--r--src/kicadtoNgspice/Processing.pycbin0 -> 8441 bytes
-rw-r--r--src/kicadtoNgspice/Sample.py320
-rw-r--r--src/kicadtoNgspice/Source.py10
-rw-r--r--src/kicadtoNgspice/Source.pycbin0 -> 4000 bytes
-rw-r--r--src/kicadtoNgspice/TrackWidget.py10
-rw-r--r--src/kicadtoNgspice/TrackWidget.pycbin0 -> 887 bytes
17 files changed, 351 insertions, 478 deletions
diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py
index 2dcb43c3..d2870532 100644
--- a/src/kicadtoNgspice/Analysis.py
+++ b/src/kicadtoNgspice/Analysis.py
@@ -4,6 +4,9 @@ from PyQt4.Qt import QRect
import TrackWidget
class Analysis(QtGui.QWidget):
+ """
+ This class create Analysis Tab in KicadtoNgspice Window.
+ """
def __init__(self):
QtGui.QWidget.__init__(self)
self.track_obj= TrackWidget.TrackWidget()
@@ -25,27 +28,7 @@ class Analysis(QtGui.QWidget):
self.grid.addWidget(self.createDCgroup(),2,0)
self.grid.addWidget(self.createTRANgroup(),3,0)
- '''
- self.grid.addWidget(self.createTRANgroup(),3,0)
- self.grid.addWidget(self.createTRANgroup(),4,0)
- self.grid.addWidget(self.createTRANgroup(),5,0)
- self.grid.addWidget(self.createTRANgroup(),6,0)
- self.grid.addWidget(self.createTRANgroup(),7,0)
- self.grid.addWidget(self.createTRANgroup(),8,0)
- self.grid.addWidget(self.createTRANgroup(),9,0)
- self.grid.addWidget(self.createTRANgroup(),10,0)
- self.grid.addWidget(self.createTRANgroup(),11,0)
- self.grid.addWidget(self.createTRANgroup(),12,0)
- self.grid.addWidget(self.createTRANgroup(),13,0)
- self.grid.addWidget(self.createTRANgroup(),14,0)
- self.grid.addWidget(self.createTRANgroup(),15,0)
- self.grid.addWidget(self.createTRANgroup(),16,0)
- self.grid.addWidget(self.createTRANgroup(),17,0)
- self.grid.addWidget(self.createTRANgroup(),18,0)
- self.grid.addWidget(self.createTRANgroup(),19,0)
- self.grid.addWidget(self.createTRANgroup(),20,0)
- '''
-
+
self.setLayout(self.grid)
self.show()
diff --git a/src/kicadtoNgspice/Analysis.pyc b/src/kicadtoNgspice/Analysis.pyc
index b33c052a..89df9218 100644
--- a/src/kicadtoNgspice/Analysis.pyc
+++ b/src/kicadtoNgspice/Analysis.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py
index c0d98548..20597651 100644
--- a/src/kicadtoNgspice/Convert.py
+++ b/src/kicadtoNgspice/Convert.py
@@ -1,10 +1,13 @@
import os
import sys
-
+import shutil
import TrackWidget
class Convert:
+ """
+ This class has all the necessary function required to convert kicad netlist to ngspice netlist.
+ """
def __init__(self,sourcelisttrack,source_entry_var,schematicInfo):
print "Start Conversion"
self.sourcelisttrack = sourcelisttrack
@@ -14,6 +17,9 @@ class Convert:
def addSourceParameter(self):
+ """
+ This function add the source details to schematicInfo
+ """
print "Adding Source parameter"
#print "SourceListTrack : ",self.sourcelisttrack
#print "Schematic Info ",self.schematicInfo
@@ -112,6 +118,9 @@ class Convert:
def analysisInsertor(self,ac_entry_var,dc_entry_var, tran_entry_var,set_checkbox,ac_parameter,dc_parameter,tran_parameter,ac_type):
+ """
+ This function creates an analysis file in current project
+ """
self.ac_entry_var = ac_entry_var
self.dc_entry_var = dc_entry_var
self.tran_entry_var = tran_entry_var
@@ -145,6 +154,9 @@ class Convert:
self.writefile.close()
def converttosciform(self, string_obj):
+ """
+ This function is used for scientific conversion.
+ """
self.string_obj = string_obj
if self.string_obj[0] == 'm':
return "e-03"
@@ -158,6 +170,9 @@ class Convert:
return "e-00"
def defaultvalue(self, value):
+ """
+ This function select default value as 0 if Analysis widget do not hold any value.
+ """
self.value= value
if self.value == '':
return 0
@@ -166,7 +181,9 @@ class Convert:
def addModelParameter(self,schematicInfo):
- print "Schematic info after adding source detail",schematicInfo
+ """
+ This function add the Ngspice Model details to schematicInfo
+ """
#Create object of TrackWidget
self.obj_track = TrackWidget.TrackWidget()
@@ -176,7 +193,7 @@ class Convert:
modelParamValue = []
for line in self.obj_track.modelTrack:
- print "Model Track :",line
+ #print "Model Track :",line
if line[2] == 'transfo':
try:
start=line[5]
@@ -214,8 +231,8 @@ class Convert:
end = line[6]
addmodelLine=".model "+ line[3]+" "+line[2]+"("
for key,value in line[9].iteritems():
- print "Tags: ",key
- print "Value: ",value
+ #print "Tags: ",key
+ #print "Value: ",value
#Checking for default value and accordingly assign param and default.
if ':' in key:
key = key.split(':')
@@ -258,6 +275,78 @@ class Convert:
return schematicInfo
-
-
- \ No newline at end of file
+
+ def addDeviceLibrary(self,schematicInfo,kicadFile):
+ """
+ This function add the library details to schematicInfo
+ """
+ print "Adding Device library to Schematic info file"
+
+ (projpath,filename) = os.path.split(kicadFile)
+
+ print "Project Path",projpath
+
+ deviceLibList = self.obj_track.deviceModelTrack
+ deviceLine = {} #Key:Index, Value:with its updated line in the form of list
+ includeLine = [] #All .include line list
+
+ if not deviceLibList:
+ print "No Library Added in the schematic"
+ pass
+ else:
+ for eachline in schematicInfo:
+ words = eachline.split()
+ if words[0] in deviceLibList:
+ print "Found Library line"
+ index = schematicInfo.index(eachline)
+ completeLibPath = deviceLibList[words[0]]
+ (libpath,libname) = os.path.split(completeLibPath)
+ print "Library Path :",libpath
+ #Copying library from devicemodelLibrary to Project Path
+ #Special case for MOSFET
+ if eachline[0] == 'm':
+ #For mosfet library name come along with MOSFET dimension information
+ tempStr = libname.split(':')
+ libname = tempStr[0]
+ dimension = tempStr[1]
+ #Replace last word with library name
+ words[-1] = libname.split('.')[0]
+ #Appending Dimension of MOSFET
+ words.append(dimension)
+ deviceLine[index] = words
+ includeLine.append(".include "+libname)
+
+ src = completeLibPath.split(':')[0]
+ dst = projpath
+ shutil.copy2(src, dst)
+ else:
+ #Replace last word with library name
+ words[-1] = libname.split('.')[0]
+ deviceLine[index] = words
+ includeLine.append(".include "+libname)
+
+ src = completeLibPath
+ dst = projpath
+ shutil.copy2(src,dst)
+
+ else:
+ pass
+
+
+ #Adding device line to schematicInfo
+ for index,value in deviceLine.iteritems():
+ #Update the device line
+ strLine = " ".join(str(item) for item in value)
+ schematicInfo[index] = strLine
+
+ #This has to be second i.e after deviceLine details
+ #Adding .include line to Schematic Info at the start of line
+ for item in list(set(includeLine)):
+ schematicInfo.insert(0,item)
+
+
+
+
+
+ return schematicInfo
+ \ No newline at end of file
diff --git a/src/kicadtoNgspice/Convert.pyc b/src/kicadtoNgspice/Convert.pyc
new file mode 100644
index 00000000..22a8b4a5
--- /dev/null
+++ b/src/kicadtoNgspice/Convert.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py
new file mode 100644
index 00000000..6fd2b663
--- /dev/null
+++ b/src/kicadtoNgspice/DeviceModel.py
@@ -0,0 +1,182 @@
+from PyQt4 import QtGui
+
+import TrackWidget
+
+
+class DeviceModel(QtGui.QWidget):
+ """
+ This class creates Device Library Tab in KicadtoNgspice Window
+ It dynamically creates the widget for device like diode,mosfet,transistor and jfet.
+ """
+
+ def __init__(self,schematicInfo):
+ QtGui.QWidget.__init__(self)
+ #print "Starting Device Modeling"
+
+ #Creating track widget object
+ self.obj_trac = TrackWidget.TrackWidget()
+
+ #Row and column count
+ self.row = 0
+ self.count = 1 #Entry count
+ self.entry_var = {}
+
+ #For MOSFET
+ self.widthLabel = {}
+ self.lengthLabel = {}
+ self.multifactorLable = {}
+
+
+ #List to hold information about device
+ self.deviceDetail = {}
+
+ #Set Layout
+ self.grid = QtGui.QGridLayout()
+ self.setLayout(self.grid)
+
+ for eachline in schematicInfo:
+ words = eachline.split()
+ if eachline[0] == 'q':
+ print "Words ",words[0]
+ self.label = QtGui.QLabel("Add library for Transistor "+words[0]+" : "+words[4])
+ self.grid.addWidget(self.label,self.row,0)
+ self.entry_var[self.count] = QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.addbtn = QtGui.QPushButton("Add")
+ self.addbtn.setObjectName("%d" %self.count)
+ self.addbtn.clicked.connect(self.trackLibrary)
+ self.grid.addWidget(self.addbtn,self.row,2)
+
+ #Adding Device Details
+ self.deviceDetail[self.count] = words[0]
+
+ #Increment row and widget count
+ self.row = self.row+1
+ self.count = self.count+1
+
+ elif eachline[0] == 'd':
+ print "Words",words[0]
+ self.label = QtGui.QLabel("Add library for Diode "+words[0]+" : "+words[3])
+ self.grid.addWidget(self.label,self.row,0)
+ self.entry_var[self.count] = QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.addbtn = QtGui.QPushButton("Add")
+ self.addbtn.setObjectName("%d" %self.count)
+ self.addbtn.clicked.connect(self.trackLibrary)
+ self.grid.addWidget(self.addbtn,self.row,2)
+
+ #Adding Device Details
+ self.deviceDetail[self.count] = words[0]
+
+ #Increment row and widget count
+ self.row = self.row+1
+ self.count = self.count+1
+
+ elif eachline[0] == 'j':
+ print "Words",words[0]
+ self.label = QtGui.QLabel("Add library for JFET "+words[0]+" : "+words[4])
+ self.grid.addWidget(self.label,self.row,0)
+ self.entry_var[self.count] = QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.addbtn = QtGui.QPushButton("Add")
+ self.addbtn.setObjectName("%d" %self.count)
+ self.addbtn.clicked.connect(self.trackLibrary)
+ self.grid.addWidget(self.addbtn,self.row,2)
+
+ #Adding Device Details
+ self.deviceDetail[self.count] = words[0]
+
+ #Increment row and widget count
+ self.row = self.row+1
+ self.count = self.count+1
+
+
+
+ elif eachline[0] == 'm':
+ self.label = QtGui.QLabel("Add library for MOSFET "+words[0]+" : "+words[5])
+ self.grid.addWidget(self.label,self.row,0)
+ self.entry_var[self.count] =QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.addbtn = QtGui.QPushButton("Add")
+ self.addbtn.setObjectName("%d" %self.count)
+ self.addbtn.clicked.connect(self.trackLibrary)
+ self.grid.addWidget(self.addbtn,self.row,2)
+
+ #Adding Device Details
+ self.deviceDetail[self.count] = words[0]
+
+ #Increment row and widget count
+ self.row = self.row+1
+ self.count = self.count+1
+
+ #Adding to get MOSFET dimension
+ self.widthLabel[self.count] = QtGui.QLabel("Enter width of MOSFET "+words[0]+"(default=100u):")
+ self.grid.addWidget(self.widthLabel[self.count],self.row,0)
+ self.entry_var[self.count] = QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.entry_var[self.count].setMaximumWidth(150)
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.row = self.row + 1
+ self.count = self.count+1
+
+ self.lengthLabel[self.count] = QtGui.QLabel("Enter length of MOSFET "+words[0]+"(default=100u):")
+ self.grid.addWidget(self.lengthLabel[self.count],self.row,0)
+ self.entry_var[self.count] = QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.entry_var[self.count].setMaximumWidth(150)
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.row = self.row + 1
+ self.count = self.count+1
+
+
+ self.multifactorLable[self.count] = QtGui.QLabel("Enter multiplicative factor of MOSFET "+words[0]+"(default=1):")
+ self.grid.addWidget(self.multifactorLable[self.count],self.row,0)
+ self.entry_var[self.count] = QtGui.QLineEdit()
+ self.entry_var[self.count].setText("")
+ self.entry_var[self.count].setMaximumWidth(150)
+ self.grid.addWidget(self.entry_var[self.count],self.row,1)
+ self.row = self.row + 1
+ self.count = self.count+1
+
+
+ self.show()
+
+
+ def trackLibrary(self):
+ """
+ This function is use to keep track of all Device Model widget
+ """
+ print "Calling Track Library funtion"
+ sending_btn = self.sender()
+ #print "Object Called is ",sending_btn.objectName()
+ self.widgetObjCount = int(sending_btn.objectName())
+
+ self.libfile = str(QtGui.QFileDialog.getOpenFileName(self,"Open Library Directory","../deviceModelLibrary"))
+ #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())
+ multifactor = str(self.entry_var[self.widgetObjCount+3].text())
+ if width == "" : width="100u"
+ if length == "": length="100u"
+ if multifactor == "": multifactor="1"
+
+ self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile+":"+"W="+width+" L="+length+" M="+multifactor
+
+ else:
+ self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile
+
+
+ \ No newline at end of file
diff --git a/src/kicadtoNgspice/DeviceModel.pyc b/src/kicadtoNgspice/DeviceModel.pyc
new file mode 100644
index 00000000..f747be9c
--- /dev/null
+++ b/src/kicadtoNgspice/DeviceModel.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py
index f05f2ebe..f8faa997 100644
--- a/src/kicadtoNgspice/KicadtoNgspice.py
+++ b/src/kicadtoNgspice/KicadtoNgspice.py
@@ -22,12 +22,17 @@ from Processing import PrcocessNetlist
import Analysis
import Source
import Model
+import DeviceModel
import Convert
import TrackWidget
class MainWindow(QtGui.QWidget):
+ """
+ This class craete KicadtoNgspice window.
+ And Call Convert function if convert button is pressed.
+ """
def __init__(self):
QtGui.QWidget.__init__(self)
#Create object of track widget
@@ -69,11 +74,18 @@ class MainWindow(QtGui.QWidget):
self.modelTab.setWidget(Model.Model(schematicInfo,modelList))
#self.modelTabLayout = QtGui.QVBoxLayout(self.modelTab.widget())
self.modelTab.setWidgetResizable(True)
+
+ self.deviceModelTab = QtGui.QScrollArea()
+ self.deviceModelTab.setWidget(DeviceModel.DeviceModel(schematicInfo))
+ self.deviceModelTab.setWidgetResizable(True)
+
+
self.tabWidget = QtGui.QTabWidget()
- self.tabWidget.addTab(self.analysisTab,"Analysis Tab")
- self.tabWidget.addTab(self.sourceTab,"Source Tab")
- self.tabWidget.addTab(self.modelTab,"Model Tab")
+ self.tabWidget.addTab(self.analysisTab,"Analysis")
+ self.tabWidget.addTab(self.sourceTab,"Source Details")
+ self.tabWidget.addTab(self.modelTab,"NgSpice Model")
+ self.tabWidget.addTab(self.deviceModelTab,"Device Modeling")
self.mainLayout = QtGui.QVBoxLayout()
self.mainLayout.addWidget(self.tabWidget)
#self.mainLayout.addStretch(1)
@@ -97,9 +109,14 @@ class MainWindow(QtGui.QWidget):
#Adding Source Value to Schematic Info
schematicInfo = self.obj_convert.addSourceParameter()
- #Adding Model Value to schematic Info
+ #Adding Model Value to schematicInfo
schematicInfo = self.obj_convert.addModelParameter(schematicInfo)
+ #Adding Device Library to SchematicInfo
+ schematicInfo = self.obj_convert.addDeviceLibrary(schematicInfo,kicadFile)
+
+
+
analysisoutput = self.obj_convert.analysisInsertor(self.obj_track.AC_entry_var["ITEMS"],
self.obj_track.DC_entry_var["ITEMS"],
self.obj_track.TRAN_entry_var["ITEMS"],
@@ -108,36 +125,35 @@ class MainWindow(QtGui.QWidget):
self.obj_track.DC_Parameter["ITEMS"],
self.obj_track.TRAN_Parameter["ITEMS"],
self.obj_track.AC_type["ITEMS"])
- print "SchematicInfo after adding Model Details",schematicInfo
+ #print "SchematicInfo after adding Model Details",schematicInfo
+
#Calling netlist file generation function
- self.createNetlistFile()
+ self.createNetlistFile(schematicInfo)
+
self.msg = "The Kicad to Ngspice Conversion completed successfully!!!!!!"
QtGui.QMessageBox.information(self, "Information", self.msg, QtGui.QMessageBox.Ok)
self.close()
except Exception as e:
print "Exception Message: ",e
- print "SchematicInfo after adding Model Details",schematicInfo
print "There was error while converting kicad to ngspice"
self.close()
- def createNetlistFile(self):
+ def createNetlistFile(self,schematicInfo):
print "Creating Final netlist"
- print "INFOLINE",infoline
- print "OPTIONINFO",optionInfo
- print "Device MODEL LIST ",devicemodelList
- print "SUBCKT ",subcktList
- print "OUTPUTOPTION",outputOption
- print "KicadfIle",kicadFile
+ #print "INFOLINE",infoline
+ #print "OPTIONINFO",optionInfo
+ #print "Device MODEL LIST ",devicemodelList
+ #print "SUBCKT ",subcktList
+ #print "OUTPUTOPTION",outputOption
+ #print "KicadfIle",kicadFile
#checking if analysis files is present
- (filepath,filename) = os.path.split(kicadFile)
- analysisFileLoc = os.path.join(filepath,"analysis")
- print "FilePath",filepath
- print "FileName",filename
- print "Analysis File Location",analysisFileLoc
+ (projpath,filename) = os.path.split(kicadFile)
+ analysisFileLoc = os.path.join(projpath,"analysis")
+ #print "Analysis File Location",analysisFileLoc
if os.path.exists(analysisFileLoc):
try:
f = open(analysisFileLoc)
@@ -163,7 +179,7 @@ class MainWindow(QtGui.QWidget):
else:
pass
- print "Option Info",optionInfo
+ #print "Option Info",optionInfo
analysisOption = []
initialCondOption=[]
simulatorOption =[]
@@ -255,15 +271,7 @@ def main(args):
print "OPTIONINFO",optionInfo
print "SCHEMATICINFO",schematicInfo
- #Getting model and subckt list
- global devicemodelList,subcktList
- devicemodelList = []
- subcktList = []
- devicemodelList,subcktList = obj_proc.getModelSubcktList(schematicInfo,devicemodelList,subcktList)
-
- print "Device MODEL LIST ",devicemodelList
- print "SUBCKT ",subcktList
-
+
#List for storing source and its value
global sourcelist, sourcelisttrack
sourcelist=[]
diff --git a/src/kicadtoNgspice/KicadtoNgspice.pyc b/src/kicadtoNgspice/KicadtoNgspice.pyc
index 29e4d0c6..de20b98b 100644
--- a/src/kicadtoNgspice/KicadtoNgspice.pyc
+++ b/src/kicadtoNgspice/KicadtoNgspice.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py
index 79f47ce0..f450cf56 100644
--- a/src/kicadtoNgspice/Model.py
+++ b/src/kicadtoNgspice/Model.py
@@ -5,12 +5,16 @@ import TrackWidget
class Model(QtGui.QWidget):
+ """
+ This class creates Model Tab of KicadtoNgspice window.
+ The widgets are created dynamically in the Model Tab.
+ """
def __init__(self,schematicInfo,modelList):
QtGui.QWidget.__init__(self)
- print "Start Ngspice Modelling"
- print "Schematic Info in Model Widget",schematicInfo
- print "Model List",modelList
+ #print "Start Ngspice Modelling"
+ #print "Schematic Info in Model Widget",schematicInfo
+ #print "Model List",modelList
#Creating track widget object
self.obj_trac = TrackWidget.TrackWidget()
@@ -28,7 +32,7 @@ class Model(QtGui.QWidget):
self.setLayout(self.grid)
for line in modelList:
- print "ModelList Item:",line
+ #print "ModelList Item:",line
#Adding title label for model
#Key: Tag name,Value:Entry widget number
tag_dict = {}
@@ -38,8 +42,8 @@ class Model(QtGui.QWidget):
self.nextrow=self.nextrow+1
#line[7] is parameter dictionary holding parameter tags.
for key,value in line[7].iteritems():
- print "Key : ",key
- print "Value : ",value
+ #print "Key : ",key
+ #print "Value : ",value
#Check if value is iterable
if hasattr(value, '__iter__'):
#For tag having vector value
@@ -73,6 +77,8 @@ class Model(QtGui.QWidget):
line[6] = type i.e analog or digital
Now adding start,end and tag_dict which will be line[7],line[8] and line[9] respectively
'''
+
+ #This keeps the track of Model Tab Widget
self.obj_trac.modelTrack.append([line[0],line[1],line[2],line[3],line[4],line[5],line[6],self.start,self.end,tag_dict])
print "The tag dictionary : ",tag_dict
diff --git a/src/kicadtoNgspice/Model.pyc b/src/kicadtoNgspice/Model.pyc
new file mode 100644
index 00000000..72aaef1b
--- /dev/null
+++ b/src/kicadtoNgspice/Model.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py
index 63f38bb2..6fb79921 100644
--- a/src/kicadtoNgspice/Processing.py
+++ b/src/kicadtoNgspice/Processing.py
@@ -5,6 +5,10 @@ from xml.etree import ElementTree as ET
class PrcocessNetlist:
+ """
+ This class include all the function required for pre-proccessing of netlist
+ before converting to Ngspice Netlist.
+ """
modelxmlDIR = '../modelParamXML'
def __init__(self):
pass
@@ -75,62 +79,7 @@ class PrcocessNetlist:
schematicInfo.append(eachline)
return optionInfo,schematicInfo
- def getModelSubcktList(self,schematicInfo,modelList,subcktList):
- #Processing Netlist for modellist and subcktlist details
- for eachline in schematicInfo:
- words = eachline.split()
- if eachline[0]=='d':
- modelName=words[3]
- if modelName in modelList:
- continue
- else:
- modelList.append(modelName)
- elif eachline[0]=='q':
- modelName=words[4]
- index=schematicInfo.index(eachline)
- schematicInfo.remove(eachline)
- schematicInfo.insert(index,words[0]+" "+words[3]+" "+words[2]+" "+words[1]+" "+words[4])
- if modelName in modelList:
- continue
- else:
- modelList.append(modelName)
- elif eachline[0]=='m':
- modelName=words[4]
- index=schematicInfo.index(eachline)
- schematicInfo.remove(eachline)
- '''
- width=raw_input(' Enter width of mosfet '+words[0]+'(default=100u):')
- length=raw_input(' Enter length of mosfet '+words[0]+'(default=100u):')
- multiplicative_factor=raw_input(' Enter multiplicative factor of mosfet '+words[0]+'(default=1):')
-
- if width=="": width="100u"
- if multiplicative_factor=="": multiplicative_factor="100u"
- if length=="": length="100u"
- schematicInfo.insert(index,words[0]+" "+words[1]+" "+words[2]+" "+words[3]+" "+words[3]+" "+words[4]+" "+'M='+multiplicative_factor+" "+'L='+length+" "+'W='+width)
- '''
-
- schematicInfo.insert(index,words[0]+" "+words[1]+" "+words[2]+" "+words[3]+" "+words[3]+" "+words[4])
- if modelName in modelList:
- continue
- modelList.append(modelName)
- elif eachline[0]=='j':
- modelName=words[4]
- index=schematicInfo.index(eachline)
- schematicInfo.remove(eachline)
- schematicInfo.insert(index,words[0]+" "+words[1]+" "+words[2]+" "+words[3]+" "+words[4])
- if modelName in modelList:
- continue
- else:
- modelList.append(modelName)
- elif eachline[0]=='x':
- subcktName=words[len(words)-1]
- if subcktName in subcktList:
- continue
- else:
- subcktList.append(subcktName)
- return modelList,subcktList
-
def insertSpecialSourceParam(self,schematicInfo,sourcelist):
#Inser Special source parameter
schematicInfo1=[]
@@ -337,39 +286,7 @@ class PrcocessNetlist:
#print "Count",count
#print "UnknownModelList",unknownModelList
#print "MultipleModelList",multipleModelList
- '''
- if compType=="gain":
- schematicInfo.append("a"+str(k)+" "+words[1]+" "+words[2]+" "+compName)
- k=k+1
- #Insert comment at remove line
- schematicInfo.insert(index,"* "+compline)
- print "-----------------------------------------------------------\n"
- print "Adding Gain"
- Comment='* Gain '+compType
- Title='Add parameters for Gain '+compName
- in_offset=' Enter offset for input (default=0.0): '
- gain=' Enter gain (default=1.0): '
- out_offset=' Enter offset for output (default=0.0): '
- print "-----------------------------------------------------------"
- modelList.append([index,compline,compType,compName,Comment,Title,in_offset,gain,out_offset])
- elif compType=="summer":
- schematicInfo.append("a"+str(k)+" ["+words[1]+" "+words[2]+"] "+words[3]+" "+compName)
- k=k+1
- #Insert comment at remove line
- schematicInfo.insert(index,"* "+compline)
- print "-----------------------------------------------------------\n"
- print "Adding summer"
- Comment='* Summer '+compType
- Title='Add parameters for Summer '+compName
- in1_offset=' Enter offset for input 1 (default=0.0): '
- in2_offset=' Enter offset for input 2 (default=0.0): '
- in1_gain=' Enter gain for input 1 (default=1.0): '
- in2_gain=' Enter gain for input 2 (default=1.0): '
- out_gain=' Enter gain for output (default=1.0): '
- out_offset=' Enter offset for output (default=0.0): '
- print "-----------------------------------------------------------"
- modelList.append([index,compline,compType,compName,Comment,Title,in1_offset,in2_offset,in1_gain,in2_gain,out_gain,out_offset])
- '''
+
return schematicInfo,outputOption,modelList,unknownModelList,multipleModelList
diff --git a/src/kicadtoNgspice/Processing.pyc b/src/kicadtoNgspice/Processing.pyc
new file mode 100644
index 00000000..efd69b68
--- /dev/null
+++ b/src/kicadtoNgspice/Processing.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/Sample.py b/src/kicadtoNgspice/Sample.py
deleted file mode 100644
index 5f562724..00000000
--- a/src/kicadtoNgspice/Sample.py
+++ /dev/null
@@ -1,320 +0,0 @@
-from PyQt4 import QtGui,QtCore
-
-import sys
-import re
-import datetime
-################################################################
-def main():
- app = QtGui.QApplication(sys.argv)
- mw = MainWindow()
- sys.exit(app.exec_())
-
-################################################################
-class MainWindow(QtGui.QMainWindow):
- def __init__(self):
- QtGui.QMainWindow.__init__(self)
-
- # create stuff
- self.rw = ReportWidget()
- self.setCentralWidget(self.rw)
- self.sw = StartWindow()
- self.createActions()
- self.createMenus()
- self.createStatusBar()
-
- # create progress bar
- self.pb = QtGui.QProgressBar(self.statusBar())
- self.statusBar().addPermanentWidget(self.pb)
-
- # connections
- self.connect(self.sw, QtCore.Qt.SIGNAL("okClicked"),
- self.rw.create)
- self.connect(self.rw.table, QtCore.Qt.SIGNAL("progressChanged"),
- self.update_progress)
- self.connect(self.rw.table, QtCore.Qt.SIGNAL("displayFinished"),
- self.hide_progress_bar)
-
- # format the main window
- self.setGeometry(100,100,750,550)
-
- # show windows
- self.show()
- self.sw.show()
-
- def update_progress(self, n, nrows):
- self.pb.show()
- self.pb.setRange(0, nrows)
- self.pb.setValue(n)
- self.statusBar().showMessage(self.tr("Parsing eventlog data..."))
-
- def hide_progress_bar(self):
- self.pb.hide()
- self.statusBar().showMessage(self.tr("Finished"))
-
- def about(self):
- QtGui.QMessageBox.about(self, self.tr("About AIS Audit Tool"),
- self.tr("AIS Audit Tool\n\n"
- "%s\n"
- "%s\n"
- "%s" % (__author__, __version__, __date__)))
-
- def createActions(self):
- self.exitAct = QtGui.QAction(self.tr("E&xit;"), self)
- self.exitAct.setShortcut(self.tr("Ctrl+Q"))
- self.exitAct.setStatusTip(self.tr("Exit the application"))
- self.connect(self.exitAct, QtCore.Qt.SIGNAL("triggered()"), self, QtCore.Qt.SLOT("close()"))
-
- self.aboutAct = QtGui.QAction(self.tr("&About;"), self)
- self.aboutAct.setStatusTip(self.tr("Show the application's About box"))
- self.connect(self.aboutAct, QtCore.Qt.SIGNAL("triggered()"), self.about)
-
- self.aboutQtAct = QtGui.QAction(self.tr("About &Qt;"), self)
- self.aboutQtAct.setStatusTip(self.tr("Show the Qt library's About box"))
- self.connect(self.aboutQtAct, QtCore.Qt.SIGNAL("triggered()"), qApp, QtCore.Qt.SLOT("aboutQt()"))
-
- def createMenus(self):
- self.fileMenu = self.menuBar().addMenu(self.tr("&File;"))
- self.fileMenu.addAction(self.exitAct)
-
- self.helpMenu = self.menuBar().addMenu(self.tr("&Help;"))
- self.helpMenu.addAction(self.aboutAct)
- self.helpMenu.addAction(self.aboutQtAct)
-
- def createStatusBar(self):
- sb = QtGui.QStatusBar()
- sb.setFixedHeight(18)
- self.setStatusBar(sb)
- self.statusBar().showMessage(self.tr("Ready"))
-
-################################################################
-class StartWindow(QtGui.QWidget):
- def __init__(self, *args):
- QtGui.QWidget.__init__(self, *args)
-
- # date box
- self.label_date = QtGui.QLabel()
- self.label_date.setText("Set date of last audit:")
- default = datetime.date.today() - datetime.timedelta(DEFAULT_DAYS_FROM_LAST_AUDIT)
- self.datebox = QtGui.QDateEdit(QtCore.Qt.QDate(default.year, default.month, default.day))
-
- # buttons
- spacer = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding)
- self.button_ok = QtGui.QPushButton()
- self.button_ok.setText("OK")
- self.button_ok.setDefault(True)
- button_cancel = QtGui.QPushButton()
- button_cancel.setText("Cancel")
-
- # layout
- layout_right = QtGui.QVBoxLayout(self)
- layout_right.addWidget(self.label_date)
- layout_right.addWidget(self.datebox)
- layout_right.addItem(spacer)
- layout_right.addWidget(self.button_ok)
- layout_right.addWidget(button_cancel)
-
- # connections
- self.connect(button_cancel, QtCore.Qt.SIGNAL("clicked(bool)"),
- self.close)
- self.connect(self.button_ok, QtCore.Qt.SIGNAL("clicked(bool)"),
- self.ok_clicked)
-
- def ok_clicked(self):
- self.close()
- year = self.datebox.date().year()
- month = self.datebox.date().month()
- day = self.datebox.date().day()
- dateobj = datetime.date(int(year),int(month),int(day))
- self.emit(QtCore.Qt.SIGNAL("okClicked"), dateobj)
-
-################################################################
-class ReportWidget(QtGui.QWidget):
- def __init__(self, *args):
- QtGui.QWidget.__init__(self, *args)
- self.cbUsers = QtGui.QCheckBox("Hide SYSTEM users")
- self.cbSorting = QtGui.QCheckBox("Sorting enabled")
- self.table = MyTable()
- self.textbrowser = QtGui.QTextBrowser()
- self.textbrowser.setFontFamily("Courier")
- self.textbrowser.setFontPointSize(10)
- hlayout = QtGui.QHBoxLayout()
- hlayout.addWidget(self.cbUsers)
- hlayout.addWidget(self.cbSorting)
- vlayout = QtGui.QVBoxLayout()
- vlayout.setMargin(2)
- vlayout.addLayout(hlayout)
- vlayout.addWidget(self.table)
- self.setLayout(vlayout)
- self.setGeometry(100,100,750,550)
-
- # connections
- self.connect(self.cbUsers, QtCore.Qt.SIGNAL("stateChanged(int)"),
- self.cbUsersChanged)
- self.connect(self.cbSorting, QtCore.Qt.SIGNAL("stateChanged(int)"),
- self.cbSortingChanged)
-
- def create(self, dateobj):
- """ Parses the eventlog data, displays it in a table, and
- displays the user login/logout also """
- self.table.display_data(dateobj)
-
- def cbUsersChanged(self):
- state = self.cbUsers.checkState()
- if state == 0:
- self.table.show_system_users()
- elif state == 2:
- self.table.hide_system_users()
-
- def cbSortingChanged(self):
- state = self.cbSorting.checkState()
- if state == 0:
- self.table.setSortingEnabled(False)
- elif state == 2:
- self.table.setSortingEnabled(True)
-
-################################################################
-class MyTable(QtGui.QTableWidget):
- """ Creates a custom table widget """
- def __init__(self, *args):
- QtGui.QTableWidget.__init__(self, *args)
- self.setSelectionMode(self.ContiguousSelection)
- self.setGeometry(0,0,700,400)
- self.setShowGrid(False)
- self.other_users_list = []
-
- def hide_system_users(self):
- for n in self.other_users_list:
- self.setRowHidden(n, True)
-
- def show_system_users(self):
- for n in self.other_users_list:
- self.setRowHidden(n, False)
-
- def display_data(self, dateobj):
- """ Reads in data as a 2D list and formats and displays it in
- the table """
-
- print "Fetching data..."
- ep = EventlogParser()
- data = ep.parse_log(dateobj)
- print "Done."
-
- if len(data)==0:
- data = ["No data for this date range."]
-
- nrows = len(data)
- ncols = len(data[0])
- self.setRowCount(nrows)
- self.setColumnCount(ncols)
- self.setHorizontalHeaderLabels(['No.', 'Date','Time','Type','Event','User','Computer'])
-
- for i in xrange(len(data)):
- # update progress dialog
- if (i%20) == 0:
- self.emit(QtCore.Qt.SIGNAL("progressChanged"), i, nrows)
- qApp.processEvents()
-
- # set each cell to be a QTableWidgetItem from the _process_row method
- items = self._process_row(data[i])
- for j in range(len(items)):
- self.setItem(i, j, items[j])
- self.setRowHeight(i, 16)
-
- # set column width first time through
- if i == 0:
- self.resizeColumnsToContents()
- self.setColumnWidth(4, 250)
-
- # format column width
- self.resizeColumnsToContents()
- self.setColumnWidth(4, 250)
-
- # emit signal for finished processing
- self.emit(QtCore.Qt.SIGNAL("displayFinished"))
-
- def _process_row(self, row):
- """ Formats items in the row of the 2-D list data
- Input: the row of data from the EventlogParser in a list
- Returns a list of QTableWidgetItems to be one row in the table
- """
-
- icon = []
- for i in xrange(len(row)):
- # general formatting for all cells (may be overwritten)
- icon.append(QtGui.QIcon())
- computer = row[6]
-
- # time processing
- if i == 2:
- try:
- hour = int(re.split(r":", row[i])[0])
- except:
- raise
- if hour <= EARLY_HOUR or hour >= LATE_HOUR:
- backcolor_time = QtGui.QColor(0,0,102)
- else:
- backcolor_time = QtGui.QColor("white")
-
- # success or failure processing
- elif i == 3:
- if row[i] == "8":
- row[i] = "Success"
- icon[i] = QtGui.QIcon("success.png")
- elif row[i] == "16":
- row[i] = "Failure"
- icon[i] = QtGui.QIcon("failure.png")
- else:
- row[i] = "Unknown"
- icon[i] = QtGui.QIcon("unknown.png")
-
- # event processing
- elif i == 4:
- backcolor = QtGui.QColor("white")
- if row[i] in RED_EVENTIDS:
- backcolor = QtGui.QColor("red")
- elif row[i] in ORANGE_EVENTIDS:
- backcolor = QtGui.QColor("orange")
- elif row[i] in YELLOW_EVENTIDS:
- backcolor = QtGui.QColor("yellow")
- elif row[i] in GREEN_EVENTIDS:
- pass
- elif row[i] in OTHER_EVENTIDS:
- backcolor = QtGui.QColor("blue")
- try:
- row[i] = row[i] + ": " + EVENT_DESC[row[i]]
- except:
- pass
-
- # user processing
- elif i == 5:
- if row[i] in (computer, "", "SYSTEM", "NETWORK SERVICE", "LOCAL SERVICE", "ANONYMOUS LOGON"):
- font = QtGui.QFont("Arial", 8)
- font.setBold(False)
- textcolor = QtGui.QColor("gray")
- user = 'other'
- else:
- font = QtGui. QFont("Arial", 8)
- font.setBold(True)
- textcolor = QtGui.QColor("black")
- user = 'user'
-
- # create table widget item
- tableitem_list = []
- for i in xrange(len(row)):
- tableitem = QtGui.QTableWidgetItem(row[i])
- if i == 2:
- tableitem.setBackgroundColor(backcolor_time)
- else:
- tableitem.setBackgroundColor(backcolor)
- tableitem.setTextColor(textcolor)
- tableitem.setFont(font)
- tableitem.setTextAlignment(QtCore.Qt.AlignTop)
- tableitem.setToolTip(row[i])
- tableitem.setIcon(icon[i])
- tableitem_list.append(tableitem)
-
- return tableitem_list
-
-################################################################
-if __name__ == "__main__":
- main()
diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py
index ee460cb0..6b9a2aa4 100644
--- a/src/kicadtoNgspice/Source.py
+++ b/src/kicadtoNgspice/Source.py
@@ -5,6 +5,9 @@ import TrackWidget
class Source(QtGui.QWidget):
+ """
+ This class create Source Tab of KicadtoNgSpice Window.
+ """
def __init__(self,sourcelist,sourcelisttrack):
QtGui.QWidget.__init__(self)
@@ -24,6 +27,9 @@ class Source(QtGui.QWidget):
def createSourceWidget(self,sourcelist,sourcelisttrack):
+ """
+ This function dynamically create source widget in the Source tab of KicadtoNgSpice window
+ """
self.grid = QtGui.QGridLayout()
self.setLayout(self.grid)
@@ -33,7 +39,7 @@ class Source(QtGui.QWidget):
#print "Voltage source line index: ",line[0]
#print "SourceList line Test: ",line
track_id=line[0]
- print "track_id is ",track_id
+ #print "track_id is ",track_id
if line[2]=='ac':
label=QtGui.QLabel(line[3])
self.grid.addWidget(label,self.row,1)
@@ -143,7 +149,7 @@ class Source(QtGui.QWidget):
print "No source is present in your circuit"
-
+ #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
self.show()
diff --git a/src/kicadtoNgspice/Source.pyc b/src/kicadtoNgspice/Source.pyc
new file mode 100644
index 00000000..e023e82e
--- /dev/null
+++ b/src/kicadtoNgspice/Source.pyc
Binary files differ
diff --git a/src/kicadtoNgspice/TrackWidget.py b/src/kicadtoNgspice/TrackWidget.py
index 3ecbd883..f6c4969d 100644
--- a/src/kicadtoNgspice/TrackWidget.py
+++ b/src/kicadtoNgspice/TrackWidget.py
@@ -1,7 +1,6 @@
class TrackWidget:
"""
- This Class track the widget of Kicad to NgSpice converter
- module.
+ This Class track the dynamically created widget of KicadtoNgSpice Window.
"""
#Track widget list for Source details
sourcelisttrack = {"ITEMS":"None"}
@@ -17,6 +16,9 @@ class TrackWidget:
set_CheckBox = {"ITEMS":"None"}
AC_type = {"ITEMS":"None"}
- #Track widget for Model details
+ #Track widget for Model detail
modelTrack = []
- model_entry_var = {} \ No newline at end of file
+ model_entry_var = {}
+
+ #Track Widget for Device Model detail
+ deviceModelTrack = {} \ No newline at end of file
diff --git a/src/kicadtoNgspice/TrackWidget.pyc b/src/kicadtoNgspice/TrackWidget.pyc
new file mode 100644
index 00000000..388068f9
--- /dev/null
+++ b/src/kicadtoNgspice/TrackWidget.pyc
Binary files differ