Skip to content

Commit

Permalink
Add support for wire length units
Browse files Browse the repository at this point in the history
  • Loading branch information
zombielinux authored and kvid committed Oct 5, 2020
1 parent df90d83 commit 94f752d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Cable:
gauge_unit: Optional[str] = None
show_equiv: bool = False
length: float = 0
lengthunit: Optional[str] = None
color: Optional[str] = None
wirecount: Optional[int] = None
shield: bool = False
Expand Down Expand Up @@ -119,6 +120,9 @@ def __post_init__(self):

self.connections = []

if self.lengthunit is None: #Default wire length units to meters if left undeclared
self.lengthunit = 'm'

if self.wirecount: # number of wires explicitly defined
if self.colors: # use custom color palette (partly or looped if needed)
pass
Expand Down
4 changes: 2 additions & 2 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def create_graph(self) -> Graph:
f'{cable.wirecount}x' if cable.show_wirecount else None,
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
'+ S' if cable.shield else None,
f'{cable.length} m' if cable.length > 0 else None,
f'{cable.length} {cable.lengthunit}' if cable.length > 0 else None,
cable.color, '<!-- colorbar -->' if cable.color else None],
'<!-- wire table -->',
[html_line_breaks(cable.notes)]]
Expand Down Expand Up @@ -365,7 +365,7 @@ def bom(self):
gauge_name = f' x {shared.gauge} {shared.gauge_unit}' if shared.gauge else ' wires'
shield_name = ' shielded' if shared.shield else ''
name = f'Cable{cable_type}, {shared.wirecount}{gauge_name}{shield_name}'
item = {'item': name, 'qty': round(total_length, 3), 'unit': 'm', 'designators': designators,
item = {'item': name, 'qty': round(total_length, 3), 'unit': shared.lengthunit, 'designators': designators,
'manufacturer': remove_line_breaks(shared.manufacturer), 'mpn': remove_line_breaks(shared.mpn), 'pn': shared.pn}
bom_cables.append(item)
# bundles (ignores wirecount)
Expand Down

0 comments on commit 94f752d

Please sign in to comment.