From 30ac03c46bd89bd1d5f3aba57f318049b7a48834 Mon Sep 17 00:00:00 2001 From: William Sutton Date: Fri, 28 Aug 2020 18:00:21 -0400 Subject: [PATCH 1/3] Adding support for wire length units Will also be editing dataclasses.py to add the support as well as defaulting units to meters if unpopulated. --- src/wireviz/Harness.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index af7946e3..be61911f 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -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, '' if cable.color else None], '', [html_line_breaks(cable.notes)]] @@ -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) From 67a25e390b4807bdf7d62d9b0ffd66ba6c729f43 Mon Sep 17 00:00:00 2001 From: William Sutton Date: Fri, 28 Aug 2020 18:02:14 -0400 Subject: [PATCH 2/3] Add support for units to wire lengths. Part 2 Will also be editing harness.py to add the support as well as defaulting units to meters if unpopulated. --- src/wireviz/DataClasses.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 6b3b1e36..4fba6e53 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -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 @@ -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 From 32cb73b483894a7022f4f5b6aeab8146848b951a Mon Sep 17 00:00:00 2001 From: Steve Traugott Date: Mon, 5 Oct 2020 00:26:38 -0700 Subject: [PATCH 3/3] add length_unit - partial fix for #7 - based on and closes #161 and #162 --- src/wireviz/DataClasses.py | 6 +++--- src/wireviz/Harness.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 4fba6e53..750f7156 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -88,7 +88,7 @@ class Cable: gauge_unit: Optional[str] = None show_equiv: bool = False length: float = 0 - lengthunit: Optional[str] = None + length_unit: Optional[str] = None color: Optional[str] = None wirecount: Optional[int] = None shield: bool = False @@ -120,8 +120,8 @@ 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.length_unit is None: #Default wire length units to meters if left undeclared + self.length_unit = 'm' if self.wirecount: # number of wires explicitly defined if self.colors: # use custom color palette (partly or looped if needed) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index be61911f..f1b5fa14 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -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} {cable.lengthunit}' if cable.length > 0 else None, + f'{cable.length} {cable.length_unit}' if cable.length > 0 else None, cable.color, '' if cable.color else None], '', [html_line_breaks(cable.notes)]] @@ -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': shared.lengthunit, 'designators': designators, + item = {'item': name, 'qty': round(total_length, 3), 'unit': shared.length_unit, 'designators': designators, 'manufacturer': remove_line_breaks(shared.manufacturer), 'mpn': remove_line_breaks(shared.mpn), 'pn': shared.pn} bom_cables.append(item) # bundles (ignores wirecount)