diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .gitignore~ | 0 | ||||
-rw-r--r-- | src/SubcircuitLibrary/lm555n/analysis | 2 | ||||
-rw-r--r-- | src/SubcircuitLibrary/lm555n/lm555n.cir.out | 2 | ||||
-rw-r--r-- | src/SubcircuitLibrary/lm555n/lm555n_Previous_Values.xml | 2 | ||||
-rwxr-xr-x | src/frontEnd/Application.py | 9 | ||||
-rw-r--r-- | src/frontEnd/DockArea.py | 32 | ||||
-rw-r--r-- | src/kicadtoNgspice/Analysis.py | 10 | ||||
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 7 | ||||
-rw-r--r-- | src/kicadtoNgspice/DeviceModel.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 188 | ||||
-rw-r--r-- | src/kicadtoNgspice/Model.py | 13 | ||||
-rw-r--r-- | src/kicadtoNgspice/Source.py | 5 | ||||
-rw-r--r-- | src/kicadtoNgspice/SubcircuitTab.py | 6 | ||||
-rw-r--r-- | src/kicadtoNgspice/TrackWidget.py | 2 | ||||
-rw-r--r-- | src/ngspiceSimulation/pythonPlotting.py | 1 | ||||
-rw-r--r-- | src/projManagement/Kicad.py | 9 | ||||
-rw-r--r-- | src/subcircuit/Subcircuit.py | 4 | ||||
-rw-r--r-- | src/subcircuit/convertSub.py | 11 |
19 files changed, 192 insertions, 119 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2f78cf5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc + diff --git a/.gitignore~ b/.gitignore~ new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/.gitignore~ diff --git a/src/SubcircuitLibrary/lm555n/analysis b/src/SubcircuitLibrary/lm555n/analysis index 52ccc5ec..31bc5ccd 100644 --- a/src/SubcircuitLibrary/lm555n/analysis +++ b/src/SubcircuitLibrary/lm555n/analysis @@ -1 +1 @@ -.ac lin 0 0Hz 0Hz
\ No newline at end of file +.ac oct 897897 kjadsfhHz jhdsakjHz
\ No newline at end of file diff --git a/src/SubcircuitLibrary/lm555n/lm555n.cir.out b/src/SubcircuitLibrary/lm555n/lm555n.cir.out index f25b1e46..21ca75a9 100644 --- a/src/SubcircuitLibrary/lm555n/lm555n.cir.out +++ b/src/SubcircuitLibrary/lm555n/lm555n.cir.out @@ -20,7 +20,7 @@ a2 1 4 5 21 21 8 10 u6 .model u5 d_inverter(fall_delay=1.0e-9 input_load=1.0e-12 rise_delay=1.0e-9 ) * Schematic Name: d_srlatch, NgSpice Name: d_srlatch .model u6 d_srlatch(ic=0 sr_load=1.0e-12 set_delay=1.0e-9 set_load=1.0e-12 sr_delay=1.0e-9 reset_load=1.0e-12 enable_delay=1.0e-9 reset_delay=1.0e-9 rise_delay=1.0e-9 fall_delay=1.0e-9 enable_load=1.0e-12 ) -.ac lin 0 0Hz 0Hz +.ac oct 897897 kjadsfhHz jhdsakjHz * Control Statements .control diff --git a/src/SubcircuitLibrary/lm555n/lm555n_Previous_Values.xml b/src/SubcircuitLibrary/lm555n/lm555n_Previous_Values.xml index 09c35028..58d33ec5 100644 --- a/src/SubcircuitLibrary/lm555n/lm555n_Previous_Values.xml +++ b/src/SubcircuitLibrary/lm555n/lm555n_Previous_Values.xml @@ -1 +1 @@ -<KicadtoNgspice><source /><model><u5 name="type">d_inverter<field1 name="Enter Fall Delay (default=1.0e-9)" /><field2 name="Enter Input Load (default=1.0e-12)" /><field3 name="Enter Rise Delay (default=1.0e-9)" /></u5><u6 name="type">d_srlatch<field4 name="Enter IC (default=0)" /><field5 name="Enter value for SR Load (default=1.0e-12)" /><field6 name="Enter Set Delay (default=1.0e-9)" /><field7 name="Enter value for Set Load (default=1.0e-12)" /><field8 name="Enter SR Delay (default=1.0e-9)" /><field9 name="Enter Enable Delay (default=1.0e-9)" /><field10 name="Enter Reset Delay (default=1.0)" /><field11 name="Enter Rise Delay (default=1.0e-9)" /><field12 name="Enter Fall Delay (default=1.0e-9)" /><field13 name="Enter value for Reset Load (default=1.0e-12)" /><field14 name="Enter value for Enable Load (default=1.0e-12)" /></u6></model><devicemodel><q1><field /></q1></devicemodel><analysis><ac><field1 name="Lin">true</field1><field2 name="Dec">false</field2><field3 name="Oct">false</field3><field4 name="Start Frequency" /><field5 name="Stop Frequency" /><field6 name="No. of points" /><field7 name="Start Fre Combo">Hz</field7><field8 name="Stop Fre Combo">Hz</field8></ac><dc><field1 name="Source Name" /><field2 name="Start" /><field3 name="Increment" /><field4 name="Stop" /><field5 name="Operating Point">False</field5><field6 name="Start Combo">Volts or Amperes</field6><field7 name="Increment Combo">Volts or Amperes</field7><field8 name="Stop Combo">Volts or Amperes</field8></dc><tran><field1 name="Start Time" /><field2 name="Step Time" /><field3 name="Stop Time" /><field4 name="Start Combo">Sec</field4><field5 name="Step Combo">Sec</field5><field6 name="Stop Combo">Sec</field6></tran></analysis></KicadtoNgspice>
\ No newline at end of file +<KicadtoNgspice><source /><model><u5 name="type">d_inverter<field1 name="Enter Fall Delay (default=1.0e-9)" /><field2 name="Enter Input Load (default=1.0e-12)" /><field3 name="Enter Rise Delay (default=1.0e-9)" /></u5><u6 name="type">d_srlatch<field4 name="Enter IC (default=0)" /><field5 name="Enter value for SR Load (default=1.0e-12)" /><field6 name="Enter Set Delay (default=1.0e-9)" /><field7 name="Enter value for Set Load (default=1.0e-12)" /><field8 name="Enter SR Delay (default=1.0e-9)" /><field9 name="Enter Enable Delay (default=1.0e-9)" /><field10 name="Enter Reset Delay (default=1.0)" /><field11 name="Enter Rise Delay (default=1.0e-9)" /><field12 name="Enter Fall Delay (default=1.0e-9)" /><field13 name="Enter value for Reset Load (default=1.0e-12)" /><field14 name="Enter value for Enable Load (default=1.0e-12)" /></u6></model><devicemodel><q1><field /></q1></devicemodel><analysis><ac><field1 name="Lin">false</field1><field2 name="Dec">false</field2><field3 name="Oct">true</field3><field4 name="Start Frequency">kjadsfh</field4><field5 name="Stop Frequency">jhdsakj</field5><field6 name="No. of points">897897</field6><field7 name="Start Fre Combo">Hz</field7><field8 name="Stop Fre Combo">Hz</field8></ac><dc><field1 name="Source Name" /><field2 name="Start" /><field3 name="Increment" /><field4 name="Stop" /><field5 name="Operating Point">False</field5><field6 name="Start Combo">Volts or Amperes</field6><field7 name="Increment Combo">Volts or Amperes</field7><field8 name="Stop Combo">Volts or Amperes</field8></dc><tran><field1 name="Start Time" /><field2 name="Step Time" /><field3 name="Stop Time" /><field4 name="Start Combo">Sec</field4><field5 name="Step Combo">Sec</field5><field6 name="Stop Combo">Sec</field6></tran></analysis></KicadtoNgspice>
\ No newline at end of file diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 4f5f4d4b..7ee98aa8 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -46,8 +46,8 @@ class Application(QtGui.QMainWindow): #Creating require Object self.obj_workspace = Workspace.Workspace() - self.obj_kicad = Kicad() self.obj_Mainview = MainView() + self.obj_kicad = Kicad(self.obj_Mainview.obj_dockarea) self.obj_appconfig = Appconfig() #Initialize all widget @@ -229,6 +229,13 @@ class Application(QtGui.QMainWindow): print "model editor is called" self.obj_appconfig.print_info('model editor is called') self.obj_Mainview.obj_dockarea.modelEditor() + """ + def open_kicadToNgspice(self): + print "kicadToNgspice is called" + self.obj_appconfig.print_info('kicadToNgspice is called') + self.obj_Mainview.obj_dockarea.kicadToNgspiceEditor()""" + + def testing(self): print "Success hit kicad button" diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index fcaf1f0f..f1452497 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -4,6 +4,7 @@ from ngspiceSimulation.NgspiceWidget import NgspiceWidget from configuration.Appconfig import Appconfig from modelEditor.ModelEditor import ModelEditorclass from subcircuit.Subcircuit import Subcircuit +from kicadtoNgspice.KicadtoNgspice import MainWindow import os dockList = ['Welcome'] @@ -57,6 +58,11 @@ class DockArea(QtGui.QMainWindow): dock['Tips-'+str(count)].setVisible(True) dock['Tips-'+str(count)].setFocus() + """ + dock['Tips-'+str(count)].setStyleSheet(" \ + :hover { background-color: yellow; } \ + ") + """ dock['Tips-'+str(count)].raise_() count = count + 1 @@ -157,6 +163,30 @@ class DockArea(QtGui.QMainWindow): dock['Model Editor-'+str(count)].raise_() count = count + 1 + + def kicadToNgspiceEditor(self,clarg1,clarg2=None): + global count + self.kicadToNgspiceWidget=QtGui.QWidget() + self.kicadToNgspiceLayout=QtGui.QVBoxLayout() + self.kicadToNgspiceLayout.addWidget(MainWindow(clarg1,clarg2)) + + self.kicadToNgspiceWidget.setLayout(self.kicadToNgspiceLayout) + dock['kicadToNgspice-'+str(count)] = QtGui.QDockWidget('kicadToNgspice-'+str(count)) + dock['kicadToNgspice-'+str(count)].setWidget(self.kicadToNgspiceWidget) + self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['kicadToNgspice-'+str(count)]) + self.tabifyDockWidget(dock['Welcome'],dock['kicadToNgspice-'+str(count)]) + + #CSS + dock['kicadToNgspice-'+str(count)].setStyleSheet(" \ + .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + ") + + dock['kicadToNgspice-'+str(count)].setVisible(True) + dock['kicadToNgspice-'+str(count)].setFocus() + dock['kicadToNgspice-'+str(count)].raise_() + + count = count + 1 + def subcircuiteditor(self): """ @@ -166,7 +196,7 @@ class DockArea(QtGui.QMainWindow): global count self.subcktWidget=QtGui.QWidget() self.subcktLayout=QtGui.QVBoxLayout() - self.subcktLayout.addWidget(Subcircuit()) + self.subcktLayout.addWidget(Subcircuit(self)) self.subcktWidget.setLayout(self.subcktLayout) dock['Subcircuit-'+str(count)] = QtGui.QDockWidget('Subcircuit-'+str(count)) diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py index 27dc740f..bdebf114 100644 --- a/src/kicadtoNgspice/Analysis.py +++ b/src/kicadtoNgspice/Analysis.py @@ -9,7 +9,8 @@ class Analysis(QtGui.QWidget): """ This class create Analysis Tab in KicadtoNgspice Window. """ - def __init__(self): + def __init__(self,clarg1): + self.clarg1=clarg1 QtGui.QWidget.__init__(self) self.track_obj= TrackWidget.TrackWidget() self.count =0 @@ -21,6 +22,7 @@ class Analysis(QtGui.QWidget): self.dc_parameter={} self.tran_parameter= {} self.createAnalysisWidget() + def createAnalysisWidget(self): @@ -86,7 +88,7 @@ class Analysis(QtGui.QWidget): self.track_obj.set_CheckBox["ITEMS"]="TRAN" def createACgroup(self): - kicadFile = sys.argv[1] + kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) print "PROJECT NAME---------",project_name @@ -226,7 +228,7 @@ class Analysis(QtGui.QWidget): pass def createDCgroup(self): - kicadFile = sys.argv[1] + kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) print "PROJECT NAME---------",project_name @@ -370,7 +372,7 @@ class Analysis(QtGui.QWidget): self.track_obj.op_check.append(0) def createTRANgroup(self): - kicadFile = sys.argv[1] + kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) print "PROJECT NAME---------",project_name diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 3b87e863..ae426470 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -10,12 +10,13 @@ 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): + def __init__(self,sourcelisttrack,source_entry_var,schematicInfo,clarg1): print "Start Conversion" self.sourcelisttrack = sourcelisttrack self.schematicInfo = schematicInfo self.entry_var = source_entry_var self.sourcelistvalue = [] + self.clarg1=clarg1 def addSourceParameter(self): @@ -135,7 +136,7 @@ class Convert: self.no=0 self.variable=self.set_checkbox - self.direct= sys.argv[1] + self.direct= self.clarg1 (filepath, filemname)= os.path.split(self.direct) self.Fileopen = os.path.join(filepath, "analysis") self.writefile= open(self.Fileopen,"w") @@ -387,6 +388,8 @@ class Convert: subList = self.obj_track.subcircuitTrack subLine = {} #Key:Index, Value:with its updated line in the form of list includeLine = [] #All .include line list + print "self.obj_track.subcircuitList--->",self.obj_track.subcircuitList + print "self.obj_track.subcircuitTrack--->",self.obj_track.subcircuitTrack if len(self.obj_track.subcircuitList) != len(self.obj_track.subcircuitTrack): self.msg = QtGui.QErrorMessage() self.msg.showMessage("Conversion failed. Please add all Subcircuits.") diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index 7dc740d2..ee8b7d25 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -12,9 +12,11 @@ class DeviceModel(QtGui.QWidget): It dynamically creates the widget for device like diode,mosfet,transistor and jfet. """ - def __init__(self,schematicInfo): + def __init__(self,schematicInfo,clarg1): - kicadFile = sys.argv[1] + + self.clarg1=clarg1 + kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) print "PROJECT NAME---------",project_name diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index c3e9d637..2452d215 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -38,8 +38,66 @@ class MainWindow(QtGui.QWidget): The convert function takes all the value entered by user and create a final netlist "*.cir.out". This final netlist is compatible with NgSpice. """ - def __init__(self): + def __init__(self,clarg1,clarg2=None): + + + QtGui.QWidget.__init__(self) + + print "==================================" + print "Kicad to Ngspice netlist converter " + print "==================================" + global kicadNetlist,schematicInfo + global infoline,optionInfo + self.kicadFile = clarg1 + self.clarg1=clarg1 + self.clarg2=clarg2 + #Object of Processing + obj_proc = PrcocessNetlist() + + # Read the netlist + kicadNetlist = obj_proc.readNetlist(self.kicadFile) + + # Construct parameter information + param = obj_proc.readParamInfo(kicadNetlist) + + # Replace parameter with values + netlist,infoline = obj_proc.preprocessNetlist(kicadNetlist,param) + + print "NETLIST ",netlist + print "INFOLINE",infoline + + # Separate option and schematic information + optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist) + + print "OPTIONINFO",optionInfo + print "SCHEMATICINFO",schematicInfo + + + #List for storing source and its value + global sourcelist, sourcelisttrack + sourcelist=[] + sourcelisttrack=[] + schematicInfo,sourcelist = obj_proc.insertSpecialSourceParam(schematicInfo,sourcelist) + + print "SOURCELIST",sourcelist + print "SCHEMATICINFO",schematicInfo + + #List storing model detail + global modelList,outputOption,unknownModelList,multipleModelList + + modelList = [] + outputOption = [] + schematicInfo,outputOption,modelList,unknownModelList,multipleModelList = obj_proc.convertICintoBasicBlocks(schematicInfo,outputOption,modelList) + print "Unknown Model List",unknownModelList + print "Multiple Model List",multipleModelList + print "Model List",modelList + """ + args=[clarg1,clarg2] + app = QtGui.QApplication(args) + kingWindow = MainWindow() + sys.exit(app.exec_()) + """ #Create object of track widget self.obj_track = TrackWidget.TrackWidget() """ @@ -69,48 +127,59 @@ class MainWindow(QtGui.QWidget): This function create main window of Kicad to Ngspice converter """ - self.grid = QtGui.QGridLayout(self) + self.vbox = QtGui.QVBoxLayout(self) + self.hbox=QtGui.QHBoxLayout(self) + self.hbox.addStretch(1) self.convertbtn = QtGui.QPushButton("Convert") self.convertbtn.clicked.connect(self.callConvert) - self.cancelbtn = QtGui.QPushButton("Cancel") - self.cancelbtn.clicked.connect(self.close) - self.grid.addWidget(self.createcreateConvertWidget(),0,0) - self.grid.addWidget(self.convertbtn,1,1) - self.grid.addWidget(self.cancelbtn,1,2) - self.setWindowState(QtCore.Qt.WindowMaximized) - self.setLayout(self.grid) + #self.cancelbtn = QtGui.QPushButton("Cancel") + #self.cancelbtn.clicked.connect(self.closeCancel) + self.hbox.addWidget(self.convertbtn) + self.vbox.addWidget(self.createcreateConvertWidget()) + self.vbox.addLayout(self.hbox) + + #self.grid.addWidget(self.cancelbtn,1,1) + + #self.setWindowState(QtCore.Qt.WindowMaximized) + self.setLayout(self.vbox) self.setWindowTitle("Kicad To NgSpice Converter") self.show() - + + """ + def closeCancel(self): + self.obj_track.modelTrack[:]=[] + self.obj_track.subcircuitList[:]=[] + self.close() + """ def createcreateConvertWidget(self): global obj_analysis self.convertWindow = QtGui.QWidget() self.analysisTab = QtGui.QScrollArea() - obj_analysis=Analysis.Analysis() + obj_analysis=Analysis.Analysis(self.clarg1) self.analysisTab.setWidget(obj_analysis) #self.analysisTabLayout = QtGui.QVBoxLayout(self.analysisTab.widget()) self.analysisTab.setWidgetResizable(True) global obj_source self.sourceTab = QtGui.QScrollArea() - obj_source=Source.Source(sourcelist,sourcelisttrack) + obj_source=Source.Source(sourcelist,sourcelisttrack,self.clarg1) self.sourceTab.setWidget(obj_source) #self.sourceTabLayout = QtGui.QVBoxLayout(self.sourceTab.widget()) self.sourceTab.setWidgetResizable(True) global obj_model self.modelTab = QtGui.QScrollArea() - obj_model=Model.Model(schematicInfo,modelList) + obj_model=Model.Model(schematicInfo,modelList,self.clarg1) self.modelTab.setWidget(obj_model) #self.modelTabLayout = QtGui.QVBoxLayout(self.modelTab.widget()) self.modelTab.setWidgetResizable(True) global obj_devicemodel self.deviceModelTab = QtGui.QScrollArea() - obj_devicemodel=DeviceModel.DeviceModel(schematicInfo) + obj_devicemodel=DeviceModel.DeviceModel(schematicInfo,self.clarg1) self.deviceModelTab.setWidget(obj_devicemodel) self.deviceModelTab.setWidgetResizable(True) global obj_subcircuitTab self.subcircuitTab = QtGui.QScrollArea() - obj_subcircuitTab = SubcircuitTab.SubcircuitTab(schematicInfo) + obj_subcircuitTab = SubcircuitTab.SubcircuitTab(schematicInfo,self.clarg1) self.subcircuitTab.setWidget(obj_subcircuitTab) self.subcircuitTab.setWidgetResizable(True) @@ -136,8 +205,8 @@ class MainWindow(QtGui.QWidget): """ global schematicInfo global analysisoutput - kicadFile = sys.argv[1] - (projpath,filename)=os.path.split(kicadFile) + global kicad + (projpath,filename)=os.path.split(self.kicadFile) project_name=os.path.basename(projpath) print "PROJ PATH---",projpath @@ -399,7 +468,7 @@ class MainWindow(QtGui.QWidget): self.obj_convert = Convert.Convert(self.obj_track.sourcelisttrack["ITEMS"], self.obj_track.source_entry_var["ITEMS"], - schematicInfo) + schematicInfo,self.clarg1) try: #Adding Source Value to Schematic Info @@ -409,10 +478,10 @@ class MainWindow(QtGui.QWidget): schematicInfo = self.obj_convert.addModelParameter(schematicInfo) #Adding Device Library to SchematicInfo - schematicInfo = self.obj_convert.addDeviceLibrary(schematicInfo,kicadFile) + schematicInfo = self.obj_convert.addDeviceLibrary(schematicInfo,self.kicadFile) #Adding Subcircuit Library to SchematicInfo - schematicInfo = self.obj_convert.addSubcircuit(schematicInfo, kicadFile) + schematicInfo = self.obj_convert.addSubcircuit(schematicInfo, self.kicadFile) analysisoutput = self.obj_convert.analysisInsertor(self.obj_track.AC_entry_var["ITEMS"], self.obj_track.DC_entry_var["ITEMS"], @@ -424,24 +493,25 @@ class MainWindow(QtGui.QWidget): self.obj_track.AC_type["ITEMS"], self.obj_track.op_check) #print "SchematicInfo after adding Model Details",schematicInfo - + #Calling netlist file generation function self.createNetlistFile(schematicInfo) self.msg = "The Kicad to Ngspice Conversion completed successfully!!!!!!" QtGui.QMessageBox.information(self, "Information", self.msg, QtGui.QMessageBox.Ok) - self.close() + #self.obj_track.subcircuitList[:]=[] + #self.obj_track.modelTrack[:]=[] + #self.close() except Exception as e: print "Exception Message: ",e print "There was error while converting kicad to ngspice" self.close() # Generate .sub file from .cir.out file if it is a subcircuit - subPath = os.path.splitext(kicadFile)[0] + subPath = os.path.splitext(self.kicadFile)[0] - if len(sys.argv)>2: - if sys.argv[2] == "sub": - self.createSubFile(subPath) + if self.clarg2 == "sub": + self.createSubFile(subPath) def createNetlistFile(self,schematicInfo): print "Creating Final netlist" @@ -453,7 +523,7 @@ class MainWindow(QtGui.QWidget): #print "KicadfIle",kicadFile #checking if analysis files is present - (projpath,filename) = os.path.split(kicadFile) + (projpath,filename) = os.path.split(self.kicadFile) analysisFileLoc = os.path.join(projpath,"analysis") #print "Analysis File Location",analysisFileLoc if os.path.exists(analysisFileLoc): @@ -512,7 +582,7 @@ class MainWindow(QtGui.QWidget): #Start creating final netlist cir.out file - outfile = kicadFile+".out" + outfile = self.kicadFile+".out" out=open(outfile,"w") out.writelines(infoline) out.writelines('\n') @@ -594,69 +664,7 @@ class MainWindow(QtGui.QWidget): out.writelines('.ends ' + self.projName) print "The subcircuit has been written in "+self.projName+".sub" - -#Main Function - -def main(args): - print "==================================" - print "Kicad to Ngspice netlist converter " - print "==================================" - global kicadFile,kicadNetlist,schematicInfo - global infoline,optionInfo - kicadFile = sys.argv[1] - - #Object of Processing - obj_proc = PrcocessNetlist() - - # Read the netlist - kicadNetlist = obj_proc.readNetlist(kicadFile) - - # Construct parameter information - param = obj_proc.readParamInfo(kicadNetlist) - - # Replace parameter with values - netlist,infoline = obj_proc.preprocessNetlist(kicadNetlist,param) - - print "NETLIST ",netlist - print "INFOLINE",infoline - - # Separate option and schematic information - optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist) - - print "OPTIONINFO",optionInfo - print "SCHEMATICINFO",schematicInfo - - - #List for storing source and its value - global sourcelist, sourcelisttrack - sourcelist=[] - sourcelisttrack=[] - schematicInfo,sourcelist = obj_proc.insertSpecialSourceParam(schematicInfo,sourcelist) - - print "SOURCELIST",sourcelist - print "SCHEMATICINFO",schematicInfo - - #List storing model detail - global modelList,outputOption,unknownModelList,multipleModelList - - modelList = [] - outputOption = [] - schematicInfo,outputOption,modelList,unknownModelList,multipleModelList = obj_proc.convertICintoBasicBlocks(schematicInfo,outputOption,modelList) - print "Unknown Model List",unknownModelList - print "Multiple Model List",multipleModelList - print "Model List",modelList - - - app = QtGui.QApplication(args) - kingWindow = MainWindow() - #kingWindow.show() #No need to call show as we are doing it in createMainWindow - sys.exit(app.exec_()) - - - -if __name__ == '__main__': - main(sys.argv) diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index d1edd5a6..c7ca7b47 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -13,12 +13,12 @@ class Model(QtGui.QWidget): The widgets are created dynamically in the Model Tab. """ - def __init__(self,schematicInfo,modelList): + def __init__(self,schematicInfo,modelList,clarg1): QtGui.QWidget.__init__(self) #Processing for getting previous values - kicadFile = sys.argv[1] + kicadFile = clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) #print "PROJECT NAME---------",project_name @@ -125,7 +125,14 @@ class Model(QtGui.QWidget): ''' #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]) + lst=[line[0],line[1],line[2],line[3],line[4],line[5],line[6],self.start,self.end,tag_dict] + check=0 + for itr in self.obj_trac.modelTrack: + if itr==lst: + check=1 + + if check==0: + self.obj_trac.modelTrack.append(lst) print "The tag dictionary : ",tag_dict diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py index e0d0fe19..4841ab07 100644 --- a/src/kicadtoNgspice/Source.py +++ b/src/kicadtoNgspice/Source.py @@ -12,11 +12,12 @@ class Source(QtGui.QWidget): This class create Source Tab of KicadtoNgSpice Window. """ - def __init__(self,sourcelist,sourcelisttrack): + def __init__(self,sourcelist,sourcelisttrack,clarg1): QtGui.QWidget.__init__(self) self.obj_track = TrackWidget.TrackWidget() #Variable self.count = 1 + self.clarg1=clarg1 self.start = 0 self.end = 0 self.row = 0 @@ -32,7 +33,7 @@ class Source(QtGui.QWidget): """ This function dynamically create source widget in the Source tab of KicadtoNgSpice window """ - kicadFile = sys.argv[1] + kicadFile = self.clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) print "PROJECT NAME---------",project_name diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py index bbac5592..fa51ac6a 100644 --- a/src/kicadtoNgspice/SubcircuitTab.py +++ b/src/kicadtoNgspice/SubcircuitTab.py @@ -14,9 +14,9 @@ class SubcircuitTab(QtGui.QWidget): It dynamically creates the widget for subcircuits. """ - def __init__(self,schematicInfo): + def __init__(self,schematicInfo,clarg1): - kicadFile = sys.argv[1] + kicadFile = clarg1 (projpath,filename)=os.path.split(kicadFile) project_name=os.path.basename(projpath) print "PROJECT NAME---------",project_name @@ -59,7 +59,7 @@ class SubcircuitTab(QtGui.QWidget): words = eachline.split() if eachline[0] == 'x': print "Words",words[0] - self.obj_trac.subcircuitList.append(words) + self.obj_trac.subcircuitList[project_name+words[0]]=words self.subcircuit_dict_beg[words[0]]=self.count subbox=QtGui.QGroupBox() subgrid=QtGui.QGridLayout() diff --git a/src/kicadtoNgspice/TrackWidget.py b/src/kicadtoNgspice/TrackWidget.py index e97b317d..56e84ce3 100644 --- a/src/kicadtoNgspice/TrackWidget.py +++ b/src/kicadtoNgspice/TrackWidget.py @@ -26,4 +26,4 @@ class TrackWidget: #Track Widget for Subcircuits where directory has been selected subcircuitTrack = {} #Track subcircuits which are specified in .cir file - subcircuitList = []
\ No newline at end of file + subcircuitList = {}
\ No newline at end of file diff --git a/src/ngspiceSimulation/pythonPlotting.py b/src/ngspiceSimulation/pythonPlotting.py index f746fae8..7d37623d 100644 --- a/src/ngspiceSimulation/pythonPlotting.py +++ b/src/ngspiceSimulation/pythonPlotting.py @@ -84,6 +84,7 @@ class plotWindow(QtGui.QMainWindow): self.top_grid.addWidget(self.listBranch,self.a[1]+2,0) for i in range(0,self.a[1]):#a[0]-1 self.chkbox.append(QtGui.QCheckBox(self.obj_dataext.NBList[i])) + self.chkbox[i].setStyleSheet('color') self.chkbox[i].setToolTip('<b>Check To Plot</b>' ) self.top_grid.addWidget(self.chkbox[i],i+2,0) self.colorLab = QtGui.QLabel() diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index fdaa3187..c2a0c948 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -26,10 +26,10 @@ class Kicad: """ This class called the Kicad Schematic,KicadtoNgspice Converter,Layout editor and Footprint Editor """ - def __init__(self): + def __init__(self,dockarea): self.obj_validation = Validation.Validation() self.obj_appconfig = Appconfig() - + self.obj_dockarea=dockarea def openSchematic(self): """ @@ -138,9 +138,14 @@ class Kicad: self.project = os.path.join(self.projDir,self.projName) #Creating a command to run + """ self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py " +self.project+".cir " self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() + """ + var=self.project+".cir" + self.obj_dockarea.kicadToNgspiceEditor(var) + else: diff --git a/src/subcircuit/Subcircuit.py b/src/subcircuit/Subcircuit.py index 94ca37e4..e161d6f3 100644 --- a/src/subcircuit/Subcircuit.py +++ b/src/subcircuit/Subcircuit.py @@ -14,7 +14,7 @@ class Subcircuit(QtGui.QWidget): QtGui.QWidget.__init__(self) self.obj_appconfig=Appconfig() self.obj_validation=Validation() - + self.obj_dockarea=parent self.layout = QtGui.QVBoxLayout() self.splitter= QtGui.QSplitter() self.splitter.setOrientation(QtCore.Qt.Vertical) @@ -58,5 +58,5 @@ class Subcircuit(QtGui.QWidget): self.obj_opensubcircuit.body() def convertsch(self): - self.obj_convertsubcircuit = convertSub() + self.obj_convertsubcircuit = convertSub(self.obj_dockarea) self.obj_convertsubcircuit.createSub()
\ No newline at end of file diff --git a/src/subcircuit/convertSub.py b/src/subcircuit/convertSub.py index bb045e3b..6744b35d 100644 --- a/src/subcircuit/convertSub.py +++ b/src/subcircuit/convertSub.py @@ -9,10 +9,11 @@ class convertSub(QtGui.QWidget): This class is called when User create new Project. """ - def __init__(self): + def __init__(self,dockarea): super(convertSub, self).__init__() self.obj_validation = Validation() self.obj_appconfig=Appconfig() + self.obj_dockarea=dockarea def createSub(self): """ @@ -30,8 +31,12 @@ class convertSub(QtGui.QWidget): self.project = os.path.join(self.projDir,self.projName) #Creating a command to run - self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py "+self.project+".cir "+"sub" - os.system(self.cmd) + #self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py "+self.project+".cir "+"sub" + #os.system(self.cmd) + + var1=self.project+".cir" + var2="sub" + self.obj_dockarea.kicadToNgspiceEditor(var1,var2) # self.obj_workThread = Worker.WorkerThread(self.cmd) # self.obj_workThread.start() else: |