diff options
author | fahim | 2015-03-25 16:01:00 +0530 |
---|---|---|
committer | fahim | 2015-03-25 16:01:00 +0530 |
commit | 38156ae2ab71a0b26870c8a4a2c0745427a032ff (patch) | |
tree | 79103ed9b5a6ed4e25aac421c3b0b21967ae97e4 /src/kicadtoNgspice/Convert.py | |
parent | 0e14e5c36023a4a12cfe7429b0be01dc534151b4 (diff) | |
download | eSim-38156ae2ab71a0b26870c8a4a2c0745427a032ff.tar.gz eSim-38156ae2ab71a0b26870c8a4a2c0745427a032ff.tar.bz2 eSim-38156ae2ab71a0b26870c8a4a2c0745427a032ff.zip |
Subject: Added module for source tab
Description: Addition of source tab is completed. Able to update source
detail of schematic info.
Diffstat (limited to 'src/kicadtoNgspice/Convert.py')
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py new file mode 100644 index 00000000..92bc2945 --- /dev/null +++ b/src/kicadtoNgspice/Convert.py @@ -0,0 +1,106 @@ + + +class Convert: + def __init__(self,sourcelisttrack,entry_var,schematicInfo): + print "Start Conversion" + self.sourcelisttrack = sourcelisttrack + self.schematicInfo = schematicInfo + self.entry_var = entry_var + self.sourcelistvalue = [] + + def addSourceParameter(self): + print "Adding Source parameter" + print "SourceListTrack : ",self.sourcelisttrack + print "Schematic Info ",self.schematicInfo + print "Entry Var",self.entry_var + self.start = 0 + self.end = 0 + + for compline in self.sourcelisttrack: + self.index = compline[0] + self.addline = self.schematicInfo[self.index] + if compline[1] == 'sine': + try: + self.start = compline[2] + self.end = compline[3] + vo_val = str(self.entry_var[self.start].text()) if len(str(self.entry_var[self.start].text())) > 0 else '0' + va_val = str(self.entry_var[self.start+1].text()) if len(str(self.entry_var[self.start+1].text())) > 0 else '0' + freq_val = str(self.entry_var[self.start+2].text()) if len(str(self.entry_var[self.start+2].text())) > 0 else '0' + td_val = str(self.entry_var[self.start+3].text()) if len(str(self.entry_var[self.start+3].text())) > 0 else '0' + theta_val = str(self.entry_var[self.end].text()) if len(str(self.entry_var[self.end].text())) > 0 else '0' + self.addline = self.addline.partition('(')[0] + "("+vo_val+" "+va_val+" "+freq_val+" "+td_val+" "+theta_val+")" + self.sourcelistvalue.append([self.index,self.addline]) + except: + print "Caught an exception in sine voltage source ",self.addline + + elif compline[1] == 'pulse': + try: + self.start = compline[2] + self.end = compline[3] + v1_val = str(self.entry_var[self.start].text()) if len(str(self.entry_var[self.start].text())) > 0 else '0' + v2_val = str(self.entry_var[self.start+1].text()) if len(str(self.entry_var[self.start+1].text())) > 0 else '0' + td_val = str(self.entry_var[self.start+2].text()) if len(str(self.entry_var[self.start+2].text())) > 0 else '0' + tr_val = str(self.entry_var[self.start+3].text()) if len(str(self.entry_var[self.start+3].text())) > 0 else '0' + tf_val = str(self.entry_var[self.start+4].text()) if len(str(self.entry_var[self.start+4].text())) > 0 else '0' + pw_val = str(self.entry_var[self.start+5].text()) if len(str(self.entry_var[self.start+5].text())) > 0 else '0' + tp_val = str(self.entry_var[self.end].text()) if len(str(self.entry_var[self.end].text())) > 0 else '0' + + self.addline = self.addline.partition('(')[0] + "("+v1_val+" "+v2_val+" "+td_val+" "+tr_val+" "+tf_val+" "+pw_val+" "+tp_val+")" + self.sourcelistvalue.append([self.index,self.addline]) + except: + print "Caught an exception in pulse voltage source ",self.addline + + elif compline[1] == 'pwl': + try: + self.start = compline[2] + self.end = compline[3] + t_v_val = str(self.entry_var[self.start].text()) if len(str(self.entry_var[self.start].text())) > 0 else '0 0' + self.addline = self.addline.partition('(')[0] + "("+t_v_val+")" + self.sourcelistvalue.append([self.index,self.addline]) + except: + print "Caught an exception in pwl voltage source ",self.addline + + elif compline[1] == 'ac': + try: + self.start = compline[2] + self.end = compline[3] + va_val=str(self.entry_var[self.start].text()) if len(str(self.entry_var[self.start].text())) > 0 else '0' + self.addline = ' '.join(self.addline.split()) + self.addline = self.addline.partition('ac')[0] +" "+'ac'+" "+ va_val + self.sourcelistvalue.append([self.index,self.addline]) + except: + print "Caught an exception in ac voltage source ",self.addline + + elif compline[1] == 'dc': + try: + self.start = compline[2] + self.end = compline[3] + v1_val = str(self.entry_var[self.start].text()) if len(str(self.entry_var[self.start].text())) > 0 else '0' + self.addline = ' '.join(self.addline.split()) + self.addline = self.addline.partition('dc')[0] + " " +'dc'+ " "+v1_val + self.sourcelistvalue.append([self.index,self.addline]) + except: + print "Caught an exception in dc voltage source",self.addline + + elif compline[1] == 'exp': + try: + self.start = compline[2] + self.end = compline[3] + v1_val = str(self.entry_var[self.start].text()) if len(str(self.entry_var[self.start].text())) > 0 else '0' + v2_val = str(self.entry_var[self.start+1].text()) if len(str(self.entry_var[self.start+1].text())) > 0 else '0' + td1_val = str(self.entry_var[self.start+2].text()) if len(str(self.entry_var[self.start+2].text())) > 0 else '0' + tau1_val = str(self.entry_var[self.start+3].text()) if len(str(self.entry_var[self.start+3].text())) > 0 else '0' + td2_val = str(self.entry_var[self.start+4].text()) if len(str(self.entry_var[self.start+4].text())) > 0 else '0' + tau2_val = str(self.entry_var[self.end].text()) if len(str(self.entry_var[self.end].text())) > 0 else '0' + + self.addline = self.addline.partition('(')[0] + "("+v1_val+" "+v2_val+" "+td1_val+" "+tau1_val+" "+td2_val+" "+tau2_val+")" + self.sourcelistvalue.append([self.index,self.addline]) + except: + print "Caught an exception in exp voltage source ",self.addline + + #Updating Schematic with source value + for item in self.sourcelistvalue: + del self.schematicInfo[item[0]] + self.schematicInfo.insert(item[0],item[1]) + + return self.schematicInfo
\ No newline at end of file |