diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 3c678fd..d15b998 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -124,7 +124,8 @@ class Harness: elif cable.gauge_unit.upper() == 'AWG': awg_fmt = f' ({mm2_equiv(cable.gauge)} mm\u00B2)' - attributes = [f'{len(cable.colors)}x' if cable.show_wirecount else '', + attributes = [cable.type, + f'{len(cable.colors)}x' if cable.show_wirecount else '', f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else '', '+ S' if cable.shield else '', f'{cable.length} m' if cable.length > 0 else ''] @@ -273,7 +274,7 @@ class Harness: # cables # TODO: If category can have other non-empty values than 'bundle', maybe it should be part of item name? # Otherwise, it can be removed from the cable_group because it will allways be empty. - cable_group = lambda c: (c.category, c.gauge, c.gauge_unit, c.wirecount, c.shield) + cable_group = lambda c: (c.category, c.type, c.gauge, c.gauge_unit, c.wirecount, c.shield) groups = Counter([cable_group(v) for v in self.cables.values() if v.category != 'bundle']) for group in groups: items = {k: v for k, v in self.cables.items() if cable_group(v) == group} @@ -281,15 +282,16 @@ class Harness: designators = list(items.keys()) designators.sort() total_length = sum(i.length for i in items.values()) + cable_type = f', {shared.type}' if shared.type else '' gauge_name = f' x {shared.gauge} {shared.gauge_unit}'if shared.gauge else ' wires' shield_name = ' shielded' if shared.shield else '' - name = f'Cable, {shared.wirecount}{gauge_name}{shield_name}' + name = f'Cable{cable_type}, {shared.wirecount}{gauge_name}{shield_name}' item = {'item': name, 'qty': round(total_length, 3), 'unit': 'm', 'designators': designators} bom_cables.append(item) # bundles (ignores wirecount) wirelist = [] # list all cables again, since bundles are represented as wires internally, with the category='bundle' set - bundle_group = lambda b: (b.gauge, b.gauge_unit, b.length) + bundle_group = lambda b: (b.type, b.gauge, b.gauge_unit, b.length) # TODO: Why is b.lenght included? groups = Counter([bundle_group(v) for v in self.cables.values() if v.category == 'bundle']) for group in groups: items = {k: v for k, v in self.cables.items() if bundle_group(v) == group} @@ -297,10 +299,10 @@ class Harness: for bundle in items.values(): # add each wire from each bundle to the wirelist for color in bundle.colors: - wirelist.append({'gauge': shared.gauge, 'gauge_unit': shared.gauge_unit, + wirelist.append({'type': shared.type, 'gauge': shared.gauge, 'gauge_unit': shared.gauge_unit, 'length': shared.length, 'color': color, 'designator': bundle.name}) # join similar wires from all the bundles to a single BOM item - wire_group = lambda w: (w['gauge'], w['gauge_unit'], w['color']) + wire_group = lambda w: (w['type'], w['gauge'], w['gauge_unit'], w['color']) groups = Counter([wire_group(v) for v in wirelist]) for group in groups: items = [v for v in wirelist if wire_group(v) == group] @@ -310,9 +312,10 @@ class Harness: designators = list(dict.fromkeys(designators)) designators.sort() total_length = sum(i['length'] for i in items) + wire_type = f', {shared["type"]}' if shared['type'] else '' gauge_name = f', {shared["gauge"]} {shared["gauge_unit"]}' if shared['gauge'] else '' gauge_color = f', {shared["color"]}' if shared['color'] != '' else '' - name = f'Wire{gauge_name}{gauge_color}' + name = f'Wire{wire_type}{gauge_name}{gauge_color}' item = {'item': name, 'qty': round(total_length, 3), 'unit': 'm', 'designators': designators} bom_cables.append(item) bom_cables = sorted(bom_cables, key=lambda k: k['item']) # https://stackoverflow.com/a/73050