From 653597a0e98975b671082d36e04cb9b0b20718b7 Mon Sep 17 00:00:00 2001 From: Andreas Nordin Date: Wed, 24 Jun 2020 16:52:07 +0200 Subject: [PATCH] Add 'specified_cable' field for BOM generation There is no obvious way of specifying exactly which cable type (manufacturer, part number) to use for a given cable, which is useful for BOM purposes. Add a 'specified_cable' field to the Cable class to remedy this, and render it both in the graph and the BOM. --- src/wireviz/wireviz.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index fa03b9f..e60a740 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -128,6 +128,8 @@ class Harness: html = html + '' # name+attributes table if c.show_name: html = html + ''.format(colspan=len(a), name=c.name) + if c.specified_cable: + html = html + ''.format(colspan=len(a), specified=c.specified_cable) html = html + '' # attribute row for attrib in a: html = html + ''.format(attrib=attrib) @@ -264,9 +266,11 @@ class Harness: designators = list(items.keys()) designators.sort() total_length = sum(i.length for i in items.values()) - name = 'Cable, {wirecount}{gauge}{shield}'.format(wirecount = shared.wirecount, + name = 'Cable, {specified_cable}{wirecount}{gauge}{shield}'.format(wirecount = shared.wirecount, gauge = ' x {} {}'.format(shared.gauge, shared.gauge_unit) if shared.gauge else ' wires', - shield = ' shielded' if shared.shield else '') + shield = ' shielded' if shared.shield else '', + specified_cable = '{}, '.format(shared.specified_cable) if shared.specified_cable else '') + item = {'item': name, 'qty': round(total_length, 3), 'unit': 'm', 'designators': designators} bom_cables.append(item) # bundles (ignores wirecount) @@ -357,6 +361,7 @@ class Cable: length: float = 0 wirecount: int = None shield: bool = False + specified_cable: str = None notes: str = None colors: List[Any] = field(default_factory=list) color_code: str = None
{name}
{specified}
{attrib}