From a0f738ba15264b69d9d51755569408bdd8e383b5 Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Fri, 7 Jun 2019 18:54:35 +0530 Subject: pep8 fixes and list models bug fixed --- src/kicadtoNgspice/Processing.py | 84 ++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 12 deletions(-) (limited to 'src/kicadtoNgspice/Processing.py') diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index 63847761..bd1b45dc 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -13,15 +13,29 @@ class PrcocessNetlist: def __init__(self): pass + """ + - Read the circuit file and return splitted lines + """ + def readNetlist(self, filename): f = open(filename) data = f.read() f.close() + 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): - """Read Parameter information and store it into dictionary""" param = {} + print("=========================KICADNETLIST========================") for eachline in kicadNetlis: print(eachline) eachline = eachline.strip() @@ -32,10 +46,18 @@ 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("=============================================================") return param + """ + - Preprocess netlist (replace parameters) + """ + def preprocessNetlist(self, kicadNetlis, param): - """Preprocess netlist (replace parameters)""" netlist = [] for eachline in kicadNetlis: # Remove leading and trailing blanks spaces from line @@ -66,6 +88,12 @@ class PrcocessNetlist: # Copy information line infoline = netlist[0] netlist.remove(netlist[0]) + print("=============================================================") + print("preprocessNetList called, from Processing") + print("=============================================================") + print("NETLIST", netlist) + print("INFOLINE", infoline) + print("=============================================================") return netlist, infoline def separateNetlistInfo(self, netlist): @@ -78,14 +106,24 @@ class PrcocessNetlist: optionInfo.append(eachline) else: schematicInfo.append(eachline) + print("=============================================================") + print("separateNetlistInfo called, from Processing") + print("=============================================================") + print("OPTIONINFO", optionInfo) + print("SCHEMATICINFO", schematicInfo) + print("=============================================================") return optionInfo, schematicInfo + """ + - Insert Special source parameter + - As per the parameters passed create source list + """ + def insertSpecialSourceParam(self, schematicInfo, sourcelist): - # Inser Special source parameter schematicInfo1 = [] - + print("=============================================================") print("Reading schematic info for source details") - + print("=============================================================") for compline in schematicInfo: words = compline.split() compName = words[0] @@ -171,10 +209,17 @@ class PrcocessNetlist: schematicInfo = schematicInfo + schematicInfo1 print("Source List : ", sourcelist) # print schematicInfo + print("=============================================================") + print("insertSpecialSourceParam called, from Processing") + print("=============================================================") + print("SCHEMATICINFO", schematicInfo) + print("SOURCELIST", sourcelist) + print("=============================================================") return schematicInfo, sourcelist def convertICintoBasicBlocks( self, schematicInfo, outputOption, modelList, plotText): + print("=============================================================") print("Reading Schematic info for Model") # Insert details of Ngspice model unknownModelList = [] @@ -228,6 +273,8 @@ class PrcocessNetlist: unknownModelList.append(compType) elif count == 1: try: + print("==========================================\ + ===========================") print( "Start Parsing Previous Values XML\ for ngspice model :", modelPath) @@ -265,7 +312,7 @@ class PrcocessNetlist: if 'default' in item.attrib: paramDict[item.tag + ":" + item.attrib['default']] \ - = temp_list + = temp_list else: paramDict[item.tag] = item.text @@ -273,7 +320,7 @@ class PrcocessNetlist: if 'default' in item.attrib: paramDict[item.tag + ":" + item.attrib['default']]\ - = item.text + = item.text else: paramDict[item.tag] = item.text @@ -288,6 +335,8 @@ class PrcocessNetlist: modelLine += compName else: + print("=====================================\ + ================================") print("Split Details :", splitDetail) modelLine = "a" + str(k) + " " vectorDetail = splitDetail.split(':') @@ -302,7 +351,7 @@ class PrcocessNetlist: for i in range(0, int( item.split("-")[0])): modelLine += words[pos] +\ - " " + " " pos += 1 modelLine += ") " else: @@ -310,7 +359,7 @@ class PrcocessNetlist: for i in range(0, int( item.split("-")[0])): modelLine += words[pos] + \ - " " + " " pos += 1 modelLine += "] " elif item.split("-")[1] == 'NV': @@ -436,16 +485,27 @@ class PrcocessNetlist: else: schematicInfo.insert(index, "* " + compline) - + print("=====================================================") print( "UnknownModelList Used in the Schematic", unknownModelList) + print("=====================================================") print( "Multiple Model XML file with same name ", multipleModelList) + print("=====================================================") print("Model List Details : ", modelList) - + print("=============================================================") + print("convertICIntoBasicBlocks called, from Processing") + print("=============================================================") + print("SCHEMATICINFO", schematicInfo) + print("OUTPUTOPTION", outputOption) + print("MODELLIST", modelList) + print("UNKOWNMODELLIST", unknownModelList) + print("MULTIPLEMODELLIST", multipleModelList) + print("PLOTTEST", plotText) + print("=============================================================") return ( schematicInfo, outputOption, modelList, unknownModelList, multipleModelList, plotText - ) + ) -- cgit From fd8107b2f5662851dd5d3a7388e46d6be1eb5125 Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Fri, 7 Jun 2019 19:01:08 +0530 Subject: kicadtoNgspice documentation added --- src/kicadtoNgspice/Processing.py | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'src/kicadtoNgspice/Processing.py') diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index bd1b45dc..ebbd3429 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -5,8 +5,8 @@ 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. + - This class include all the function required for pre-proccessing of + netlist before converting to Ngspice Netlist. """ modelxmlDIR = '../modelParamXML' @@ -16,7 +16,6 @@ class PrcocessNetlist: """ - Read the circuit file and return splitted lines """ - def readNetlist(self, filename): f = open(filename) data = f.read() @@ -32,7 +31,6 @@ class PrcocessNetlist: - Read Parameter information and store it into dictionary - kicadNetlis is the .cir file content """ - def readParamInfo(self, kicadNetlis): param = {} print("=========================KICADNETLIST========================") @@ -55,8 +53,8 @@ class PrcocessNetlist: """ - Preprocess netlist (replace parameters) + - Separate infoline (first line) from the rest of netlist """ - def preprocessNetlist(self, kicadNetlis, param): netlist = [] for eachline in kicadNetlis: @@ -97,6 +95,13 @@ class PrcocessNetlist: return netlist, infoline def separateNetlistInfo(self, netlist): + """ + - Remove the options such as .end, .param, starting wtih "." + from the netlist file + - This is stored as option info, whereas rest is stored as + schematicInfo + - Rest from the `* Sheet Name:` line stored as schematicInfo + """ optionInfo = [] schematicInfo = [] for eachline in netlist: @@ -116,9 +121,10 @@ class PrcocessNetlist: """ - Insert Special source parameter - - As per the parameters passed create source list + - 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): schematicInfo1 = [] print("=============================================================") @@ -219,6 +225,16 @@ class PrcocessNetlist: def convertICintoBasicBlocks( self, schematicInfo, outputOption, modelList, plotText): + """ + - Parses the schematicInfo and returns + - - SchematicInfo + - - Output Option + - - Model List + - - Unkown Model List + - - Multiple Model List + - - Plot text + - Parsing info is provided below + """ print("=============================================================") print("Reading Schematic info for Model") # Insert details of Ngspice model @@ -425,8 +441,8 @@ class PrcocessNetlist: words = compline.split() # Adding zero voltage source to netlist schematicInfo.append( - "v_" + words[0] + " " - + words[1] + " " + words[2] + " " + "0") + "v_" + words[0] + " " + + words[1] + " " + words[2] + " " + "0") plotText.append("plot i(v_" + words[0] + ")") elif compType == 'plot_log': words = compline.split() @@ -442,9 +458,11 @@ class PrcocessNetlist: schematicInfo.insert(index, "* " + compline) # For Primary Couple - modelLine = "a" + str(k) - + " (" + words[1] + " " + words[2] + ") (interNode_" + str( - interMediateNodeCount) + " " + words[3] + ") " + modelLine = ( + "a" + str(k) + " (" + words[1] + " " + + words[2] + ") (interNode_" + + str(interMediateNodeCount) + " " + words[3] + ") " + ) modelLine += compName + "_primary" schematicInfo.append(modelLine) k = k + 1 -- cgit