Change order of arguments in wire..connect()
squash
This commit is contained in:
parent
517cba4863
commit
544e009bcb
@ -6,7 +6,7 @@ h.add_cable('W1', mm2=0.25, length=0.2, show_name=True, show_pinout=True, num_wi
|
|||||||
h.add_node('X1', type='D-Sub', gender='female', pinout=('DCD','RX','TX','DTR','GND','DSR','RTS','CTS','RI'))
|
h.add_node('X1', type='D-Sub', gender='female', pinout=('DCD','RX','TX','DTR','GND','DSR','RTS','CTS','RI'))
|
||||||
h.add_node('X2', type='Molex KK 254', gender='female', pinout=('GND','RX','TX','NC','OUT','IN'))
|
h.add_node('X2', type='Molex KK 254', gender='female', pinout=('GND','RX','TX','NC','OUT','IN'))
|
||||||
# Option 1: define wires and shield in one line
|
# Option 1: define wires and shield in one line
|
||||||
h.connect('W1','X1',(5,2,3,5),(1,2,3,'s'),'X2',(1,3,2,None))
|
h.connect('X1',(5,2,3,5),'W1',(1,2,3,'s'),'X2',(1,3,2,None))
|
||||||
h.loop('X2', 5, 6)
|
h.loop('X2', 5, 6)
|
||||||
# Option 2: define wires and shield separately
|
# Option 2: define wires and shield separately
|
||||||
# Harness.objects['W1'].connect('X1',(5,2,3),'auto','X2',(1,3,2)) # wires
|
# Harness.objects['W1'].connect('X1',(5,2,3),'auto','X2',(1,3,2)) # wires
|
||||||
|
|||||||
@ -23,9 +23,9 @@ h.add_cable('W1', mm2=0.14, show_equiv=True, length=0.2, colors=COLORS_I2C, show
|
|||||||
h.add_cable('W2', mm2=0.14, show_equiv=True, length=0.2, colors=COLORS_I2C, show_name=False)
|
h.add_cable('W2', mm2=0.14, show_equiv=True, length=0.2, colors=COLORS_I2C, show_name=False)
|
||||||
h.add_cable('W3', mm2=0.14, show_equiv=True, length=0.2, colors=('BK','BU','OG','VT'), show_name=False)
|
h.add_cable('W3', mm2=0.14, show_equiv=True, length=0.2, colors=('BK','BU','OG','VT'), show_name=False)
|
||||||
h.add_cable('W4', mm2=0.5, show_equiv=True, length=0.35, colors=('BK','RD'), show_name=False)
|
h.add_cable('W4', mm2=0.5, show_equiv=True, length=0.35, colors=('BK','RD'), show_name=False)
|
||||||
h.connect('W1','X1',(1,2,3,4),'auto','X2','auto')
|
h.connect('X1',(1,2,3,4),'W1','auto','X2','auto')
|
||||||
h.connect('W2','X1',(1,2,3,4),'auto','X3','auto')
|
h.connect('X1',(1,2,3,4),'W2','auto','X3','auto')
|
||||||
h.connect('W3','X1',(1,5,6,7),'auto','X4',(1,3,4,5))
|
h.connect('X1',(1,5,6,7),'W3','auto','X4',(1,3,4,5))
|
||||||
h.connect_all_straight('W4','X5','X4')
|
h.connect_all_straight('W4','X5','X4')
|
||||||
|
|
||||||
h.output(filename='output', format=('png','svg'), view=False)
|
h.output(filename='output', format=('png','svg'), view=False)
|
||||||
|
|||||||
@ -66,8 +66,8 @@ class Harness:
|
|||||||
def loop(self, node_name, from_pin, to_pin):
|
def loop(self, node_name, from_pin, to_pin):
|
||||||
self.nodes[node_name].loop(from_pin, to_pin)
|
self.nodes[node_name].loop(from_pin, to_pin)
|
||||||
|
|
||||||
def connect(self, cable_name, from_name, from_pin, via, to_name, to_pin):
|
def connect(self, from_name, from_pin, via_name, via_pin, to_name, to_pin):
|
||||||
self.cables[cable_name].connect(from_name, from_pin, via, to_name, to_pin)
|
self.cables[via_name].connect(from_name, from_pin, via_pin, to_name, to_pin)
|
||||||
|
|
||||||
def connect_all_straight(self, cable_name, from_name, to_name):
|
def connect_all_straight(self, cable_name, from_name, to_name):
|
||||||
self.cables[cable_name].connect_all_straight(from_name, to_name)
|
self.cables[cable_name].connect_all_straight(from_name, to_name)
|
||||||
@ -247,14 +247,14 @@ class Cable:
|
|||||||
cc = cc * int(m)
|
cc = cc * int(m)
|
||||||
self.colors = cc[:n]
|
self.colors = cc[:n]
|
||||||
|
|
||||||
def connect(self, from_name, from_pin, via, to_name, to_pin):
|
def connect(self, from_name, from_pin, via_pin, to_name, to_pin):
|
||||||
from_pin = int2tuple(from_pin)
|
from_pin = int2tuple(from_pin)
|
||||||
via = int2tuple(via)
|
via_pin = int2tuple(via_pin)
|
||||||
to_pin = int2tuple(to_pin)
|
to_pin = int2tuple(to_pin)
|
||||||
if len(from_pin) != len(to_pin):
|
if len(from_pin) != len(to_pin):
|
||||||
raise Exception('from_pin must have the same number of elements as to_pin')
|
raise Exception('from_pin must have the same number of elements as to_pin')
|
||||||
for i, x in enumerate(from_pin):
|
for i, x in enumerate(from_pin):
|
||||||
self.connections.append((from_name, from_pin[i], via[i], to_name, to_pin[i]))
|
self.connections.append((from_name, from_pin[i], via_pin[i], to_name, to_pin[i]))
|
||||||
|
|
||||||
def connect_all_straight(self, from_name, to_name):
|
def connect_all_straight(self, from_name, to_name):
|
||||||
self.connect(from_name, 'auto', 'auto', to_name, 'auto')
|
self.connect(from_name, 'auto', 'auto', to_name, 'auto')
|
||||||
|
|||||||
@ -75,7 +75,7 @@ for con in conlist:
|
|||||||
raise Exception('List length mismatch')
|
raise Exception('List length mismatch')
|
||||||
|
|
||||||
for (from_pin, via_pin, to_pin) in zip(from_pins, via_pins, to_pins):
|
for (from_pin, via_pin, to_pin) in zip(from_pins, via_pins, to_pins):
|
||||||
h.connect(via_name, from_name, from_pin, via_pin, to_name, to_pin)
|
h.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
||||||
|
|
||||||
elif len(con) == 2:
|
elif len(con) == 2:
|
||||||
|
|
||||||
@ -102,9 +102,9 @@ for con in conlist:
|
|||||||
if n_w == True or w_n == True:
|
if n_w == True or w_n == True:
|
||||||
for (from_pin, to_pin) in zip(from_pins, to_pins):
|
for (from_pin, to_pin) in zip(from_pins, to_pins):
|
||||||
if n_w:
|
if n_w:
|
||||||
h.connect(to_name, from_name, from_pin, to_pin, None, None)
|
h.connect(from_name, from_pin, to_name, to_pin, None, None)
|
||||||
else: # w_n
|
else: # w_n
|
||||||
h.connect(from_name, None, None, from_pin, to_name, to_pin)
|
h.connect(None, None, from_name, from_pin, to_name, to_pin)
|
||||||
elif n_n == True:
|
elif n_n == True:
|
||||||
con_name = list(con[0].keys())[0]
|
con_name = list(con[0].keys())[0]
|
||||||
from_pins = expand(con[0][from_name])
|
from_pins = expand(con[0][from_name])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user