summaryrefslogtreecommitdiff
path: root/src/converter/schematic_converters/lib/PythonLib/wire.py
diff options
context:
space:
mode:
authorSangaviGR2024-09-13 01:15:31 +0530
committerGitHub2024-09-13 01:15:31 +0530
commit3989889835663988f3dc89f1c1b0a8c5e23e303d (patch)
tree6eb539107e3c9a78049dc615b118db4e4cf01738 /src/converter/schematic_converters/lib/PythonLib/wire.py
parent5865b5d9a2375971fe2ec1cbcc3e9344f138907d (diff)
downloadeSim-3989889835663988f3dc89f1c1b0a8c5e23e303d.tar.gz
eSim-3989889835663988f3dc89f1c1b0a8c5e23e303d.tar.bz2
eSim-3989889835663988f3dc89f1c1b0a8c5e23e303d.zip
Integrated Schematic Converters (#271)
Add the files for the Schematic Converters(PSpice to KiCad and LTspice to KiCad converters) to eSim.
Diffstat (limited to 'src/converter/schematic_converters/lib/PythonLib/wire.py')
-rw-r--r--src/converter/schematic_converters/lib/PythonLib/wire.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/converter/schematic_converters/lib/PythonLib/wire.py b/src/converter/schematic_converters/lib/PythonLib/wire.py
new file mode 100644
index 00000000..b8f56037
--- /dev/null
+++ b/src/converter/schematic_converters/lib/PythonLib/wire.py
@@ -0,0 +1,66 @@
+#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