summaryrefslogtreecommitdiff
path: root/tableconversion.py
diff options
context:
space:
mode:
authorJoshua Drake <joshua.ellis.drake@okstate.edu>2024-11-11 16:46:24 -0600
committerJoshua Drake <joshua.ellis.drake@okstate.edu>2024-11-11 16:46:24 -0600
commitfd00e596b01c4dafcb922bc4ce3844d9caecacfe (patch)
tree443d916bc0a8fd5063e04055a1935fb19345f217 /tableconversion.py
parentac1ae4487748cc07fe809fd2a836fa512654a602 (diff)
Almost everything is accounted for. Figure out something for shields...
Diffstat (limited to 'tableconversion.py')
-rw-r--r--tableconversion.py93
1 files changed, 76 insertions, 17 deletions
diff --git a/tableconversion.py b/tableconversion.py
index 71b56a5..a9f436d 100644
--- a/tableconversion.py
+++ b/tableconversion.py
@@ -23,6 +23,11 @@ def parse_wireviz_yml(file_path):
connectorwpin = str(connection[1])
connector = connectorwpin[2:connectorwpin.find("':")]
connectorwires = str(connection[0])
+ elif(len(connection)==4):
+ connectorwpin = str(connection[3])
+ connector = connectorwpin[2:connectorwpin.find("':")].strip("'")
+ connectorwires = str(connection[2])
+
#currently skipping all abnormal conditions
if connectorlist.count(connector) < 1:
continue
@@ -35,14 +40,25 @@ def parse_wireviz_yml(file_path):
connectorpinsadjusted.append(x)
else:
connectorpinsadjusted.append(pins)
+ #connectorpinsadjusted= list(map(int,connectorpinsadjusted))
bundle = connectorwires[2:connectorwires.find("':")]
bundlewires = connectorwires[connectorwires.find(" [")+2:connectorwires.rfind("]}")].split(",")
+ # print(bundlewires)
+ # bundlewiresadjusted = []
+ # for wire in bundlewires:
+ # if str(wire).count("-") > 0:
+ # wirerange = wire.strip("' ").split("-")
+ # for x in range(int(wirerange[0]),int(wirerange[1])+1):
+ # bundlewiresadjusted.append(x)
+ # else:
+ # bundlewiresadjusted.append(wire)
+ # print(bundlewiresadjusted)
connector2pinsadjusted = []
-
- if len(connection) > 2:
+ if len(connection) == 3:
connector2wpin = str(connection[2])
connector2 = connector2wpin[2:connector2wpin.find("':")]
+ print(connector2)
connector2pins = connector2wpin[connector2wpin.find(" [")+2:connector2wpin.rfind("]}")].split(",")
for pins in connector2pins:
idcount=idcount+1
@@ -60,65 +76,108 @@ def parse_wireviz_yml(file_path):
else:
connector2pinsadjusted = connector2pins
for x in range(0,len(connectorpinsadjusted)):
- ident = str(ord(connector[0]))[:1]+str(ord(str(connectorpinsadjusted[x])[-1]))[-1]+str(ord(str(connector2pinsadjusted[x])[-1]))[-1]+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1]
- ident = ident.strip(" ")
pin1 = connectorpinsadjusted[x]
+ con1type = "Unspecified"
pin2 = connector2pinsadjusted[x]
+ con2type = "Unspecified"
notes = ""
- if str(connectors[connector]).count("'pinlabels':"):
+ if str(connectors[connector.strip("'")]).count("'pinlabels':"):
stringarray = list(map(str,connectors[connector]['pinlabels']))
- if stringarray.count(connectorpinsadjusted[x][1:-1]):
+ if stringarray.count(str(connectorpinsadjusted[x])[1:-1]):
pin1= connectors[connector]['pins'][stringarray.index(connectorpinsadjusted[x][1:-1])]
- if str(connectors[connector2.strip("'")]).count("'pinlabels':")and not(str(connector2pinsadjusted[x]).isnumeric()):
- stringarray = list(map(str,connectors[connector2]['pinlabels']))
- print(connector2pinsadjusted)
- if stringarray.count(connector2pinsadjusted[x].strip(" ")[1:-1]):
- pin2= connectors[connector2]['pins'][stringarray.index(connector2pinsadjusted[x].strip(" ")[1:-1])]
+ if str(connectors[connector]).count("'type':"):
+ con1type = connectors[connector]['type']
+ if not connectorlist.count(connector2) < 1:
+ if str(connectors[connector2.strip("'")]).count("'pinlabels':")and not(str(connector2pinsadjusted[x]).isnumeric()):
+ stringarray = list(map(str,connectors[connector2]['pinlabels']))
+ if stringarray.count(connector2pinsadjusted[x].strip(" ")[1:-1]):
+ pin2= connectors[connector2]['pins'][stringarray.index(connector2pinsadjusted[x].strip(" ")[1:-1])]
+ if str(connectors[connector2.strip("'")]).count("'type':"):
+ con2type = connectors[connector2.strip("'")]['type']
if str(wires[bundle]).find("'notes':") > 0:
notes = wires[bundle]['notes']
+ ident = str(ord(connector[0]))[0]+str(ord(str(pin1)[-1]))[-1]+str(ord(str(pin2)[-1]))[-1]+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1]
+ ident = ident.strip(" ")
wire_info.append({
'Identifier': ident,
'End 1': connector,
+ 'Type 1': con1type,
'Pin 1': pin1,
'Length': wires[bundle]['length'],
'Color': wires[bundle]['colors'][x],
'Gauge': wires[bundle]['gauge'],
'End 2': connector2,
+ 'Type 2': con2type,
'Pin 2': pin2,
'Notes': notes,
})
- else:
+ elif len(connection) == 2:
idcount=idcount+1
for x in range(0,len(connectorpinsadjusted)):
- ident = str(ord(connector[0]))[:1]+str(ord(str(connectorpinsadjusted[x])[-1]))[-1]+"0"+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1]
- ident = ident.strip(" ")
+ pin1 = connectorpinsadjusted[x]
+ con1type = "Unspecified"
notes = ""
- if str(connectors[connector]).count("'pinlabels':"):
+ if str(connectors[connector]).count("'pinlabels':") and not str(connectors[connector]['pins']).count(str(pin1)):
stringarray = list(map(str,connectors[connector]['pinlabels']))
if stringarray.count(connectorpinsadjusted[x][1:-1]):
pin1= connectors[connector]['pins'][stringarray.index(connectorpinsadjusted[x][1:-1])]
+ if str(connectors[connector]).count("'type':"):
+ con1type = connectors[connector]['type']
if str(wires[bundle]).find("'notes':") > 0:
notes = wires[bundle]['notes']
+ ident = str(ord(connector[0]))[0]+str(ord(str(pin1)[-1]))[-1]+"0"+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1]
+ ident = ident.strip(" ")
wire_info.append({
'Identifier': ident,
'End 1': connector,
+ 'Type 1': con1type,
'Pin 1': connectorpinsadjusted[x],
'Length': wires[bundle]['length'],
'Color': wires[bundle]['colors'][x],
'Gauge': wires[bundle]['gauge'],
'End 2': "----",
+ 'Type 2': "----",
'Pin 2': "----",
'Notes': notes,
})
+ elif len(connection) == 4:
+ idcount=idcount+1
+ for x in range(0,len(connectorpinsadjusted)):
+ pin1 = connectorpinsadjusted[x]
+ con1type = "Unspecified"
+ notes = ""
+ if str(connectors[connector]).count("'pinlabels':"):
+ stringarray = list(map(str,connectors[connector]['pinlabels']))
+ if stringarray.count(str(connectorpinsadjusted[x])[1:-1]):
+ pin1= connectors[connector]['pins'][stringarray.index(connectorpinsadjusted[x][1:-1])]
+ if str(connectors[connector]).count("'type':"):
+ con1type = connectors[connector]['type']
+ if str(wires[bundle]).find("'notes':") > 0:
+ notes = wires[bundle]['notes']
+ ident = str(ord(connector[0]))[0]+str(ord(str(pin1)[-1]))[-1]+"S"+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1]
+ ident = ident.strip(" ")
+ wire_info.append({
+ 'Identifier': ident,
+ 'End 1': "Splice",
+ 'Type 1': "Crimp Splice",
+ 'Pin 1': "-",
+ 'Length': wires[bundle]['length'],
+ 'Color': wires[bundle]['colors'][x],
+ 'Gauge': wires[bundle]['gauge'],
+ 'End 2': connector,
+ 'Type 2': con1type,
+ 'Pin 2': pin1,
+ 'Notes': notes,
+ })
# Create a DataFrame to display the data as a table
- wire_df = pd.DataFrame(wire_info, columns=['Identifier','End 1', 'Pin 1', 'Length', 'Color', 'Gauge', 'End 2', 'Pin 2', 'Notes'])
+ wire_df = pd.DataFrame(wire_info, columns=['Identifier','End 1','Type 1', 'Pin 1', 'Length', 'Color', 'Gauge', 'End 2','Type 2', 'Pin 2', 'Notes'])
return wire_df
# Path to your WireViz YML file
-file_path = 'wireviz/Choppy_ECU_C1.yml'
+file_path = 'wireviz/Choppy_IB_1X.yml'
wire_table = parse_wireviz_yml(file_path)
# Display the table