Double arrows working
This commit is contained in:
parent
82fcfbe71e
commit
37cedb960e
@ -102,7 +102,6 @@ class Connector:
|
||||
show_name: Optional[bool] = None
|
||||
show_pincount: Optional[bool] = None
|
||||
hide_disconnected_pins: bool = False
|
||||
autogenerate: bool = False
|
||||
loops: List[List[Pin]] = field(default_factory=list)
|
||||
ignore_in_bom: bool = False
|
||||
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
||||
@ -134,7 +133,7 @@ class Connector:
|
||||
raise Exception('Pins are not unique')
|
||||
|
||||
if self.show_name is None:
|
||||
self.show_name = not self.autogenerate # hide auto-generated designators by default
|
||||
self.show_name = self.style != 'simple' # hide designators for simple connectors by default
|
||||
|
||||
if self.show_pincount is None:
|
||||
self.show_pincount = self.style != 'simple' # hide pincount for simple (1 pin) connectors by default
|
||||
|
||||
@ -28,8 +28,7 @@ class Harness:
|
||||
self.mini_bom_mode = True
|
||||
self.connectors = {}
|
||||
self.cables = {}
|
||||
self.mates_pin = []
|
||||
self.mates_component = []
|
||||
self.mates = []
|
||||
self._bom = [] # Internal Cache for generated bom
|
||||
self.additional_bom_items = []
|
||||
|
||||
@ -40,10 +39,10 @@ class Harness:
|
||||
self.cables[name] = Cable(name, *args, **kwargs)
|
||||
|
||||
def add_mate_pin(self, *args, **kwargs) -> None:
|
||||
self.mates_pin.append(MatePin(*args, **kwargs))
|
||||
self.mates.append(MatePin(*args, **kwargs))
|
||||
|
||||
def add_mate_component(self, *args, **kwargs) -> None:
|
||||
self.mates_component.append(MateComponent(*args, **kwargs))
|
||||
self.mates.append(MateComponent(*args, **kwargs))
|
||||
|
||||
def add_bom_item(self, item: dict) -> None:
|
||||
self.additional_bom_items.append(item)
|
||||
@ -123,7 +122,8 @@ class Harness:
|
||||
self.connectors[connection_color.from_name].ports_right = True
|
||||
if connection_color.to_port is not None: # connect to right
|
||||
self.connectors[connection_color.to_name].ports_left = True
|
||||
for mate in self.mates_pin:
|
||||
for mate in self.mates:
|
||||
if isinstance(mate, MatePin):
|
||||
self.connectors[mate.from_name].ports_right = True
|
||||
self.connectors[mate.from_name].activate_pin(mate.from_port)
|
||||
self.connectors[mate.to_name].ports_left = True
|
||||
@ -349,17 +349,27 @@ class Harness:
|
||||
dot.node(cable.name, label=f'<\n{html}\n>', shape='box',
|
||||
style='filled,dashed' if cable.category == 'bundle' else '', margin='0', fillcolor='white')
|
||||
|
||||
for mate in self.mates_pin:
|
||||
if mate.shape == '<--':
|
||||
dir = 'back'
|
||||
elif mate.shape == '-->':
|
||||
dir = 'forward'
|
||||
elif mate.shape == '<->':
|
||||
for mate in self.mates:
|
||||
if mate.shape[0] == '<' and mate.shape[-1] == '>':
|
||||
dir = 'both'
|
||||
dot.attr('edge', color='#000000', style='dashed', dir=dir)
|
||||
from_port = f':p{mate.from_port}r' if self.connectors[mate.from_name].style != 'simple' else ''
|
||||
elif mate.shape[0] == '<':
|
||||
dir = 'back'
|
||||
elif mate.shape[-1] == '>':
|
||||
dir = 'forward'
|
||||
else:
|
||||
dir = 'none' # should not happen?
|
||||
|
||||
if isinstance(mate, MatePin):
|
||||
color = '#000000'
|
||||
elif isinstance(mate, MateComponent):
|
||||
color = '#000000:#ffffff:#000000'
|
||||
else:
|
||||
raise Exception(f'{mate} is an unknown mate')
|
||||
|
||||
dot.attr('edge', color=color, style='dashed', dir=dir)
|
||||
from_port = f':p{mate.from_port}r' if isinstance(mate, MatePin) and self.connectors[mate.from_name].style != 'simple' else ''
|
||||
code_from = f'{mate.from_name}{from_port}:e'
|
||||
to_port = f':p{mate.to_port}l' if self.connectors[mate.to_name].style != 'simple' else ''
|
||||
to_port = f':p{mate.to_port}l' if isinstance(mate, MatePin) and self.connectors[mate.to_name].style != 'simple' else ''
|
||||
code_to = f'{mate.to_name}{to_port}:w'
|
||||
print(mate, '---', code_from, '---', code_to)
|
||||
dot.edge(code_from, code_to)
|
||||
|
||||
@ -186,6 +186,9 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
||||
print(' ', designator, 'is a new cable instance of type', template)
|
||||
harness.add_cable(name = designator, **template_cables[template])
|
||||
|
||||
elif designator in arrows:
|
||||
print(f' {template} is an arrow')
|
||||
|
||||
else:
|
||||
print(f' Template {template} not found, neither in connectors nor in cables')
|
||||
|
||||
@ -195,9 +198,9 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
||||
print(connection_set)
|
||||
|
||||
# actually connect components using connection list
|
||||
for index_connection, connection in enumerate(connection_set):
|
||||
print(f' connection ic {index_connection}', connection)
|
||||
for index_item, item in enumerate(connection):
|
||||
for index_entry, entry in enumerate(connection_set):
|
||||
print(f' entry ie {index_entry}', entry)
|
||||
for index_item, item in enumerate(entry):
|
||||
print(f' item ii {index_item}', item)
|
||||
designator = list(item.keys())[0]
|
||||
if designator in harness.cables:
|
||||
@ -206,35 +209,37 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
||||
from_name = None
|
||||
from_pin = None
|
||||
else:
|
||||
from_name = list(connection_set[index_connection][index_item-1].keys())[0]
|
||||
from_pin = connection_set[index_connection][index_item-1][from_name]
|
||||
from_name = list(connection_set[index_entry][index_item-1].keys())[0]
|
||||
from_pin = connection_set[index_entry][index_item-1][from_name]
|
||||
via_name = designator
|
||||
via_pin = item[designator]
|
||||
if index_item == len(connection) - 1: # list ends with a cable, no connector to join on right side
|
||||
if index_item == len(entry) - 1: # list ends with a cable, no connector to join on right side
|
||||
to_name = None
|
||||
to_pin = None
|
||||
else:
|
||||
to_name = list(connection_set[index_connection][index_item+1].keys())[0]
|
||||
to_pin = connection_set[index_connection][index_item+1][to_name]
|
||||
to_name = list(connection_set[index_entry][index_item+1].keys())[0]
|
||||
to_pin = connection_set[index_entry][index_item+1][to_name]
|
||||
print(' > connect ', from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
||||
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
||||
elif designator in arrows:
|
||||
print(f' - {designator} is an arrow')
|
||||
if index_item == 0: # list startess with an arrow
|
||||
raise Exception('An arrow cannot be at the start of a connection set')
|
||||
elif index_item == len(connection) - 1: # list ends with an arrow
|
||||
elif index_item == len(entry) - 1: # list ends with an arrow
|
||||
raise Exception('An arrow cannot be at the end of a connection set')
|
||||
|
||||
if '-' in designator: # join pin by pin
|
||||
from_name = list(connection_set[index_connection][index_item-1].keys())[0]
|
||||
from_pin = connection_set[index_connection][index_item-1][from_name]
|
||||
from_name = list(connection_set[index_entry][index_item-1].keys())[0]
|
||||
from_pin = connection_set[index_entry][index_item-1][from_name]
|
||||
via_name = designator
|
||||
via_pin = None
|
||||
to_name = list(connection_set[index_connection][index_item+1].keys())[0]
|
||||
to_pin = connection_set[index_connection][index_item+1][to_name]
|
||||
to_name = list(connection_set[index_entry][index_item+1].keys())[0]
|
||||
to_pin = connection_set[index_entry][index_item+1][to_name]
|
||||
if '-' in designator: # mate pin by pin
|
||||
print(f' Mate {from_name}:{from_pin} {designator} {to_name}:{to_pin}')
|
||||
# harness.connect(from_name, from_pin, designator, None, to_name, to_pin)
|
||||
harness.add_mate_pin(from_name, from_pin, to_name, to_pin, designator)
|
||||
elif '=' in designator and index_entry == 0: # mate two connectors as a whole
|
||||
print(f' Mate {from_name} {designator} {to_name} ({index_entry})')
|
||||
harness.add_mate_component(from_name, to_name, designator)
|
||||
elif '=' in designator: # mate connectors as a whole
|
||||
pass
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user