Skip to content

Commit

Permalink
Fix bug of arrows using the wrong port IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Oct 14, 2021
1 parent 50ea7f5 commit 02a800a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 02a800a

Please sign in to comment.