diff options
Diffstat (limited to 'src/kicadtoNgspice/KicadtoNgspice.py')
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index dfc7cff8..833bd6cc 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -33,11 +33,13 @@ import json class MainWindow(QtGui.QWidget): """ - This class create KicadtoNgspice window. - 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 class create KicadtoNgspice window. + - 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. + - clarg1 is the path to the .cir file + - clarg2 is either None or "sub" depending on the analysis type """ def __init__(self, clarg1, clarg2=None): @@ -52,6 +54,7 @@ class MainWindow(QtGui.QWidget): self.clarg2 = clarg2 # Create object of track widget + # Track the dynamically created widget of KicadtoNgSpice Window self.obj_track = TrackWidget.TrackWidget() # Clear Dictionary/List item of sub circuit and ngspice model @@ -65,9 +68,9 @@ class MainWindow(QtGui.QWidget): # Object of Processing obj_proc = PrcocessNetlist() - # Read the netlist + # Read the netlist, ie the .cir file kicadNetlist = obj_proc.readNetlist(self.kicadFile) - + print("=============================================================") print("Given Kicad Schematic Netlist Info :", kicadNetlist) # Construct parameter information @@ -75,13 +78,13 @@ class MainWindow(QtGui.QWidget): # Replace parameter with values netlist, infoline = obj_proc.preprocessNetlist(kicadNetlist, param) - + print("=============================================================") print("Schematic Info after processing Kicad Netlist: ", netlist) # print "INFOLINE",infoline # Separate option and schematic information optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist) - + print("=============================================================") print("OPTIONINFO in the Netlist", optionInfo) # List for storing source and its value @@ -92,15 +95,23 @@ class MainWindow(QtGui.QWidget): schematicInfo, sourcelist) # List storing model detail - global modelList, outputOption, unknownModelList, multipleModelList, plotText + global modelList, outputOption,\ + unknownModelList, multipleModelList, plotText modelList = [] outputOption = [] plotText = [] - schematicInfo, outputOption, modelList, unknownModelList, multipleModelList, plotText = obj_proc.convertICintoBasicBlocks( - schematicInfo, outputOption, modelList, plotText - ) - + ( + schematicInfo, + outputOption, + modelList, + unknownModelList, + multipleModelList, + plotText + ) = obj_proc.convertICintoBasicBlocks( + schematicInfo, outputOption, modelList, plotText + ) + print("=======================================") print("Model available in the Schematic :", modelList) """ @@ -128,11 +139,11 @@ class MainWindow(QtGui.QWidget): else: self.createMainWindow() - def createMainWindow(self): - """ - This function create main window of Kicad to Ngspice converter - """ + """ + This function create main window of Kicad to Ngspice converter + """ + def createMainWindow(self): self.vbox = QtGui.QVBoxLayout(self) self.hbox = QtGui.QHBoxLayout(self) self.hbox.addStretch(1) @@ -450,7 +461,11 @@ class MainWindow(QtGui.QWidget): json_data["model"][line[3]]["values"] = [] for key, value in line[7].items(): - if hasattr(value, '__iter__') and i <= end: + if( + hasattr(value, '__iter__') and + i <= end and type(value) is not + str + ): for item in value: fields = { item: str( @@ -503,21 +518,24 @@ class MainWindow(QtGui.QWidget): self.obj_track.sourcelisttrack["ITEMS"], self.obj_track.source_entry_var["ITEMS"], store_schematicInfo, self.clarg1 - ) + ) try: # Adding Source Value to Schematic Info store_schematicInfo = self.obj_convert.addSourceParameter() + print("=========================================================") print("Netlist After Adding Source details :", store_schematicInfo) # Adding Model Value to store_schematicInfo store_schematicInfo = self.obj_convert.addModelParameter( store_schematicInfo) + print("=========================================================") print("Netlist After Adding Ngspice Model :", store_schematicInfo) # Adding Device Library to SchematicInfo store_schematicInfo = self.obj_convert.addDeviceLibrary( store_schematicInfo, self.kicadFile) + print("=========================================================") print( "Netlist After Adding Device Model Library :", store_schematicInfo) @@ -525,6 +543,7 @@ class MainWindow(QtGui.QWidget): # Adding Subcircuit Library to SchematicInfo store_schematicInfo = self.obj_convert.addSubcircuit( store_schematicInfo, self.kicadFile) + print("=========================================================") print("Netlist After Adding subcircuits :", store_schematicInfo) analysisoutput = self.obj_convert.analysisInsertor( @@ -538,7 +557,7 @@ class MainWindow(QtGui.QWidget): self.obj_track.AC_type["ITEMS"], self.obj_track.op_check ) - + print("=========================================================") print("Analysis OutPut ", analysisoutput) # Calling netlist file generation function @@ -561,6 +580,7 @@ class MainWindow(QtGui.QWidget): self.createSubFile(subPath) def createNetlistFile(self, store_schematicInfo, plotText): + print("=============================================================") print("Creating Final netlist") # print "INFOLINE",infoline # print "OPTIONINFO",optionInfo @@ -588,6 +608,7 @@ class MainWindow(QtGui.QWidget): Please check it") sys.exit() else: + print("========================================================") print(analysisFileLoc + " does not exist") sys.exit() @@ -673,6 +694,7 @@ class MainWindow(QtGui.QWidget): except BaseException: print("Error in opening .cir.out file.") else: + print("=========================================================") print( self.projName + ".cir.out does not exist. Please create a spice netlist.") @@ -732,4 +754,5 @@ class MainWindow(QtGui.QWidget): out.writelines('\n') out.writelines('.ends ' + self.projName) + print("=============================================================") print("The subcircuit has been written in " + self.projName + ".sub") |