Add support for wire length units
Based on #161, #162, #171. Co-authored-by: stevegt <stevegt@t7a.org> Co-authored-by: kvid <kvid@users.noreply.github.com>
This commit is contained in:
parent
96bd121403
commit
dec64abaf5
@ -176,6 +176,7 @@ class Cable:
|
|||||||
gauge_unit: Optional[str] = None
|
gauge_unit: Optional[str] = None
|
||||||
show_equiv: bool = False
|
show_equiv: bool = False
|
||||||
length: float = 0
|
length: float = 0
|
||||||
|
length_unit: Optional[str] = None
|
||||||
color: Optional[Color] = None
|
color: Optional[Color] = None
|
||||||
wirecount: Optional[int] = None
|
wirecount: Optional[int] = None
|
||||||
shield: Union[bool, Color] = False
|
shield: Union[bool, Color] = False
|
||||||
@ -215,6 +216,9 @@ class Cable:
|
|||||||
|
|
||||||
self.connections = []
|
self.connections = []
|
||||||
|
|
||||||
|
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.wirecount: # number of wires explicitly defined
|
||||||
if self.colors: # use custom color palette (partly or looped if needed)
|
if self.colors: # use custom color palette (partly or looped if needed)
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -203,7 +203,7 @@ class Harness:
|
|||||||
f'{cable.wirecount}x' if cable.show_wirecount else None,
|
f'{cable.wirecount}x' if cable.show_wirecount else None,
|
||||||
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
|
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
|
||||||
'+ S' if cable.shield else None,
|
'+ S' if cable.shield else None,
|
||||||
f'{cable.length} m' if cable.length > 0 else None,
|
f'{cable.length} {cable.length_unit}' if cable.length > 0 else None,
|
||||||
cable.color, html_colorbar(cable.color)],
|
cable.color, html_colorbar(cable.color)],
|
||||||
'<!-- wire table -->',
|
'<!-- wire table -->',
|
||||||
[html_image(cable.image)],
|
[html_image(cable.image)],
|
||||||
|
|||||||
@ -67,7 +67,7 @@ def generate_bom(harness):
|
|||||||
+ (f' x {cable.gauge} {cable.gauge_unit}' if cable.gauge else ' wires')
|
+ (f' x {cable.gauge} {cable.gauge_unit}' if cable.gauge else ' wires')
|
||||||
+ (' shielded' if cable.shield else ''))
|
+ (' shielded' if cable.shield else ''))
|
||||||
bom_entries.append({
|
bom_entries.append({
|
||||||
'item': description, 'qty': cable.length, 'unit': 'm', 'designators': cable.name if cable.show_name else None,
|
'item': description, 'qty': cable.length, 'unit': cable.length_unit, 'designators': cable.name if cable.show_name else None,
|
||||||
'manufacturer': cable.manufacturer, 'mpn': cable.mpn, 'pn': cable.pn
|
'manufacturer': cable.manufacturer, 'mpn': cable.mpn, 'pn': cable.pn
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
@ -78,7 +78,7 @@ def generate_bom(harness):
|
|||||||
+ (f', {cable.gauge} {cable.gauge_unit}' if cable.gauge else '')
|
+ (f', {cable.gauge} {cable.gauge_unit}' if cable.gauge else '')
|
||||||
+ (f', {color}' if color else ''))
|
+ (f', {color}' if color else ''))
|
||||||
bom_entries.append({
|
bom_entries.append({
|
||||||
'item': description, 'qty': cable.length, 'unit': 'm', 'designators': cable.name if cable.show_name else None,
|
'item': description, 'qty': cable.length, 'unit': cable.length_unit, 'designators': cable.name if cable.show_name else None,
|
||||||
'manufacturer': index_if_list(cable.manufacturer, index),
|
'manufacturer': index_if_list(cable.manufacturer, index),
|
||||||
'mpn': index_if_list(cable.mpn, index), 'pn': index_if_list(cable.pn, index)
|
'mpn': index_if_list(cable.mpn, index), 'pn': index_if_list(cable.pn, index)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user