diff --git a/examples/demo01.yml b/examples/demo01.yml index 6538d3d..9918129 100644 --- a/examples/demo01.yml +++ b/examples/demo01.yml @@ -13,7 +13,7 @@ wires: mm2: 0.25 length: 0.2 color_code: DIN - num_wires: 3 + wirecount: 3 shield: true connections: diff --git a/examples/ex01.yml b/examples/ex01.yml index 3d190c3..77f5ea8 100644 --- a/examples/ex01.yml +++ b/examples/ex01.yml @@ -11,7 +11,7 @@ nodes: wires: W1: color_code: IEC # auto-color wires based on a standard - num_wires: 4 # need to specify number of wires explicitly when using a color code + wirecount: 4 # need to specify number of wires explicitly when using a color code mm2: 0.25 # metric gauge, in mm^2 show_equiv: true # auto-calculate AWG equivalent from metric gauge length: 0.2 # length in m diff --git a/examples/ex03.yml b/examples/ex03.yml index c28f6b8..0356a28 100644 --- a/examples/ex03.yml +++ b/examples/ex03.yml @@ -15,8 +15,8 @@ nodes: wires: W1: type: bundle # bundles are routed together, but more loosely than normal cables - num_wires: 6 - colors: [BK, RD] # if number of items in color list is less than num_wires, loop colors + wirecount: 6 + colors: [BK, RD] # if number of items in color list is less than wirecount, loop colors mm2: 0.25 show_equiv: true length: 0.2 diff --git a/examples/ex04.yml b/examples/ex04.yml index 95af64e..826729c 100644 --- a/examples/ex04.yml +++ b/examples/ex04.yml @@ -14,7 +14,7 @@ wires: show_equiv: true length: 0.2 color_code: IEC - num_wires: 6 + wirecount: 6 type: bundle ferrules: diff --git a/readme.md b/readme.md index 0cf176b..8e94ebf 100644 --- a/readme.md +++ b/readme.md @@ -44,7 +44,7 @@ _Note_: WireViz is not designed to represent the complete wiring of a system. It mm2: 0.25 length: 0.2 color_code: DIN - num_wires: 3 + wirecount: 3 shield: true connections: diff --git a/src/wireviz.py b/src/wireviz.py index d258c1c..51c4710 100755 --- a/src/wireviz.py +++ b/src/wireviz.py @@ -158,7 +158,7 @@ class Harness: for k, c in self.cables.items(): # a = attributes - a = ['{}x'.format(len(c.colors)) if c.show_num_wires else '', + a = ['{}x'.format(len(c.colors)) if c.show_wirecount else '', '{} mm\u00B2{}'.format(c.mm2, ' ({} AWG)'.format(awg_equiv(c.mm2)) if c.show_equiv else '') if c.mm2 is not None else '', '{} AWG'.format(c.awg) if c.awg else '', '+ S' if c.shield else '', @@ -287,11 +287,11 @@ class Harness: mm2s = Counter([v.mm2 for v in self.cables.values()]) for mm2 in mm2s.keys(): # print(mm2, 'mm2', '({})'.format(mm2s[mm2])) - wirecounts = Counter([v.num_wires for v in self.cables.values() if v.mm2 == mm2]) + wirecounts = Counter([v.wirecount for v in self.cables.values() if v.mm2 == mm2]) for wirecount in wirecounts.keys(): # print(' ', mm2, wirecount, ':', wirecounts[wirecount]) - lengths = [v.length for v in self.cables.values() if v.mm2 == mm2 and v.num_wires == wirecount] - designators = [k for k,v in self.cables.items() if v.mm2 == mm2 and v.num_wires == wirecount] + lengths = [v.length for v in self.cables.values() if v.mm2 == mm2 and v.wirecount == wirecount] + designators = [k for k,v in self.cables.items() if v.mm2 == mm2 and v.wirecount == wirecount] # print(' ', 'Lengths:', lengths) # print(' ', 'Total lengths:', sum(lengths)) bom = bom + '{mm2}\t{wirecount}\t{len_total}\t{qty}\t{designators}\n'.format(mm2=mm2, wirecount=wirecount, len_total=round(sum(lengths),3), qty=len(lengths), designators=', '.join(designators)) @@ -337,21 +337,21 @@ class Cable: awg: int = None show_equiv: bool = False length: float = 0 - num_wires: int = None + wirecount: int = None shield: bool = False notes: str = None colors: List[Any] = field(default_factory=list) color_code: str = None show_name: bool = True show_pinout: bool = False - show_num_wires: bool = True + show_wirecount: bool = True def __post_init__(self): if self.mm2 and self.awg: raise Exception('You cannot define both mm2 and awg!') self.connections = [] - if self.num_wires: # 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) pass elif self.color_code: # use standard color palette (partly or looped if needed) @@ -359,19 +359,19 @@ class Cable: raise Exception('Unknown color code') self.colors = COLOR_CODES[self.color_code] else: # no colors defined, add dummy colors - self.colors = [''] * self.num_wires + self.colors = [''] * self.wirecount # make color code loop around if more wires than colors - if self.num_wires > len(self.colors): - m = self.num_wires // len(self.colors) + 1 + if self.wirecount > len(self.colors): + m = self.wirecount // len(self.colors) + 1 self.colors = self.colors * int(m) # cut off excess after looping - self.colors = self.colors[:self.num_wires] + self.colors = self.colors[:self.wirecount] - else: # num_wires implicit in length of color list + else: # wirecount implicit in length of color list if not self.colors: - raise Exception('Unknown number of wires. Must specify num_wires or colors (implicit length)') - self.num_wires = len(self.colors) + raise Exception('Unknown number of wires. Must specify wirecount or colors (implicit length)') + self.wirecount = len(self.colors) def connect(self, from_name, from_pin, via_pin, to_name, to_pin): from_pin = int2tuple(from_pin)