diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index f481d284..0e82492f 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -25,11 +25,11 @@ class Connector: show_pincount: bool = True hide_disconnected_pins: bool = False autogenerate: bool = False + loops: List[Any] = field(default_factory=list) def __post_init__(self): self.ports_left = False self.ports_right = False - self.loops = [] self.visible_pins = {} if self.pincount is None: @@ -55,11 +55,12 @@ def __post_init__(self): if len(self.pinnumbers) != len(set(self.pinnumbers)): raise Exception('Pin numbers are not unique') - def loop(self, from_pin, to_pin): - self.loops.append((from_pin, to_pin)) - if self.hide_disconnected_pins: - self.visible_pins[from_pin] = True - self.visible_pins[to_pin] = True + for loop in self.loops: + # TODO: check that pins to connect actually exist + # TODO: allow using pin labels in addition to pin numbers, just like when defining regular connections + # TODO: include properties of wire used to create the loop + if len(loop) != 2: + raise Exception('Loops must be between exactly two pins!') def activate_pin(self, pin): self.visible_pins[pin] = True diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index bcc3d28c..a5e5d6ee 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -22,9 +22,6 @@ def add_connector(self, name, *args, **kwargs): def add_cable(self, name, *args, **kwargs): self.cables[name] = Cable(name, *args, **kwargs) - def loop(self, connector_name, from_pin, to_pin): - self.connectors[connector_name].loop(from_pin, to_pin) - def connect(self, from_name, from_pin, via_name, via_pin, to_name, to_pin): for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]): # check from and to connectors @@ -46,7 +43,6 @@ def connect(self, from_name, from_pin, via_name, via_pin, to_name, to_pin): from_pin = pin if name == to_name: to_pin = pin - # TODO: what happens with loops? if not pin in connector.pinnumbers: raise Exception(f'{name}:{pin} not found.')