Add shield parameter to BOM generation
This commit is contained in:
parent
19f0a82544
commit
a8b9fc03c7
@ -284,20 +284,21 @@ class Harness:
|
|||||||
|
|
||||||
bom = bom + '\n'
|
bom = bom + '\n'
|
||||||
# list cables
|
# list cables
|
||||||
bom = bom + 'Gauge\tUnit\tWirecount\tTotal length\tQty\tDesignators\n'
|
bom = bom + 'Gauge\tUnit\tWirecount\tShield\tTotal length\tQty\tDesignators\n'
|
||||||
bom = bom + '---\t---\t---\t---\t---\t---\n'
|
bom = bom + '---\t---\t---\t---\t---\t---\t---\n'
|
||||||
gauges = Counter([v.gauge_and_unit for v in self.cables.values()])
|
gauges = Counter([v.gauge_and_unit for v in self.cables.values()])
|
||||||
for gauge in gauges.keys():
|
for gauge in gauges.keys():
|
||||||
wirecounts = Counter([v.wirecount for v in self.cables.values() if v.gauge_and_unit == gauge])
|
wirecounts_and_shields = Counter([v.wirecount_and_shield for v in self.cables.values() if v.gauge_and_unit == gauge])
|
||||||
for wirecount in wirecounts.keys():
|
for wirecount_and_shield in wirecounts_and_shields.keys():
|
||||||
# print(' ', gauge, wirecount, ':', wirecounts[wirecount])
|
# print(' ', gauge, wirecount, ':', wirecounts[wirecount])
|
||||||
lengths = [v.length for v in self.cables.values() if v.gauge_and_unit == gauge and v.wirecount == wirecount]
|
lengths = [v.length for v in self.cables.values() if v.gauge_and_unit == gauge and v.wirecount_and_shield == wirecount_and_shield]
|
||||||
designators = [k for k,v in self.cables.items() if v.gauge_and_unit == gauge and v.wirecount == wirecount]
|
designators = [k for k,v in self.cables.items() if v.gauge_and_unit == gauge and v.wirecount_and_shield == wirecount_and_shield]
|
||||||
# print(' ', 'Lengths:', lengths)
|
# print(' ', 'Lengths:', lengths)
|
||||||
# print(' ', 'Total lengths:', sum(lengths))
|
# print(' ', 'Total lengths:', sum(lengths))
|
||||||
bom = bom + '{gauge}\t{gauge_unit}\t{wirecount}\t{len_total}\t{qty}\t{designators}\n'.format(gauge=gauge[0],
|
bom = bom + '{gauge}\t{gauge_unit}\t{wirecount}\t{shield}\t{len_total}\t{qty}\t{designators}\n'.format(gauge=gauge[0],
|
||||||
gauge_unit=gauge[1],
|
gauge_unit=gauge[1],
|
||||||
wirecount=wirecount,
|
wirecount=wirecount_and_shield[0],
|
||||||
|
shield=wirecount_and_shield[1],
|
||||||
len_total=round(sum(lengths),3),
|
len_total=round(sum(lengths),3),
|
||||||
qty=len(lengths),
|
qty=len(lengths),
|
||||||
designators=', '.join(designators))
|
designators=', '.join(designators))
|
||||||
@ -367,6 +368,7 @@ class Cable:
|
|||||||
else:
|
else:
|
||||||
pass # gauge not specified
|
pass # gauge not specified
|
||||||
|
|
||||||
|
# for BOM generation
|
||||||
self.gauge_and_unit = (self.gauge, self.gauge_unit)
|
self.gauge_and_unit = (self.gauge, self.gauge_unit)
|
||||||
|
|
||||||
|
|
||||||
@ -390,12 +392,14 @@ class Cable:
|
|||||||
self.colors = self.colors * int(m)
|
self.colors = self.colors * int(m)
|
||||||
# cut off excess after looping
|
# cut off excess after looping
|
||||||
self.colors = self.colors[:self.wirecount]
|
self.colors = self.colors[:self.wirecount]
|
||||||
|
|
||||||
else: # wirecount implicit in length of color list
|
else: # wirecount implicit in length of color list
|
||||||
if not self.colors:
|
if not self.colors:
|
||||||
raise Exception('Unknown number of wires. Must specify wirecount or colors (implicit length)')
|
raise Exception('Unknown number of wires. Must specify wirecount or colors (implicit length)')
|
||||||
self.wirecount = len(self.colors)
|
self.wirecount = len(self.colors)
|
||||||
|
|
||||||
|
# for BOM generation
|
||||||
|
self.wirecount_and_shield = (self.wirecount, self.shield)
|
||||||
|
|
||||||
def connect(self, from_name, from_pin, via_pin, to_name, to_pin):
|
def connect(self, from_name, from_pin, via_pin, to_name, to_pin):
|
||||||
from_pin = int2tuple(from_pin)
|
from_pin = int2tuple(from_pin)
|
||||||
via_pin = int2tuple(via_pin)
|
via_pin = int2tuple(via_pin)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user