Rename num_pins to pincount

This commit is contained in:
Daniel Rojas 2020-06-13 15:40:21 +02:00
parent 75e1c119d4
commit 5bff36d4c4
3 changed files with 15 additions and 15 deletions

View File

@ -2,7 +2,7 @@ nodes:
X1: X1:
type: Molex KK 254 # more information type: Molex KK 254 # more information
gender: female gender: female
pinout: [GND, VCC, RX, TX] # num_pins is implicit in pinout pinout: [GND, VCC, RX, TX] # pincount is implicit in pinout
X2: X2:
type: Molex KK 254 type: Molex KK 254
gender: female gender: female

View File

@ -2,11 +2,11 @@
# X1: # X1:
# type: D-Sub # type: D-Sub
# gender: female # gender: female
# num_pins: 4 # pincount: 4
# X2: # X2:
# type: Molex KK 254 # type: Molex KK 254
# gender: female # gender: female
# num_pins: 3 # pincount: 3
wires: wires:
W1: W1:
@ -21,7 +21,7 @@ ferrules:
ferrule_crimp: ferrule_crimp:
type: crimp type: crimp
show_name: false show_name: false
show_num_pins: false show_pincount: false
connections: connections:
- -

View File

@ -129,7 +129,7 @@ class Harness:
# a = attributes # a = attributes
a = [n.type, a = [n.type,
n.gender, n.gender,
'{}-pin'.format(len(n.pinout)) if n.show_num_pins else ''] '{}-pin'.format(len(n.pinout)) if n.show_pincount else '']
# p = pinout # p = pinout
p = [[],[],[]] p = [[],[],[]]
p[1] = list(n.pinout) p[1] = list(n.pinout)
@ -272,11 +272,11 @@ class Harness:
for gender in genders.keys(): for gender in genders.keys():
# print(' ', type, gender, '({})'.format(genders[gender])) # print(' ', type, gender, '({})'.format(genders[gender]))
# print(keys) # print(keys)
pincounts = Counter([v.num_pins for v in self.nodes.values() if v.type == type and v.gender == gender]) pincounts = Counter([v.pincount for v in self.nodes.values() if v.type == type and v.gender == gender])
# print(' ', 'Pincounts:', pincounts) # print(' ', 'Pincounts:', pincounts)
for pincount in pincounts.keys(): for pincount in pincounts.keys():
# print(' ', type, gender, pincount, 'pins :', pincounts[pincount]) # print(' ', type, gender, pincount, 'pins :', pincounts[pincount])
designators = [k for k,v in self.nodes.items() if v.type == type and v.gender == gender and v.num_pins == pincount] designators = [k for k,v in self.nodes.items() if v.type == type and v.gender == gender and v.pincount == pincount]
bom = bom + '{type}\t{gender}\t{pincount}\t{qty}\t{designators}\n'.format(type=type, gender=gender, pincount=pincount, qty=pincounts[pincount], designators=', '.join(designators)) bom = bom + '{type}\t{gender}\t{pincount}\t{qty}\t{designators}\n'.format(type=type, gender=gender, pincount=pincount, qty=pincounts[pincount], designators=', '.join(designators))
bom = bom + '\n' bom = bom + '\n'
@ -304,12 +304,12 @@ class Node:
category: str = None category: str = None
type: str = None type: str = None
gender: str = None gender: str = None
num_pins: int = None pincount: int = None
notes: str = None notes: str = None
pinout: List[Any] = field(default_factory=list) pinout: List[Any] = field(default_factory=list)
color: str = None color: str = None
show_name: bool = True show_name: bool = True
show_num_pins: bool = True show_pincount: bool = True
def __post_init__(self): def __post_init__(self):
self.ports_left = False self.ports_left = False
@ -317,14 +317,14 @@ class Node:
self.loops = [] self.loops = []
if self.pinout: if self.pinout:
if self.num_pins is not None: if self.pincount is not None:
raise Exception('You cannot specify both pinout and num_pins') raise Exception('You cannot specify both pinout and pincount')
else: else:
self.num_pins = len(self.pinout) self.pincount = len(self.pinout)
else: else:
if not self.num_pins: if not self.pincount:
self.num_pins = 1 self.pincount = 1
self.pinout = ['',] * self.num_pins self.pinout = ['',] * self.pincount
def loop(self, from_pin, to_pin): def loop(self, from_pin, to_pin):
self.loops.append((from_pin, to_pin)) self.loops.append((from_pin, to_pin))