summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGloria12102020-06-13 01:59:32 +0530
committerGloria12102020-06-13 01:59:32 +0530
commita68c4384af21b56144493cfcb2945cc53bcd9ef7 (patch)
tree48d1270162aca1ce5888be277747eefc2f160583
parent8129fc49dbdccd3da25c0c114a798b73295e3766 (diff)
downloadeSim_PSpice_to_KiCad_Python_Parser-a68c4384af21b56144493cfcb2945cc53bcd9ef7.tar.gz
eSim_PSpice_to_KiCad_Python_Parser-a68c4384af21b56144493cfcb2945cc53bcd9ef7.tar.bz2
eSim_PSpice_to_KiCad_Python_Parser-a68c4384af21b56144493cfcb2945cc53bcd9ef7.zip
cleared lib files
-rwxr-xr-xattribute.py69
-rwxr-xr-xcomponent.py169
-rwxr-xr-xcomponent_instance.py216
-rwxr-xr-xdesign.py354
-rwxr-xr-xheader.py13
-rwxr-xr-xinclude.py0
-rwxr-xr-xlibParser.py80
-rwxr-xr-xmisc.py232
-rwxr-xr-xparser.py192
-rwxr-xr-xwire.py66
10 files changed, 0 insertions, 1391 deletions
diff --git a/attribute.py b/attribute.py
deleted file mode 100755
index e584a2e..0000000
--- a/attribute.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-
-from header import * #Importing header file from PythonLib folder
-class Attribute: #defining class Attribute
- x = 0 #declaring and initialising coordinates
- y = 0
- orient = '' #declaring and initialising orientation
- hjust = '' #declaring and initialising hjust
- vjust = '' #declaring and initialising vjust
- isHidden = False #declaring and initialising isHidden
- name ='' #declaring and initialising component name
- value = '' #declaring and initialising value
- '''Sample attribute line in a Pspice library:
- a 0 s 11 0 10 34 hln 100 PART=EPOLY
- a: implies that this line describes an attribute
- s: something to do with "isHidden"
- 10, 34: "x", "y" wrt the origin of the Component of which this is an attribute.
- hln: "orient"(h), "hjust"(l), "vjust"(n)
- 100: text size in % in Pspice. Ignore.
- PART: "name" of the attribute.
- EPOLY: "value" of the attribute. '''
- def __init__(self,line = ''): #defining the _init_ Constructor
- a = '' #declaring and initialising a
- vis = '' #declaring and initialising vis
- temp = '' #declaring and initialising temp
- t = 0 #declaring and initialising t
- x0 = 0 #declaring and initialising x0
- y0 = 0 #declaring and initialising y0
- if len(line) != 0:
- input_line = line.strip().split() #making a copy of line and spliting it
- #print(input_line)
- a,t,temp,vis,x0,y0,temp = input_line[:7] #copying input_line
- self.orient,self.hjust,self.vjust = list(input_line[7])
- t= input_line[8] #setting sizes to 8
- temp = ' '.join(map(str,input_line[9:])) #mapping and then joining in temp
- temp = temp.split()[0] #spliting the temp
- x0 = int(x0) #taking the x coordinate in integer format
- y0 = int(y0) #taking the y coordinate in integer format
-
- self.x = x0 * MULT #as size of pspice components is small therefore
- #increasing the size 10 times
- self.y = y0 * MULT #MULT=10 from header file
-
- t = temp.find('=') #everything in temp occuring before the '=' is the "name",
- #and everything after it is the "value".
- self.name = temp[0:t] #storing the name
- self.value = temp[t+1:] #storing the value
- if vis.find('13') == -1: #if '13' is not found returns -1
- self.isHidden = True #if yes, storing the isHidden as True
-
- else:
- self.isHidden = False #otherwise storing the isHidden as False
-
- #print('attribute name->',self.name,'attribute value->', self.value)
-
- def print(self, output_stream): #defining the print function
- #print('Type in attr->',self.value)
- output_stream.write(' "'+self.value+'" '+self.orient.upper()+' '+str(self.x)+' ' +str(self.y)+' 30 000'+str(int(self.isHidden))+' '+self.hjust.upper()+' ') #write the values to the output_stream
- if self.vjust == 'n': #checking vjust is 'n' (representing hln in pspice schematic)
- output_stream.write('C') #if yes, writing 'C' to the output_stream(EESchema Schematic)
- else:
- output_stream.write(self.vjust.upper()) #if not, writing vjust.upper to the output_stream
- output_stream.write('NN\n') #writing 'NN\n'
diff --git a/component.py b/component.py
deleted file mode 100755
index 8654f83..0000000
--- a/component.py
+++ /dev/null
@@ -1,169 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-from header import *
-from attribute import *
-from design import *
-from misc import *
-
-class Pin:
- #position of pin and length of the pin.Pin constructor reading values from corresponding component's pspice library
- x = 0
- y = 0
- length = 0
- #pin_number is the pin number and elec_type is the electrical type
- n = ''
- elec_type = ''
- #to store the orientation of pin
- orientation = ''
- found = 0
- tmp = 0
- x1 = 0
- x2 = 0
- y1 = 0
- y2 = 0
-
- def __init__(self, input_stream = None):
- line = ''
- temp =''
- inline = input_stream.readline().split()
- #print(inline)
- t,self.tmp,self.x1,self.y1,temp,temp,self.n,temp,self.x2,self.y2,self.orientation = inline
- self.x = int(self.x2)*MULT #x co-ordinate of the pin
- self.y = int(self.y2)*(-1)*MULT #y co-ordinate of the pin
- self.length = 10*MULT #calculating pin length from points of pins
- #line = input_stream.readline()
- g = input_stream.tell()
- line = input_stream.readline()
- while(line[0] == 'a'): #Read the attributes of the pins. lines starting from 'a' stores the attributes
- attr = Attribute(line) #called the attribute constructor to store the attributes
- if attr.name == 'ERC' or attr.name == 'erc': #if the attribute name is 'ERC' or 'erc' its value is the electrical type of the pin
- self.elec_type = attr.value
- g = input_stream.tell()
- line = input_stream.readline()
- input_stream.seek(g)
-
- def print(self, output_stream, shiftx, shifty): #converting the annotation to KiCad format as different letters are use in PSpice and KiCad libraries
- output_stream.write("X"+" "+"~ "+str(self.n)+" "+str(self.x-shiftx)+" "+str(self.y-((-1)*shifty))+" "+str(self.length)+" ")
- if self.orientation == 'h':
- output_stream.write('R') # If Pspice orientation is h, then map it to Right direction
- elif self.orientation == 'u':
- output_stream.write('L') #If Pspice orientation is u, then map it to Left direction
- elif self.orientation == 'v':
- output_stream.write('U') #If Pspice orientation is v, then map it to Up direction
- elif self.orientation == 'd':
- output_stream.write('D') #If Pspice orientation is d, then map it to Down direction
-
- output_stream.write(' 30 30 0 1 ') # Mapping electrical tupe of PSpice component to KiCad component
-
- if self.elec_type == 'i':
- output_stream.write('I\n') #If Pspice electrical type is i, then map it to Input
- elif self.elec_type == 'o':
- output_stream.write('O\n') #If Pspice electrical type is o, then map it to Output
- elif self.elec_type == 'p':
- output_stream.write('W\n') #If Pspice electrical type is p, then map it to Tristate
- elif self.elec_type == 'x':
- output_stream.write('P\n') #If Pspice electrical type is x, then map it to Passive
- elif self.elec_type == 'b':
- output_stream.write('B\n') #If Pspice electrical type is b, then map it to Bidirectional
- else:
- output_stream.write('P\n') #else map it to Passive
-
-
-
-class Component: #Component class method makePins to design pins
- #default Component class constructor
- type_ = ''
- ref = ''
- value = ''
- pins = []
- des = None
- def __init__(self, input_stream = None, t = ''):
- self.pins = []
- self.type_ = t
- if(input_stream != None):
- g = input_stream.tell() #To get to the starting point of the component's type in pspice library file
- line = ''
- '''while(('*symbol '+t) not in line):
- input_stream.seek(g)
- line = input_stream.readline().strip()
- g = input_stream.tell()
- '''
- line = skipTo(input_stream, ('*symbol '+t))
- #print('Component Line->', line)
- ''' input_stream.seek(g)
- g = input_stream.tell()
- print('Search t',line[line.rfind(' ')+1:])
- '''
- while(line != '' and line.find('ako')!= -1):
- #print('in finding ako')
- a = line.rfind(' ')+1
- t = line[a:]
- input_stream.seek(g)
- '''while(('*symbol '+t) not in line):
- line = input_stream.readline().strip()
- print('Searching ako ref',line)'''
- line = skipTo(input_stream, ('*symbol '+t)) #To get the pspice library of the components having its description written elsewhere
- #print('In component constructor')
- line = input_stream.readline().strip()
- '''while('@attributes' not in line):
- line = input_stream.readline().strip()'''
- skipTo(input_stream, '@attributes') #creating attributes by calling its constructor
- g = input_stream.tell()
- line = input_stream.readline().strip() #assigning attributes of PKGREF to the component
- while(line[0] == 'a'):
- attr = Attribute(line)
- if attr.name == 'REFDES' or attr.name == 'refdes':
- self.ref = attr.value[:-1]
- if attr.name == 'VALUE' or attr.name == 'DC' or attr.name == 'GAIN' or attr.name == 'COEFF' or attr.name == 'VPOS' or attr.name == 'VNEG':
- self.value = attr.value #assigning attributes of above cases to the component
- g = input_stream.tell()
- line = input_stream.readline().strip()
- input_stream.seek(g)
- '''
- line = input_stream.readline().strip()
-
- while('@pins' not in line):
- line = input_stream.readline().strip()
- '''
- skipTo(input_stream, '@pins') #to get to the starting point of the pins of the type required
- self.makePins(input_stream) #calling makepins function to create pins
-
- g = input_stream.tell()
- line = input_stream.readline().strip()
- while('@graphics' not in line):
- input_stream.seek(g)
- #print('***',line)
- g = input_stream.tell()
- line = input_stream.readline().strip()
- input_stream.seek(g)
- d = Design(input_stream) #calling Design constructor to create design
- self.des = d
- #print('Before fixComp',self.type_, 'ref=', self.ref)
-
- def makePins(self,input_stream):
- #print('making pins')
- line = ''
- g = input_stream.tell()
- line = input_stream.readline().strip()
- while(line[0] == 'p'): #Read the pins line from pspice library
- input_stream.seek(g)
- p = Pin(input_stream) #call the Pin constructor to get the values and pass the library as the parameter
- self.pins.append(p)
- g = input_stream.tell() #move to the next line to get next 'p' line
- line = input_stream.readline().strip()
- input_stream.seek(g)
-
- def print(self, output_stream): #print function of class Pin to print the pins in output's cache lib file
- output_stream.write('#\n# '+self.type_+'\n#\nDEF '+self.type_+' '+self.ref+' 0 30 Y Y 1 F N'+'\n')#upto DEF line printed
- output_stream.write('F0 \"'+self.ref+"\" 0 0 30 H V L CNN"+'\n') #F0 line
- output_stream.write('F1 \"'+self.type_+'\" 0 60 30 H V L CNN'+'\n') #F1 line
- output_stream.write('DRAW\n') #calling print funcition of design to print design of components
- self.des.print(output_stream)
- for i in range(len(self.pins)):
- self.pins[i].print(output_stream, self.des.shiftx, self.des.shifty) #calling print function of pins class to print pins
- output_stream.write('ENDDRAW\n'+'ENDDEF\n')
diff --git a/component_instance.py b/component_instance.py
deleted file mode 100755
index 661cd04..0000000
--- a/component_instance.py
+++ /dev/null
@@ -1,216 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-
-
-from attribute import *
-from random import randint
-from header import *
-import sys
-import copy
-
-class ComponentInstance:
- x = 0
- y = 0
- type_ = ''
- orient = ''
- attrs = []
-
- def __init__(self, input_stream):
- self.attrs = [Attribute() for _ in range(2)]
- tmp = ''
- compnum = 0
- x0 = 0
- y0 = 0
- line = input_stream.readline().strip().split()
- #print(line)
- tmp,compnum,self.type_,x0,y0,self.orient = line
- x0 = int(x0)
- y0 = int(y0)
- self.x = x0 * MULT
- self.y = y0 * MULT
- #input_stream.readline()
- g = input_stream.tell()
- #print('type ->',self.type_)
- line = input_stream.readline().strip()
-#if the above cases like VALUE, DC, GAIN doesn 't exist then giving attributes of PKGREF to it#
- #print('component instance',line)
- input_stream.seek(g)
- while(line[0] == 'a'):
- #print('compinst',line)
- attr = Attribute(line)
- #print('compinst->attr.name',attr.name)
- if attr.name == 'PKGREF':
- #print('yes attr[0]')
- self.attrs[0] = attr
- if attr.name == 'VALUE' or attr.name == 'DC' or attr.name == 'GAIN':
- #print('yes attr[1]')
- self.attrs[1] = attr
- g = input_stream.tell()
- line = input_stream.readline().strip()
- input_stream.seek(g)
- #print('attrs[0].value-> '+self.attrs[0].value,'attrs[1].name-> '+self.attrs[1].value)
- if self.attrs[0].name == '':
- #print('null attr[0]')
- self.attrs[0].name = 'PKGREF'
- self.attrs[0].value = self.type_
- self.attrs[0].orient = 'h'
- self.attrs[0].x = self.x
- self.attrs[0].y = self.y
- self.attrs[0].isHidden = True
- self.attrs[0].hjust = 'l'
- self.attrs[0].vjust = 'n'
-
- if self.attrs[1].name == '':
- #print('null attr[1]')
- self.attrs[1] = copy.copy(self.attrs[0])
-
- self.attrs[1].value = self.type_
- #print(self.attrs[1].value)
- self.attrs[1].y+=80
-
- self.attrs[0].x+= self.x
- self.attrs[1].x+= self.x
- self.attrs[0].y+= self.y
- self.attrs[1].y+= self.y
- #print('component initiated', self.attrs[0].value)
-
- #print all the components in output schematic file as per KiCad format
- def print(self, output_stream):
- output_stream.write('$Comp\n'+'L '+self.type_+' '+self.attrs[0].value+'\n')
- output_stream.write('U 1 1 '+str(randint(0, sys.maxsize+1)%90000000+10000000)+'\n')
- output_stream.write('P '+str(self.x)+' '+str(self.y)+'\n') #printing the postion of component
- output_stream.write('F 0')# upto F0 printed
- self.attrs[0].print(output_stream)# print the attributes by calling attributes print
- output_stream.write('F 1')# upto F1 printed
- self.attrs[1].print(output_stream)# print the attributes by calling attributes print
- output_stream.write('\t1 '+str(self.x)+' '+str(self.y)+'\n')# printing the postions of the component again
- if self.orient == 'v':
- output_stream.write('\t0 -1 -1 0\n')# rotation matrix corresponding to KiCad
- if self.orient == 'V':
- output_stream.write('\t0 1 -1 0\n')# rotation matrix corresponding to KiCad
- if self.orient == 'h':
- output_stream.write('\t1 0 0 -1\n')
- if self.orient == 'H':
- output_stream.write('\t-1 0 0 -1\n')
- if self.orient == 'u':
- output_stream.write('\t-1 0 0 1\n')
- if self.orient == 'U':
- output_stream.write('\t1 0 0 1\n')
- if self.orient == 'd':
- output_stream.write('\t0 1 1 0\n')
- if self.orient == 'D':
- output_stream.write('\t0 -1 1 0\n')
-
- output_stream.write('$EndComp\n')#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#Copyright (c) 2014, Siddhant Ranade,Ashlesha Atrey and Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal
-
-
-
-from attribute import *
-from random import randint
-from header import *
-import sys
-import copy
-
-class ComponentInstance:
- x = 0
- y = 0
- type_ = ''
- orient = ''
- attrs = []
-
- def __init__(self, input_stream):
- self.attrs = [Attribute() for _ in range(2)]
- tmp = ''
- compnum = 0
- x0 = 0
- y0 = 0
- line = input_stream.readline().strip().split()
- #print(line)
- tmp,compnum,self.type_,x0,y0,self.orient = line
- x0 = int(x0)
- y0 = int(y0)
- self.x = x0 * MULT
- self.y = y0 * MULT
- #input_stream.readline()
- g = input_stream.tell()
- #print('type ->',self.type_)
- line = input_stream.readline().strip()
-#if the above cases like VALUE, DC, GAIN doesn 't exist then giving attributes of PKGREF to it#
- #print('component instance',line)
- input_stream.seek(g)
- while(line[0] == 'a'):
- #print('compinst',line)
- attr = Attribute(line)
- #print('compinst->attr.name',attr.name)
- if attr.name == 'PKGREF':
- #print('yes attr[0]')
- self.attrs[0] = attr
- if attr.name == 'VALUE' or attr.name == 'DC' or attr.name == 'GAIN':
- #print('yes attr[1]')
- self.attrs[1] = attr
- g = input_stream.tell()
- line = input_stream.readline().strip()
- input_stream.seek(g)
- #print('attrs[0].value-> '+self.attrs[0].value,'attrs[1].name-> '+self.attrs[1].value)
- if self.attrs[0].name == '':
- #print('null attr[0]')
- self.attrs[0].name = 'PKGREF'
- self.attrs[0].value = self.type_
- self.attrs[0].orient = 'h'
- self.attrs[0].x = self.x
- self.attrs[0].y = self.y
- self.attrs[0].isHidden = True
- self.attrs[0].hjust = 'l'
- self.attrs[0].vjust = 'n'
-
- if self.attrs[1].name == '':
- #print('null attr[1]')
- self.attrs[1] = copy.copy(self.attrs[0])
-
- self.attrs[1].value = self.type_
- #print(self.attrs[1].value)
- self.attrs[1].y+=80
-
- self.attrs[0].x+= self.x
- self.attrs[1].x+= self.x
- self.attrs[0].y+= self.y
- self.attrs[1].y+= self.y
- #print('component initiated', self.attrs[0].value)
-
- #print all the components in output schematic file as per KiCad format
- def print(self, output_stream):
- output_stream.write('$Comp\n'+'L '+self.type_+' '+self.attrs[0].value+'\n')
- output_stream.write('U 1 1 '+str(randint(0, sys.maxsize+1)%90000000+10000000)+'\n')
- output_stream.write('P '+str(self.x)+' '+str(self.y)+'\n') #printing the postion of component
- output_stream.write('F 0')# upto F0 printed
- self.attrs[0].print(output_stream)# print the attributes by calling attributes print
- output_stream.write('F 1')# upto F1 printed
- self.attrs[1].print(output_stream)# print the attributes by calling attributes print
- output_stream.write('\t1 '+str(self.x)+' '+str(self.y)+'\n')# printing the postions of the component again
- if self.orient == 'v':
- output_stream.write('\t0 -1 -1 0\n')# rotation matrix corresponding to KiCad
- if self.orient == 'V':
- output_stream.write('\t0 1 -1 0\n')# rotation matrix corresponding to KiCad
- if self.orient == 'h':
- output_stream.write('\t1 0 0 -1\n')
- if self.orient == 'H':
- output_stream.write('\t-1 0 0 -1\n')
- if self.orient == 'u':
- output_stream.write('\t-1 0 0 1\n')
- if self.orient == 'U':
- output_stream.write('\t1 0 0 1\n')
- if self.orient == 'd':
- output_stream.write('\t0 1 1 0\n')
- if self.orient == 'D':
- output_stream.write('\t0 -1 1 0\n')
-
- output_stream.write('$EndComp\n')
diff --git a/design.py b/design.py
deleted file mode 100755
index 7589986..0000000
--- a/design.py
+++ /dev/null
@@ -1,354 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-from header import *
-import math
-
-
-# In the constructors of Line, Arc, Circle and Rectangle, the input parameters shiftx and shifty have already been scaled.
-class Line: #Constructor of Line.
- npoints = 0
- x = []
- y = []
- def __init__(self, input_stream, shiftx, shifty): #This gets called when the first character of a line is "v".This function assumes "v" and the next character(usually 0) have already been read and are NOT in the stream.
- t = 0
- temp = input_stream.readline().strip()
- self.npoints = 0
- self.x = []
- self.y = []
- while(temp!=';'):
- #t = temp
- #print('Line->',temp)
- t = temp.split()
- self.x.append(int(t[0]))
- #t = input_stream.read(1)
- self.y.append(int(t[1]))
- #tmp = input_stream.readline().strip() .The first line, i.e.the one that contains the 'v'
- temp = input_stream.readline().strip()
-
- self.x[self.npoints]*= MULT
- self.y[self.npoints]*= -1*MULT
-
- self.x[self.npoints]-=shiftx
- self.y[self.npoints]-= -1*shifty
-
- self.npoints+=1
-
- if temp != ';':
- print('Error! \";\" not found\n')# The last character in the description of a line is ";"
-
-
- def print(self, output_stream):
- output_stream.write('P '+str(self.npoints)+' 0 1 0 ')
- for i in range(self.npoints):
- output_stream.write(str(self.x[i])+' '+str(self.y[i])+' ')
- output_stream.write('N\n')
-
-class Rectangle: ## Constructor of Rectangle.
- x1 = 0
- y1 = 0
- x2 = 0
- y2 = 0
- def __init__(self, input_stream, shiftx, shifty):
- input_line = input_stream.readline().strip()
- #print('Rect->',input_line)
- self.x1, self.y1,self.x2,self.y2 = input_line.split()[:4] # The line that contains the 'r'
-
- self.x1 = (int(self.x1) * MULT) - shiftx
- self.x2 = (int(self.x2) * MULT) - shiftx
- self.y1 = (int(self.y1) * -1 * MULT) - (-1*shifty)
- self.y2 = (int(self.y2) * -1 * MULT) - (-1*shifty)
-
- def print(self, output_stream):
- output_stream.write('S '+str(self.x1)+' '+str(self.y1)+' '+str(self.x2)+' '+str(self.y2)+' 0 1 0 N\n')
-
-
-class Circle: # Constructor of Circle.
- x = 0
- y = 0
- r = 0
- def __init__(self, input_stream, shiftx, shifty):
- self.x, self.y, self.r = map(int,input_stream.readline().strip().split())
- #tmp = input_stream.readline().strip()
- #print('Circle->','x=',self.x,'y=',self.y,'r=',self.r)
- self.x*= MULT
- self.x-= shiftx
- self.y*=-1*MULT
- self.y-=-1*shifty
- self.r*= MULT
-
- def print(self, output_stream):
- output_stream.write('C '+str(self.x)+' '+str(self.y)+' '+str(self.r)+' 0 1 0 N\n')
-
-
-class Arc: # Constructor of Arc.
- x = 0
- y = 0
- r = 0
- sa = 0
- ea = 0
- x1 = 0
- y1 = 0
- x2 = 0
- y2 = 0 ## See Line::Line(istream & in , int shiftx, int shifty) above.#From pspice library, get the 3 points that describe the arc.
-
- def __init__(self, input_stream, shiftx, shifty): # Midpoints of the arcs:
- xA = 0.0
- yA = 0.0
- xB = 0.0
- yB = 0.0
- xC = 0.0
- yC = 0.0
- xmAB = 0
- xmBC = 0
- ymAB = 0
- ymBC = 0
- input_line = input_stream.readline().strip()
- #print('Arc->',input_line)
- xA,yA,xB,yB,xC,yC = map(float, input_line.split())
- #tmp = input_stream.readline().strip()
- yA*= -1
- yB*= -1
- yC*= -1
-
- xmAB = (xA+xB)/2 # The perpendicular bisectors of any two chords of a circle meet at the centre
- ymAB = (yA+yB)/2
- xmBC = (xC+xB)/2
- ymBC = (yC+yB)/2
-
- mperpAB = -(xB - xA)/(yB - yA)# Get x and y by solving the two lines(perpendicular bisectors)
- mperpBC = -(xB - xC)/(yB - yC)
-
- try:
- self.x = math.trunc((ymBC - ymAB - mperpBC * xmBC + mperpAB * xmAB)/(-mperpBC + mperpAB))
- except ZeroDivisionError:
- self.x = float('inf')
- try:
- self.y = math.trunc((xmBC - xmAB + (ymAB/mperpAB) - (ymBC/mperpBC))/((1.0/mperpAB)-(1.0/mperpBC)))
- except ZeroDivisionError:
- if mperpBC == 0.0:
- self.y = -float('inf')
- else:
- self.y = float('inf')
-
-
- if not math.isinf(self.y) and not math.isinf(self.x) and not math.isnan(self.x) and not math.isnan(self.y): # Get the radius:
- self.r = math.trunc(((self.x-xA) * (self.x-xA) + (self.y-yA) * (self.y-yA))**0.5)
- else:
- self.r = 0
-
- a = math.atan2(yA-self.y, xA-self.x)/math.pi*10.0*180.0 # Following code is used to decide which among A and C is the starting point(and thus determines "sa")
- b = math.atan2(yB-self.y, xB-self.x)/math.pi*10.0*180.0
- c = math.atan2(yC-self.y, xC-self.x)/math.pi*10.0*180.0
-
- if b < max(a,c) and b > min(a,c): #b is between a and c# print('*1')
- #print('*1')
- self.sa = math.trunc(min(a,c))
- self.ea = math.trunc(max(a,c))
-
- if b > max(a,c): #b is largest# print('*2')
- #print('*2')
- self.sa = math.trunc(max(a,c))
- self.ea = math.trunc(min(a,c) + 3600.0)
-
- if b < min(a,c): #b is smallest# print('*3')
- #print('*3')
- self.sa = math.trunc(max(a,c) - 3600.0)
- self.ea = math.trunc(min(a,c))
-
- flag_x_inf = False
- flag_y_inf = False
-
- if math.isinf(self.x) or math.isnan(self.x):
- #self.x = shiftx
- flag_x_inf = True
-
- if math.isinf(self.y) or math.isnan(self.y):
- #self.y = shifty
- flag_y_inf = True
-
-
- xA = self.x + self.r*math.cos(self.sa*math.pi/1800.0)
- yA = self.y + self.r*math.sin(self.sa*math.pi/1800.0)
- xC = self.x + self.r*math.cos(self.ea*math.pi/1800.0)
- yC = self.y + self.r*math.sin(self.ea*math.pi/1800.0)
-
- self.sa+=1
- self.ea-=1
-
- self.r*=MULT
-
- self.x1 = (xA*MULT)-shiftx
- self.y1 = ((yA*MULT)-(-1)*shifty)
- self.x2 = ((xC*MULT)-shiftx)
- self.y2 = ((yC*MULT)-(-1)*shifty)
-
- if not flag_x_inf:
- self.x*=MULT
- self.x-=shiftx
-
- else:
- self.x = shiftx
-
- if not flag_y_inf:
- self.y*=MULT
- self.y-=(-1)*shifty
-
- else:
- self.y = shifty
- # scale and shift: #startx, starty, endx, endy are redundant.May not even be in use.Haven 't been fixed.
-
- if math.isinf(self.x1) or math.isnan(self.x1) or math.isinf(self.y1) or math.isnan(self.y1) or math.isinf(self.x2) or math.isnan(self.x2) or math.isinf(self.y2) or math.isnan(self.y2):
- self.x1 = -(2**31)
- self.x2 = -(2**31)
- self.y1 = -(2**31)
- self.y2 = -(2**31)
-
- else:
- self.x1 = math.trunc(self.x1)
- self.y1 = math.trunc(self.y1)
- self.x2 = math.trunc(self.x2)
- self.y2 = math.trunc(self.y2)
-
- '''
- if mperpAB == 0 or mperpBC == 0:
- print('mperpAB=',mperpAB, 'mperpBC=', mperpBC)
- print('X=',self.x,'Y=',self.y)
- print('Radius=',self.r)
- print('a=',a,'b=',b,'c=',c)
- print('xA=',xA,'yA=',yA,'xC=',xC,'yC=',yC)
- print('x=',self.x,'y=',self.y)
- print('x1=',self.x1,'x2=',self.x2,'y1=',self.y1,'y2=',self.y2)
- print('sa=',self.sa,'ea=',self.ea)
- '''
- def print(self,output_stream):
- output_stream.write('A '+str(math.trunc(self.x))+' '+str(math.trunc(self.y))+' '+str(int(self.r))+' '+str(int(self.sa))+' '+str(int(self.ea))+' '+' 0 1 0 N '+str(int(self.x1))+' '+str(int(self.y1))+' '+str(int(self.x2))+' '+str(int(self.y2))+' '+'\n')
-
-
-class Text: #Constructor of Circle.
- x = 0
- y = 0
- text = ''
- orient = ''
-
- def __init__(self,input_stream, shiftx, shifty):
- input_line = input_stream.readline().strip().split()
- self.x,self.y,self.orient = input_line[:3]
- self.x = int(self.x)
- self.y = int(self.y)
- #tmp = input_stream.readline().strip()
-
- self.text = input_stream.readline().strip()
- self.x*=MULT
- self.y*=-1*MULT
- self.x-=shiftx
- self.y-=-1*shifty
-
- def print(self,output_stream):
- output_stream.write('T ') # The line that contains the 't'
- if self.orient[0] == 'h':
- output_stream.write('0 ')
- elif self.orient[0] == 'v':
- output_stream.write('900 ')
- output_stream.write(str(self.x)+' '+str(self.y)+' '+str(30)+' 0 0 0 '+self.text+'\n')
-
-
-class Design: #Constructor of Design.
- shiftx = 0
- shifty = 0
- lines = []
- rects = []
- circles = []
- arcs = []
- texts = [] # Reads the whole design, makes Line, Circle, etc.objects and stores them in the appropriate container(appropriate vector)
- def __init__(self, input_stream):
- g = 0
- tmp = ''
- t = 0
- tint = ''
- tmp = input_stream.readline().strip()
- #print('Design->', tmp)
- if('@graphics' not in tmp):
- print('Design not found!')
- return
- #print('Graphics->',tmp.split())
- self.lines = []
- self.rects = []
- self.circles = []
- self.arcs = []
- self.texts = []
- tmp = tmp.split()
- tint,tint,tint,self.shiftx,self.shifty= map(str,tmp[:5])
- if len(tmp) > 5:
- tmp = ''.join(tmp[5:])
- self.shiftx = int(self.shiftx)*MULT # print('shiftx->', self.shiftx, 'shifty->', self.shifty)
- self.shifty = int(self.shifty)*MULT
- #print('shiftx->',self.shiftx,'shifty->',self.shifty)
- while(t!= '*'): #As long as we haven 't reached the description of the next Component continue reading the lib file.
- g = input_stream.tell() # Get the position of the read head, so that we can go back to this position
- t = input_stream.read(1) # Get the first character of the description, store in "t".This character gives what shape it is.
- if not t:
- break
-
- if t == 'v':
- #print('Line')
- input_stream.read(1)
- input_stream.read(1)
- input_stream.read(1)
- l = Line(input_stream, self.shiftx, self.shifty)
- self.lines.append(l)
-
- elif t == 'r':
- #print('Rect')
- input_stream.read(1)
- input_stream.read(1)
- input_stream.read(1)
- r = Rectangle(input_stream, self.shiftx, self.shifty)
- self.rects.append(r)
-
- elif t == 'c':
- #print('Circle')
- input_stream.read(1)
- input_stream.read(1)
- input_stream.read(1)
- c = Circle(input_stream, self.shiftx, self.shifty)
- self.circles.append(c)
-
- elif t == 'a':
- #print('Arc')
- input_stream.read(1)
- input_stream.read(1)
- input_stream.read(1)
- a = Arc(input_stream, self.shiftx, self.shifty)
- self.arcs.append(a)
-
- elif t == 'z':
- #print('Text')
- input_stream.read(1)
- input_stream.read(1)
- input_stream.read(1)
- z = Text(input_stream, self.shiftx, self.shifty)
- self.texts.append(z)
-
- else: #If t is neither 'v', 'r', 'c'
- tmp = input_stream.readline().strip()
- g = input_stream.tell()
-
- input_stream.seek(g)
-
-
- def print(self, output_stream):
- for i in range(len(self.lines)):
- self.lines[i].print(output_stream)
- for i in range(len(self.rects)):
- self.rects[i].print(output_stream)
- for i in range(len(self.circles)):
- self.circles[i].print(output_stream)
- for i in range(len(self.arcs)):
- self.arcs[i].print(output_stream)
- for i in range(len(self.texts)):
- self.texts[i].print(output_stream)
diff --git a/header.py b/header.py
deleted file mode 100755
index 7f69210..0000000
--- a/header.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-
-MULT = 10
-nameAppend = ''
-REMOVEDCOMPONENTS = ''
-
-
diff --git a/include.py b/include.py
deleted file mode 100755
index e69de29..0000000
--- a/include.py
+++ /dev/null
diff --git a/libParser.py b/libParser.py
deleted file mode 100755
index c94bd7d..0000000
--- a/libParser.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-import sys
-import os
-from attribute import *
-from component_instance import *
-from component import *
-from design import *
-from wire import *
-from header import *
-from misc import *
-
-
-libDescr = 'EESchema-LIBRARY Version 4.7 Date: \n#encoding utf-8\n'
-
-nameAppend = '_PSPICE'
-REMOVEDCOMPONENTS = ['TITLEBLK', 'PARAM', 'readme', 'VIEWPOINT', 'LIB', 'copyright', 'WATCH1', 'VECTOR', 'NODESET1']
-
-for fcounter in range(1, len(sys.argv[1:])+1):
- input_file = open(sys.argv[fcounter], 'r+')
- fbasename = os.path.basename(sys.argv[fcounter])
- flname = fbasename[:fbasename.find('.')] + '.lib'
- flib = open(flname, 'w+') #Write .lib header:
- print('Library file name: ',flname)
-
- flib.write(libDescr)
-
- line = skipTo(input_file,'*symbol')
- print('Parser',line)
- '''
- while(line != '' and '*symbol' not in line):
- line = input_file.readline().strip()
- print(line)
- '''
-
- while(line != '__ERROR__'):
- #print(input_file.tell())
- #print('Compo line',line)
- d = line.find(' ')
- cnametmp = line[d+1:]
- #print('cnametmp',cnametmp)
- d = cnametmp.find(' ')
- if d == -1:
- cname = cnametmp
- else:
- cname = cnametmp[0:d]
-
- #print('cname->',cname)
-
- fileTMP = open(sys.argv[fcounter])
- c = Component(fileTMP, cname)
- #print(c.ref)
- fixComp(c)
- #print('After fixComp',cname, 'ref=', c.ref)
-
- write = True
-
- for i in range(len(REMOVEDCOMPONENTS)): #Don't let these components be saved.
- if cname == REMOVEDCOMPONENTS[i]:
- write = False
- break
- #print('write->', write)
- #print('line->', line)
- if write:
- c.type_ = c.type_ + nameAppend
- c.print(flib)
-
- '''line = input_file.readline().strip()
- while(line != '' and '*symbol' not in line):
- line = input_file.readline().strip()
- print(line)
- '''
- line = skipTo(input_file, '*symbol')
- flib.write('#\n#End Library\n')
- flib.close()
diff --git a/misc.py b/misc.py
deleted file mode 100755
index 1d77ae8..0000000
--- a/misc.py
+++ /dev/null
@@ -1,232 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-from component_instance import *
-
-
-def skipTo(input_stream, s): # Find the line containing the first occurence (after the current position) of string s in istream& in and read it and then return it
- tmp = '1'
- while tmp != '' and tmp.find(s) == -1:
- tmp = input_stream.readline().strip() # cout<<tmp<<"**"<<endl;
-
- # print('SkipLine',tmp)
- # print('In skipto',tmp.find(s))
-
- if tmp == '': # cerr<<"skipTo error"<<endl;
- return '__ERROR__'
-
- return tmp
-
-
-def stripNumFromRef(ref):
- i = len(ref) - 1
- while i >= 0 and ref[i] >= '0' and ref[i] <= '9':
- i -= 1
- return ref[:i + 1]
-
-
-def fixComp(c):
-
- # print('In fixComp c.type' ,c.type_)
-
- ref = c.ref
-
- # print('last 6')
-
- if ref == 'Q': # Transistor
- for i in range(0, len(c.pins)):
- if c.pins[i].n == 'e' or c.pins[i].n == 'E':
- c.pins[i].n = '1'
- if c.pins[i].n == 'b' or c.pins[i].n == 'B':
- c.pins[i].n = '2'
- if c.pins[i].n == 'c' or c.pins[i].n == 'C':
- c.pins[i].n = '3'
-
- ref = 'Q'
- c.ref = 'Q'
- return
-
- # print('last 5')
-
- if ref == 'J': # Mos
- for i in range(0, len(c.pins)):
- if c.pins[i].n == 'g' or c.pins[i].n == 'G':
- c.pins[i].n = 'G'
- if c.pins[i].n == 's' or c.pins[i].n == 'S':
- c.pins[i].n = 'S'
- if c.pins[i].n == 'd' or c.pins[i].n == 'D':
- c.pins[i].n = 'D'
- ref = 'J'
- c.ref = 'J'
- return
-
- # print('last 5')
-
- if ref == 'M': # FET
- for i in range(0, len(c.pins)):
- if c.pins[i].n == 'g' or c.pins[i].n == 'G':
- c.pins[i].n = 'G'
- if c.pins[i].n == 's' or c.pins[i].n == 'S':
- c.pins[i].n = 'S'
- if c.pins[i].n == 'd' or c.pins[i].n == 'D':
- c.pins[i].n = 'D'
- ref = 'M'
- c.ref = 'M'
- return
-
- # print('last4')
-
- if ref == 'E': # Linear voltage controlled voltage sources
- for i in range(0, len(c.pins)):
- if c.pins[i].n == '1':
- c.pins[i].n = '3'
- continue
- if c.pins[i].n == '2':
- c.pins[i].n = '4'
- continue
- if c.pins[i].n == '3':
- c.pins[i].n = '1'
- continue
- if c.pins[i].n == '4':
- c.pins[i].n = '2'
- continue
- ref = 'E'
- c.ref = 'E'
- return
-
- # print('last3') #Linear current controlled current sources
-
- if ref == 'F':
- for i in range(0, len(c.pins)):
- if c.pins[i].n == '1':
- c.pins[i].n = '3'
- continue
- if c.pins[i].n == '2':
- c.pins[i].n = '4'
- continue
- if c.pins[i].n == '3':
- c.pins[i].n = '1'
- continue
- if c.pins[i].n == '4':
- c.pins[i].n = '2'
- continue
- ref = 'F'
- c.ref = 'F'
- return
-
- # print('last2')
-
- if ref == 'G': # Linear Voltage controlled voltage sources
- for i in range(0, len(c.pins)):
- if c.pins[i].n == '1':
- c.pins[i].n = '3'
- continue
- if c.pins[i].n == '2':
- c.pins[i].n = '4'
- continue
- if c.pins[i].n == '3':
- c.pins[i].n = '1'
- continue
- if c.pins[i].n == '4':
- c.pins[i].n = '2'
- continue
- ref = 'G'
- c.ref = 'G'
- return
-
- # print('last1')
-
- if ref == 'H': # Linear Current controlled voltage sources
- for i in range(0, len(c.pins)):
- if c.pins[i].n == '1':
- c.pins[i].n = '3'
- continue
- if c.pins[i].n == '2':
- c.pins[i].n = '4'
- continue
- if c.pins[i].n == '3':
- c.pins[i].n = '1'
- continue
- if c.pins[i].n == '4':
- c.pins[i].n = '2'
- continue
- ref = 'H'
- c.ref = 'H'
- return
-
- # print('last')
-
- if c.type_ == 'VPLOT1' or c.type_ == 'VPLOT2' or c.type_ \
- == 'VPRINT1' or c.type_ == 'VPRINT2' or c.type_ == 'IPRINT' \
- or c.type_ == 'IPLOT':
- ref = 'U'
- c.ref = 'U'
- c.value = c.type_
- if c.type_ == 'VPLOT2':
- c.value = 'VPLOT8'
- if c.type_ == 'VPRINT2':
- c.value = 'VPRINT'
-
- # print('*1')
-
- return
-
-
-def fixInst(ci):
-
- # print(len(ci.attrs))
-
- ref = stripNumFromRef(ci.attrs[0].value)
-
- # print('misc',ref)
-
- if ref == 'J':
- ci.attrs[0].value = 'J?'
- return
- if ref == 'M':
- ci.attrs[0].value = 'M?'
- return
-
-# Voltage sources
-
- if ci.type_ == 'VAC' or ci.type_ == 'VDC' or ci.type_ == 'VPULSE' \
- or ci.type_ == 'VSIN' or ci.type_ == 'VEXP' or ci.type_ \
- == 'VPWL':
- if ci.attrs[1].value == 'VAC' or ci.attrs[1].value == 'VDC' \
- or ci.attrs[1].value == 'VPULSE' or ci.attrs[1].value \
- == 'VEXP':
- ci.attrs[1].value = \
- ci.attrs[1].value[1:len(ci.attrs[1].value)]
- if ci.attrs[1].value == 'VSIN':
- ci.attrs[1].value = 'SINE'
- return
-
-# Plot sources
-
- if ci.type_ == 'VPLOT1' or ci.type_ == 'VPLOT2' or ci.type_ \
- == 'VPRINT1' or ci.type_ == 'VPRINT2' or ci.type_ == 'IPRINT' \
- or ci.type_ == 'IPLOT':
- ci.attrs[0].value = 'U?'
- if ci.type_ == 'VPLOT2':
- ci.attrs[1].value = 'VPLOT8'
- if ci.type_ == 'VPRINT2':
- ci.attrs[1].value = 'VPRINT'
- return
-
-# Gnd sources
-
- if ci.type_ == 'AGND' or ci.type_ == 'GND_ANALOG':
- ci.type_ = 'GND'
- return
-
- if ci.type_ == 'EGND' or ci.type_ == 'GND_EARTH':
-
- # print(True)
-
- ci.type_ = 'GND'
- return
-
diff --git a/parser.py b/parser.py
deleted file mode 100755
index 62f8bb8..0000000
--- a/parser.py
+++ /dev/null
@@ -1,192 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-from header import * #Importing header file from PythonLib folder
-from component_instance import * #Importing component_instance file from PythonLib folder
-from wire import * #Importing header file from PythonLib folder
-
-import sys #Importing python sys module
-import os #Importing python os module
-
-from misc import * #Importing misc file from PythonLib folder
-
-
-
-files = sys.argv[1:]
-input_file = files[0] #input file(Pspice Schematic) location
-new_location = files[1] #new file(KiCAD file) location
-new_directory = os.path.dirname(new_location) #Creating new directory path(where KiCAD files are to be stored
-base_name = os.path.basename(new_location) #Addding base name to the new directory
-
-
-
-if not os.path.exists(new_location): #If the directory does not already exists, then making new directory
- os.makedirs(new_location)
-
-
-
-#current_location = os.getcwd()
-file = open(input_file, 'r+') #opening a file in read and write mode
-os.chdir(new_location) #changing to the new directory location
-fprojname = base_name + '.proj' #Creating name for the new KiCAD project
-fproname = base_name + '.pro' #Creating name for the new KiCAD project
-fschname = base_name + '.sch' #Creating name for the new EESchema schematic
-
-
-
-
-
-#Creating a String of the libraries and library names to be added in the EESchema and project file respectively
-descr = 'EESchema Schematic File Version 2 date \nLIBS:power\nLIBS:device\nLIBS:transistors\nLIBS:conn\nLIBS:linear\nLIBS:regul\nLIBS:74xx\nLIBS:cmos4000\nLIBS:adc-dac\nLIBS:memory\nLIBS:xilinx\nLIBS:special\nLIBS:microcontrollers\nLIBS:dsp\nLIBS:microchip\nLIBS:analog_switches\nLIBS:motorola\nLIBS:texas\nLIBS:intel\nLIBS:audio\nLIBS:interface\nLIBS:digital-audio\nLIBS:philips\nLIBS:display\nLIBS:cypress\nLIBS:siliconi\nLIBS:opto\nLIBS:atmel\nLIBS:contrib\nLIBS:valves\nEELAYER 25 0\nEELAYER END\n$Descr A4 11700 8267\nencoding utf-8\nSheet 1 1\nTitle \"\"\nDate \"\"\nRev \"\"\nComp \"\"\nComment1 \"\"\nComment2 \"\"\nComment3 \"\"\nComment4 \"\"\n$EndDescr\n'
-
-
-
-
-
-proDescr = 'update= \nlast_client=eeschema\n[eeschema]\nversion=1\nLibDir=\nNetFmt=1\nHPGLSpd=20\nHPGLDm=15\nHPGLNum=1\noffX_A4=0\noffY_A4=0\noffX_A3=0\noffY_A3=0\noffX_A2=0\noffY_A2=0\noffX_A1=0\noffY_A1=0\noffX_A0=0\noffY_A0=0\noffX_A=0\noffY_A=0\noffX_B=0\noffY_B=0\noffX_C=0\noffY_C=0\noffX_D=0\noffY_D=0\noffX_E=0\noffY_E=0\nRptD_X=0\nRptD_Y=100\nRptLab=1\nLabSize=60\n[eeschema/libraries]\nLibName1=power\nLibName2=device\nLibName3=transistors\nLibName4=conn\nLibName5=linear\nLibName6=regul\nLibName7=74xx\nLibName8=cmos4000\nLibName9=adc-dac\nLibName10=memory\nLibName11=xilinx\nLibName12=special\nLibName13=microcontrollers\nLibName14=dsp\nLibName15=microchip\nLibName16=analog_switches\nLibName17=motorola\nLibName18=texas\nLibName19=intel\nLibName20=audio\nLibName21=interface\nLibName22=digital-audio\nLibName23=philips\nLibName24=display\nLibName25=cypress\nLibName26=siliconi\nLibName27=opto\nLibName28=atmel\nLibName29=contrib\nLibName30=valves'
-
-
-
-
-nameAppend = '_PSPICE' #name to be appended with the Pspice Components
-REMOVEDCOMPONENTS = ['TITLEBLK', 'PARAM', 'readme', 'VIEWPOINT', 'LIB', 'copyright', 'WATCH1', 'VECTOR', 'NODESET1']
- # Components to be removed
-
-
-
-#print('opening .proj file')
-fproj = open(fprojname,'w+') #opening the project KiCAD file in write mode, if not present creating it
-fproj.write('schematicFile '+ base_name + '.sch.sch' + '\n') #writing to the project file
-fproj.close() #closing the project file
-#print('closing .proj file')
-
-
-
-
-#print('opening .pro file')
-fpro = open(fproname, 'w+') #opening the project KiCAD file in write mode, if not present creating it
-fpro.write(proDescr + '\n') #writing the library names to the project file
-fpro.close() #closing the project file
-#print('closing .pro file')
-
-
-
-
-textline = file.readline().strip() #reading from the Pspice Schematic file until '@status' is reached
-while('@status' not in textline):
- textline = file.readline().strip()
- #print(textline)
-
-textline = file.readline().strip()
-
-
-
-
-#print('opening .sch file')
-fsch = open(fschname, 'w+') #opening the EESchema file in write mode, if not present creating it
-fsch.write(descr) #writing the libraries to the project file
-
-while('@ports' not in textline): #reading from the Pspice Schematic file until '@ports' is reached
- textline = file.readline().strip()
- #print(textline)
-
-
-
-
-
-componentInstances = [] #creating array of componentInstances for EESchema
-g = file.tell() #getting position of file handle
-textline = file.readline().strip()
-while(textline[:4] == 'port' and textline != ''): #reading each port data from the Pspice schematic file
- #print('decoding ports')
- #print(textline)
- file.seek(g) #setting the position of file handle
- ci = ComponentInstance(file) #sending the 'file'object to ComponentInstance Constructor
- #and storing the result in ci
- if ci.type_ == 'AGND' or ci.type_ == 'GND_ANALOG' or ci.type_ == 'GND_EARTH' or ci.type_ == 'EGND' or ci.type_ == '+5V' or ci.type_ == '-5V' : #checking whether the type of ci is ground or power lines
- #print(ci.type_)
- fixInst(ci)
- componentInstances.append(ci) #appending ci to the array of componentInstances for EESchema
-
- componentInstances[-1].attrs[0].value = '#PWR'+str(len(componentInstances))
- #appending pwr to the array of componentInstances for EESchema
-
- g = file.tell() #getting position of file handle
- textline = file.readline().strip()
-
-'''file.seek(g)
-g = file.tell()
-print(file.readline().strip())
-file.seek(g)
-print('**', textline, ('@parts' in textline))
-'''
-
-
-
-
-while('@parts' not in textline and textline!=''): #reading each part data from the Pspice schematic file
- #print('parts')
- textline = file.readline().strip()
- #print(textline)
-g = file.tell() #getting position of file handle
-
-
-
-
-#textline = file.readline().strip()
-textline = file.readline().strip()
-#print('part->', textline)
-while(textline[:4] == 'part' and textline != ''):
- file.seek(g) #setting the position of file handle
- #print('part',file.readline().strip())
- file.seek(g)
- ci = ComponentInstance(file) #sending the 'file' object to ComponentInstance Constructor
- #in ComponentInstance.py and storing the result in ci
- fixInst(ci)
- ci.type_ = ci.type_ + nameAppend #appending _PSPIE stored in nameAppend to ci.type
- componentInstances.append(ci) #appending ci to the array of componentInstances for EESchema
- g = file.tell() #getting position of file handle
- textline = file.readline().strip()
-
-
-
-
-
-file.seek(g) #setting the position of file handle
-#print('len of componentInstances = ', len(componentInstances))
-for i in range(0, len(componentInstances)): #printing the componentInstances array to the EESchema Schematic file
- componentInstances[i].print(fsch)
-
-while('@conn' not in textline and textline != ''): #reading each part data from the Pspice schematic file
- textline = file.readline().strip()
-
-
-
-
-wires = [] #creating an array wires
-file.readline().strip()
-parseWire(file, wires) #sending the 'file' object to parseWire function in wire.py
- #and storing the result in wires
-
-for i in range(0, len(wires)): #printing the wires array to the EESchema Schematic file
- wires[i].print(fsch)
-
-
-
-
-conns = []
-parseConn(file, conns) #sending the 'file' object to parseConn function in wire.py
- #and storing the result in conns
-
-for i in range(0, len(conns)): #printing the conns array to the EESchema Schematic file
- conns[i].print(fsch)
-
-
-
-
-fsch.write('$EndSCHEMATC\n') #writing '$EndSCHEMATIC' to EESchema Schematic
-fsch.close() #closing the EESchema Schematic
diff --git a/wire.py b/wire.py
deleted file mode 100755
index b8f5603..0000000
--- a/wire.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#The MIT License (MIT)
-
-#PSpice to Oscad Schematic Converter
-#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
-#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
-
-
-from header import *
-
-class Wire:
- x1 = 0
- y1 = 0
- x2 = 0
- y2 = 0
- def __init__(self, x1 = 0, y1 = 0, x2 = 0, y2 = 0):
- self.x1 = x1
- self.x2 = x2
- self.y1 = y1
- self.y2 = y2 # print
-
- def print(self, output_stream):
- output_stream.write('Wire Wire Line\n'+'\t')
- output_stream.write(str(self.x1)+' '+str(self.y1)+' '+str(self.x2)+' ' +str(self.y2)+'\n')
-
-class Connector:
- x = 0
- y = 0
-
- def __init__(self, x = 0, y = 0):
- self.x = x
- self.y = y # print funciton of Connector class to print connectors format to output schematic file as per KiCad format
-
- def print(self, output_stream):
- output_stream.write('Connection ~ '+str(self.x)+' '+str(self.y)+'\n')# Function parseWire to get the postion of wires
-
-def parseWire(input_stream, wires):
-
- line = input_stream.readline().strip()
- while(line[0]!='@'): #print('parsing wire', line)
- #print('parsing wire', line)
- if line[0] == 's': #reading 's'
- #print('Yes')
- string = line
- t,x1,y1,x2,y2 = string.split()[:-1] # retriving the values from string stream
- x1 = int(x1)
- y1 = int(y1)
- x2 = int(x2)
- y2 = int(y2)
-
- w = Wire(x1*MULT, y1*MULT, x2*MULT, y2*MULT)
- wires.append(w)
- line = input_stream.readline().strip() # Function parseConn to get the position of junction
- return input_stream
-
-def parseConn(input_stream, conns):
- line = input_stream.readline().strip()
- while(line[0]!= '@'):
- if line[0] == 'j': #reading 'j'
- string = line
- t,x1,y1 = string.split()
- x1 = int(x1)
- y1 = int(y1)
- c = Connector(x1*MULT, y1*MULT)
- conns.append(c)
- line = input_stream.readline().strip()
- return input_stream