From 02a800abef3f35bdc4f8bbcafd9f50309a7cbe17 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Thu, 14 Oct 2021 18:03:18 +0200 Subject: [PATCH] Fix bug of arrows using the wrong port IDs --- src/wireviz/Harness.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 1233be78..1b01fa0f 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -40,11 +40,13 @@ def add_connector(self, name: str, *args, **kwargs) -> None: def add_cable(self, name: str, *args, **kwargs) -> None: self.cables[name] = Cable(name, *args, **kwargs) - def add_mate_pin(self, *args, **kwargs) -> None: - self.mates.append(MatePin(*args, **kwargs)) + def add_mate_pin(self, from_name, from_pin, to_name, to_pin, arrow_type) -> None: + from_pin_id = self.connectors[from_name].pins.index(from_pin) + to_pin_id = self.connectors[to_name].pins.index(to_pin) + self.mates.append(MatePin(from_name, from_pin_id, to_name, to_pin_id, arrow_type)) - def add_mate_component(self, *args, **kwargs) -> None: - self.mates.append(MateComponent(*args, **kwargs)) + def add_mate_component(self, from_name, to_name, arrow_type) -> None: + self.mates.append(MateComponent(from_name, to_name, arrow_type)) def add_bom_item(self, item: dict) -> None: self.additional_bom_items.append(item) @@ -447,9 +449,9 @@ def typecheck(name: str, value: Any, expect: type) -> None: 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 '' + from_port = f':p{mate.from_port+1}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 isinstance(mate, MatePin) and self.connectors[mate.to_name].style != 'simple' else '' + to_port = f':p{mate.to_port+1}l' if isinstance(mate, MatePin) and self.connectors[mate.to_name].style != 'simple' else '' code_to = f'{mate.to_name}{to_port}:w' dot.edge(code_from, code_to)