diff --git a/examples/demo01.bom.tsv b/examples/demo01.bom.tsv new file mode 100644 index 0000000..43f2d71 --- /dev/null +++ b/examples/demo01.bom.tsv @@ -0,0 +1,4 @@ +Item Qty Unit Designators +D-Sub, female, 9 pins 1 X1 +Molex KK 254, female, 3 pins 1 X2 +Cable 3 x 0.25 mm² shielded 0.2 m W1 diff --git a/examples/demo01.html b/examples/demo01.html new file mode 100644 index 0000000..f490520 --- /dev/null +++ b/examples/demo01.html @@ -0,0 +1,171 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +D-Sub + +female + +9-pin + +DCD + +RX + +TX + +DTR + +GND + +DSR + +RTS + +CTS + +RI + +1 + +2 + +3 + +4 + +5 + +6 + +7 + +8 + +9 + + + +W1 + + +W1 + +3x + +0.25 mm² + ++ S + +0.2 m +  +X1:5 +WH +X2:1 + + + +X1:2 +BN +X2:3 + + + +X1:1 +GN +X2:2 + + + +  +X1:5 +Shield + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +X2 + +X2 + +Molex KK 254 + +female + +3-pin + +1 + +2 + +3 + +GND + +RX + +TX + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
D-Sub, female, 9 pins1X1
Molex KK 254, female, 3 pins1X2
Cable 3 x 0.25 mm² shielded0.2mW1
\ No newline at end of file diff --git a/examples/demo01.yml b/examples/demo01.yml index 6538d3d..b125176 100644 --- a/examples/demo01.yml +++ b/examples/demo01.yml @@ -1,19 +1,19 @@ -nodes: +connectors: X1: type: D-Sub - gender: female + subtype: female pinout: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] X2: type: Molex KK 254 - gender: female + subtype: female pinout: [GND, RX, TX] -wires: +cables: W1: - mm2: 0.25 + gauge: 0.25 mm2 length: 0.2 color_code: DIN - num_wires: 3 + wirecount: 3 shield: true connections: diff --git a/examples/demo02.bom.tsv b/examples/demo02.bom.tsv new file mode 100644 index 0000000..5fe7ab1 --- /dev/null +++ b/examples/demo02.bom.tsv @@ -0,0 +1,13 @@ +Item Qty Unit Designators +Crimp ferrule, 0.25 mm² 2 +Molex KK 254, female, 4 pins 2 X2, X3 +Molex KK 254, female, 5 pins 1 X4 +Molex KK 254, female, 8 pins 1 X1 +Cable 2 x 0.25 mm² 0.3 m W4 +Wire 0.14 mm² BK 0.9 m W1, W2, W3 +Wire 0.14 mm² BU 0.3 m W3 +Wire 0.14 mm² GN 0.6 m W1, W2 +Wire 0.14 mm² OG 0.3 m W3 +Wire 0.14 mm² RD 0.6 m W1, W2 +Wire 0.14 mm² VT 0.3 m W3 +Wire 0.14 mm² YE 0.6 m W1, W2 diff --git a/examples/demo02.gv b/examples/demo02.gv index 04af751..fa19809 100644 --- a/examples/demo02.gv +++ b/examples/demo02.gv @@ -8,7 +8,26 @@ graph { X2 [label="X2|{Molex KK 254|female|4-pin}|{{1|2|3|4}|{GND|+5V|SCL|SDA}}"] X3 [label="X3|{Molex KK 254|female|4-pin}|{{1|2|3|4}|{GND|+5V|SCL|SDA}}"] X4 [label="X4|{Molex KK 254|female|5-pin}|{{1|2|3|4|5}|{GND|+12V|MISO|MOSI|SCK}}"] - X5 [label="X5|{Molex Micro-Fit|male|2-pin}|{{GND|+12V}|{1|2}}"] + F1 [label=< + + + + + +
Crimp ferrule, 0.25 mm²
+ + + > margin=0 orientation=180 shape=none style=filled] + F2 [label=< + + + + + +
Crimp ferrule, 0.25 mm²
+ + + > margin=0 orientation=180 shape=none style=filled] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w @@ -21,7 +40,7 @@ graph { edge [color="#000000:#00ff00:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=<
4x0.14 mm² (26 AWG)0.2 m
 
X1:1BKX2:1
X1:2RDX2:2
X1:3YEX2:3
X1:4GNX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W1 [label=<
W1
4x0.14 mm² (26 AWG)0.2 m
 
X1:1BKX2:1
X1:2RDX2:2
X1:3YEX2:3
X1:4GNX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w @@ -34,7 +53,7 @@ graph { edge [color="#000000:#00ff00:#000000"] X1:p4r:e -- W2:w4:w W2:w4:e -- X3:p4l:w - W2 [label=<
4x0.14 mm² (26 AWG)0.2 m
 
X1:1BKX3:1
X1:2RDX3:2
X1:3YEX3:3
X1:4GNX3:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W2 [label=<
W2
4x0.14 mm² (26 AWG)0.4 m
 
X1:1BKX3:1
X1:2RDX3:2
X1:3YEX3:3
X1:4GNX3:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W3:w1:w W3:w1:e -- X4:p1l:w @@ -47,12 +66,14 @@ graph { edge [color="#000000:#8000ff:#000000"] X1:p7r:e -- W3:w4:w W3:w4:e -- X4:p5l:w - W3 [label=<
4x0.14 mm² (26 AWG)0.2 m
 
X1:1BKX4:1
X1:5BUX4:3
X1:6OGX4:4
X1:7VTX4:5
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W3 [label=<
W3
4x0.14 mm² (26 AWG)0.3 m
 
X1:1BKX4:1
X1:5BUX4:3
X1:6OGX4:4
X1:7VTX4:5
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + edge [color="#000000:#000000:#000000"] + F1:e -- W4:w1:w + edge [color="#000000:#ff0000:#000000"] + F2:e -- W4:w2:w edge [color="#000000:#000000:#000000"] - X5:p1r:e -- W4:w1:w W4:w1:e -- X4:p1l:w edge [color="#000000:#ff0000:#000000"] - X5:p2r:e -- W4:w2:w W4:w2:e -- X4:p2l:w - W4 [label=<
2x0.5 mm² (21 AWG)0.35 m
 
X5:1BKX4:1
X5:2RDX4:2
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W4 [label=<
W4
2x0.25 mm² (24 AWG)0.3 m
 
BKX4:1
RDX4:2
 
> fillcolor=white margin=0 shape=box style=""] } diff --git a/examples/demo02.html b/examples/demo02.html new file mode 100644 index 0000000..25797b0 --- /dev/null +++ b/examples/demo02.html @@ -0,0 +1,499 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +Molex KK 254 + +female + +8-pin + +GND + ++5V + +SCL + +SDA + +MISO + +MOSI + +SCK + +N/C + +1 + +2 + +3 + +4 + +5 + +6 + +7 + +8 + + + +W1 + + +W1 + +4x + +0.14 mm² (26 AWG) + +0.2 m +  +X1:1 +BK +X2:1 + + + +X1:2 +RD +X2:2 + + + +X1:3 +YE +X2:3 + + + +X1:4 +GN +X2:4 + + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +W2 + + +W2 + +4x + +0.14 mm² (26 AWG) + +0.4 m +  +X1:1 +BK +X3:1 + + + +X1:2 +RD +X3:2 + + + +X1:3 +YE +X3:3 + + + +X1:4 +GN +X3:4 + + + +  + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +W3 + + +W3 + +4x + +0.14 mm² (26 AWG) + +0.3 m +  +X1:1 +BK +X4:1 + + + +X1:5 +BU +X4:3 + + + +X1:6 +OG +X4:4 + + + +X1:7 +VT +X4:5 + + + +  + + + +X1:e--W3:w + + + + + + +X1:e--W3:w + + + + + + +X1:e--W3:w + + + + + + +X1:e--W3:w + + + + + + +X2 + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + ++5V + +SCL + +SDA + + + +X3 + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + ++5V + +SCL + +SDA + + + +X4 + +X4 + +Molex KK 254 + +female + +5-pin + +1 + +2 + +3 + +4 + +5 + +GND + ++12V + +MISO + +MOSI + +SCK + + + +F1 + + Crimp ferrule, 0.25 mm²   +   + + + + +W4 + + +W4 + +2x + +0.25 mm² (24 AWG) + +0.3 m +  +BK +X4:1 + + + +RD +X4:2 + + + +  + + + +F1:e--W4:w + + + + + + +F2 + + Crimp ferrule, 0.25 mm²   +   + + + + +F2:e--W4:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Crimp ferrule, 0.25 mm²2
Molex KK 254, female, 4 pins2X2, X3
Molex KK 254, female, 5 pins1X4
Molex KK 254, female, 8 pins1X1
Cable 2 x 0.25 mm²0.3mW4
Wire 0.14 mm² BK0.9mW1, W2, W3
Wire 0.14 mm² BU0.3mW3
Wire 0.14 mm² GN0.6mW1, W2
Wire 0.14 mm² OG0.3mW3
Wire 0.14 mm² RD0.6mW1, W2
Wire 0.14 mm² VT0.3mW3
Wire 0.14 mm² YE0.6mW1, W2
\ No newline at end of file diff --git a/examples/demo02.png b/examples/demo02.png index 53e7923..3517f29 100644 Binary files a/examples/demo02.png and b/examples/demo02.png differ diff --git a/examples/demo02.svg b/examples/demo02.svg index 9c32c7f..60a0a9e 100644 --- a/examples/demo02.svg +++ b/examples/demo02.svg @@ -4,493 +4,495 @@ - - - + + + X1 - -X1 - -Molex KK 254 - -female - -8-pin - -GND - -+5V - -SCL - -SDA - -MISO - -MOSI - -SCK - -N/C - -1 - -2 - -3 - -4 - -5 - -6 - -7 - -8 + +X1 + +Molex KK 254 + +female + +8-pin + +GND + ++5V + +SCL + +SDA + +MISO + +MOSI + +SCK + +N/C + +1 + +2 + +3 + +4 + +5 + +6 + +7 + +8 - + W1 - - -4x - -0.14 mm² (26 AWG) - -0.2 m -  -X1:1 -BK -X2:1 - - - -X1:2 -RD -X2:2 - - - -X1:3 -YE -X2:3 - - - -X1:4 -GN -X2:4 - - - -  + + +W1 + +4x + +0.14 mm² (26 AWG) + +0.2 m +  +X1:1 +BK +X2:1 + + + +X1:2 +RD +X2:2 + + + +X1:3 +YE +X2:3 + + + +X1:4 +GN +X2:4 + + + +  X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + - + W2 - - -4x - -0.14 mm² (26 AWG) - -0.2 m -  -X1:1 -BK -X3:1 - - - -X1:2 -RD -X3:2 - - - -X1:3 -YE -X3:3 - - - -X1:4 -GN -X3:4 - - - -  + + +W2 + +4x + +0.14 mm² (26 AWG) + +0.4 m +  +X1:1 +BK +X3:1 + + + +X1:2 +RD +X3:2 + + + +X1:3 +YE +X3:3 + + + +X1:4 +GN +X3:4 + + + +  X1:e--W2:w - - - + + + X1:e--W2:w - - - + + + X1:e--W2:w - - - + + + X1:e--W2:w - - - + + + - + W3 - - -4x - -0.14 mm² (26 AWG) - -0.2 m -  -X1:1 -BK -X4:1 - - - -X1:5 -BU -X4:3 - - - -X1:6 -OG -X4:4 - - - -X1:7 -VT -X4:5 - - - -  + + +W3 + +4x + +0.14 mm² (26 AWG) + +0.3 m +  +X1:1 +BK +X4:1 + + + +X1:5 +BU +X4:3 + + + +X1:6 +OG +X4:4 + + + +X1:7 +VT +X4:5 + + + +  X1:e--W3:w - - - + + + X1:e--W3:w - - - + + + X1:e--W3:w - - - + + + X1:e--W3:w - - - + + + X2 - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -+5V - -SCL - -SDA + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + ++5V + +SCL + +SDA X3 - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -+5V - -SCL - -SDA + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + ++5V + +SCL + +SDA X4 - -X4 - -Molex KK 254 - -female - -5-pin - -1 - -2 - -3 - -4 - -5 - -GND - -+12V - -MISO - -MOSI - -SCK + +X4 + +Molex KK 254 + +female + +5-pin + +1 + +2 + +3 + +4 + +5 + +GND + ++12V + +MISO + +MOSI + +SCK - + -X5 - -X5 - -Molex Micro-Fit - -male - -2-pin - -GND - -+12V - -1 - -2 +F1 + + Crimp ferrule, 0.25 mm²   +   + - + W4 - - -2x - -0.5 mm² (21 AWG) - -0.35 m -  -X5:1 -BK -X4:1 - - - -X5:2 -RD -X4:2 - - - -  + + +W4 + +2x + +0.25 mm² (24 AWG) + +0.3 m +  +BK +X4:1 + + + +RD +X4:2 + + + +  - + -X5:e--W4:w - - - +F1:e--W4:w + + + - - -X5:e--W4:w - - - + + +F2 + + Crimp ferrule, 0.25 mm²   +   + + + + +F2:e--W4:w + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W2:e--X3:w - - - + + + W2:e--X3:w - - - + + + W2:e--X3:w - - - + + + W2:e--X3:w - - - + + + W3:e--X4:w - - - + + + W3:e--X4:w - - - + + + W3:e--X4:w - - - + + + W3:e--X4:w - - - + + + - + W4:e--X4:w - - - + + + W4:e--X4:w - - - + + + diff --git a/examples/demo02.yml b/examples/demo02.yml index a486b37..00ee554 100644 --- a/examples/demo02.yml +++ b/examples/demo02.yml @@ -1,15 +1,20 @@ templates: # defining templates to be used later on - &molex_f type: Molex KK 254 - gender: female + subtype: female - &con_i2c pinout: [GND, +5V, SCL, SDA] - &wire_i2c - mm2: 0.14 - length: 0.2 + category: bundle + gauge: 0.14 mm2 colors: [BK, RD, YE, GN] -nodes: +ferrules: + ferrule_crimp: + type: Crimp ferrule + subtype: 0.25 mm² + +connectors: X1: <<: *molex_f # copying items from the template pinout: [GND, +5V, SCL, SDA, MISO, MOSI, SCK, N/C] @@ -22,31 +27,26 @@ nodes: X4: <<: *molex_f pinout: [GND, +12V, MISO, MOSI, SCK] - X5: - type: Molex Micro-Fit - gender: male - pinout: [GND, +12V] -wires: +cables: W1: <<: *wire_i2c - type: bundle + length: 0.2 show_equiv: true W2: <<: *wire_i2c - type: bundle + length: 0.4 show_equiv: true W3: - mm2: 0.14 - length: 0.2 + category: bundle + gauge: 0.14 mm2 + length: 0.3 colors: [BK, BU, OG, VT] - type: bundle show_equiv: true W4: - mm2: 0.5 - length: 0.35 + gauge: 0.25 mm2 + length: 0.3 colors: [BK, RD] - type: bundle show_equiv: true connections: @@ -63,6 +63,8 @@ connections: - W3: [1-4] - X4: [1,3-5] - - - X5: [1,2] + - ferrule_crimp + - W4: [1,2] + - - W4: [1,2] - X4: [1,2] diff --git a/examples/ex01.bom.tsv b/examples/ex01.bom.tsv new file mode 100644 index 0000000..f1a36cd --- /dev/null +++ b/examples/ex01.bom.tsv @@ -0,0 +1,3 @@ +Item Qty Unit Designators +Molex KK 254, female, 4 pins 2 X1, X2 +Cable 4 x 0.25 mm² shielded 0.2 m W1 diff --git a/examples/ex01.html b/examples/ex01.html new file mode 100644 index 0000000..22856aa --- /dev/null +++ b/examples/ex01.html @@ -0,0 +1,175 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +RX + +TX + +1 + +2 + +3 + +4 + + + +W1 + + +W1 + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1 +BN +X2:1 + + + +X1:2 +RD +X2:2 + + + +X1:3 +OG +X2:4 + + + +X1:4 +YE +X2:3 + + + +  +X1:1 +Shield + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +X2 + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +RX + +TX + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Molex KK 254, female, 4 pins2X1, X2
Cable 4 x 0.25 mm² shielded0.2mW1
\ No newline at end of file diff --git a/examples/ex01.yml b/examples/ex01.yml index 120c3b6..83cce3c 100644 --- a/examples/ex01.yml +++ b/examples/ex01.yml @@ -1,18 +1,18 @@ -nodes: +connectors: X1: type: Molex KK 254 # more information - gender: female - pinout: [GND, VCC, RX, TX] # num_pins is implicit in pinout + subtype: female + pinout: [GND, VCC, RX, TX] # pincount is implicit in pinout X2: type: Molex KK 254 - gender: female + subtype: female pinout: [GND, VCC, RX, TX] -wires: +cables: 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 - mm2: 0.25 # metric gauge, in mm^2 + wirecount: 4 # need to specify number of wires explicitly when using a color code + gauge: 0.25 mm2 # also accepts AWG as unit show_equiv: true # auto-calculate AWG equivalent from metric gauge length: 0.2 # length in m shield: true diff --git a/examples/ex02.bom.tsv b/examples/ex02.bom.tsv new file mode 100644 index 0000000..61e34ab --- /dev/null +++ b/examples/ex02.bom.tsv @@ -0,0 +1,4 @@ +Item Qty Unit Designators +Molex Micro-Fit, female, 2 pins 3 X2, X3, X4 +Molex Micro-Fit, male, 2 pins 1 X1 +Cable 2 x 0.25 mm² 0.6 m W1, W2, W3 diff --git a/examples/ex02.html b/examples/ex02.html new file mode 100644 index 0000000..152b7a2 --- /dev/null +++ b/examples/ex02.html @@ -0,0 +1,258 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +Molex Micro-Fit + +male + +2-pin + +GND + +VCC + +1 + +2 + + + +W1 + + +W1 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  +X1:1 +BK +X2:1 + + + +X1:2 +RD +X2:2 + + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +W2 + + +W2 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  +X1:1 +BK +X3:1 + + + +X1:2 +RD +X3:2 + + + +  + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +W3 + + +W3 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  +X1:1 +BK +X4:1 + + + +X1:2 +RD +X4:2 + + + +  + + + +X1:e--W3:w + + + + + + +X1:e--W3:w + + + + + + +X2 + +X2 + +Molex Micro-Fit + +female + +2-pin + +1 + +2 + +GND + +VCC + + + +X3 + +X3 + +Molex Micro-Fit + +female + +2-pin + +1 + +2 + +GND + +VCC + + + +X4 + +X4 + +Molex Micro-Fit + +female + +2-pin + +1 + +2 + +GND + +VCC + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Molex Micro-Fit, female, 2 pins3X2, X3, X4
Molex Micro-Fit, male, 2 pins1X1
Cable 2 x 0.25 mm²0.6mW1, W2, W3
\ No newline at end of file diff --git a/examples/ex02.yml b/examples/ex02.yml index b990aa1..056e6fe 100644 --- a/examples/ex02.yml +++ b/examples/ex02.yml @@ -1,21 +1,21 @@ -nodes: +connectors: X1: &boo type: Molex Micro-Fit - gender: male + subtype: male pinout: [GND, VCC] X2: &con_power_f # define template type: Molex Micro-Fit - gender: female + subtype: female pinout: [GND, VCC] X3: <<: *con_power_f # create from template X4: <<: *con_power_f # create from template -wires: +cables: W1: &wire_power # define template colors: [BK, RD] # number of wires implicit in color list - mm2: 0.25 + gauge: 0.25 # assume mm2 if no gauge unit is specified show_equiv: true length: 0.2 W2: diff --git a/examples/ex03.bom.tsv b/examples/ex03.bom.tsv new file mode 100644 index 0000000..bb66fbc --- /dev/null +++ b/examples/ex03.bom.tsv @@ -0,0 +1,5 @@ +Item Qty Unit Designators +Molex Micro-Fit, female, 2 pins 3 X2, X3, X4 +Molex Micro-Fit, male, 2 pins 1 X1 +Wire 0.25 mm² BK 0.6 m W1 +Wire 0.25 mm² RD 0.6 m W1 diff --git a/examples/ex03.gv b/examples/ex03.gv index dbad2f8..c5a55e9 100644 --- a/examples/ex03.gv +++ b/examples/ex03.gv @@ -26,5 +26,5 @@ graph { edge [color="#000000:#ff0000:#000000"] X1:p2r:e -- W1:w6:w W1:w6:e -- X4:p2l:w - W1 [label=<
6x0.25 mm² (24 AWG)0.2 m
 
X1:1BKX2:1
X1:2RDX2:2
X1:1BKX3:1
X1:2RDX3:2
X1:1BKX4:1
X1:2RDX4:2
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W1 [label=<
W1
6x0.25 mm² (24 AWG)0.2 m
 
X1:1BKX2:1
X1:2RDX2:2
X1:1BKX3:1
X1:2RDX3:2
X1:1BKX4:1
X1:2RDX4:2
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] } diff --git a/examples/ex03.html b/examples/ex03.html new file mode 100644 index 0000000..fa7fe59 --- /dev/null +++ b/examples/ex03.html @@ -0,0 +1,228 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +Molex Micro-Fit + +male + +2-pin + +GND + +VCC + +1 + +2 + + + +W1 + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  +X1:1 +BK +X2:1 + + + +X1:2 +RD +X2:2 + + + +X1:1 +BK +X3:1 + + + +X1:2 +RD +X3:2 + + + +X1:1 +BK +X4:1 + + + +X1:2 +RD +X4:2 + + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X2 + +X2 + +Molex Micro-Fit + +female + +2-pin + +1 + +2 + +GND + +VCC + + + +X3 + +X3 + +Molex Micro-Fit + +female + +2-pin + +1 + +2 + +GND + +VCC + + + +X4 + +X4 + +Molex Micro-Fit + +female + +2-pin + +1 + +2 + +GND + +VCC + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X3:w + + + + + + +W1:e--X3:w + + + + + + +W1:e--X4:w + + + + + + +W1:e--X4:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Molex Micro-Fit, female, 2 pins3X2, X3, X4
Molex Micro-Fit, male, 2 pins1X1
Wire 0.25 mm² BK0.6mW1
Wire 0.25 mm² RD0.6mW1
\ No newline at end of file diff --git a/examples/ex03.png b/examples/ex03.png index 34c8b63..1a66384 100644 Binary files a/examples/ex03.png and b/examples/ex03.png differ diff --git a/examples/ex03.svg b/examples/ex03.svg index 24e80e2..af664bd 100644 --- a/examples/ex03.svg +++ b/examples/ex03.svg @@ -31,7 +31,9 @@ W1 - + + +W1 6x diff --git a/examples/ex03.yml b/examples/ex03.yml index c28f6b8..fb935a2 100644 --- a/examples/ex03.yml +++ b/examples/ex03.yml @@ -1,23 +1,23 @@ -nodes: +connectors: X1: &boo type: Molex Micro-Fit - gender: male + subtype: male pinout: [GND, VCC] X2: &con_power_f type: Molex Micro-Fit - gender: female + subtype: female pinout: [GND, VCC] X3: <<: *con_power_f X4: <<: *con_power_f -wires: +cables: 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 - mm2: 0.25 + category: bundle # bundles are routed together, but more loosely than normal cables + wirecount: 6 + colors: [BK, RD] # if number of items in color list is less than wirecount, loop colors + gauge: 0.25 mm2 show_equiv: true length: 0.2 diff --git a/examples/ex04.bom.tsv b/examples/ex04.bom.tsv new file mode 100644 index 0000000..cfa8f84 --- /dev/null +++ b/examples/ex04.bom.tsv @@ -0,0 +1,8 @@ +Item Qty Unit Designators +Crimp ferrule 12 +Wire 0.25 mm² BN 0.2 m W1 +Wire 0.25 mm² BU 0.2 m W1 +Wire 0.25 mm² GN 0.2 m W1 +Wire 0.25 mm² OG 0.2 m W1 +Wire 0.25 mm² RD 0.2 m W1 +Wire 0.25 mm² YE 0.2 m W1 diff --git a/examples/ex04.gv b/examples/ex04.gv index b41fe00..5715530 100644 --- a/examples/ex04.gv +++ b/examples/ex04.gv @@ -7,7 +7,7 @@ graph { F1 [label=< - +
crimp Crimp ferrule
@@ -17,7 +17,7 @@ graph { F2 [label=< - +
crimp Crimp ferrule
@@ -27,7 +27,7 @@ graph { F3 [label=< - +
crimp Crimp ferrule
@@ -37,7 +37,7 @@ graph { F4 [label=< - +
crimp Crimp ferrule
@@ -47,7 +47,7 @@ graph { F5 [label=< - +
crimp Crimp ferrule
@@ -57,7 +57,7 @@ graph { F6 [label=< - +
crimp Crimp ferrule
@@ -69,7 +69,7 @@ graph { - +
crimp Crimp ferrule
@@ -79,7 +79,7 @@ graph { - +
crimp Crimp ferrule
@@ -89,7 +89,7 @@ graph { - +
crimp Crimp ferrule
@@ -99,7 +99,7 @@ graph { - +
crimp Crimp ferrule
@@ -109,7 +109,7 @@ graph { - +
crimp Crimp ferrule
@@ -119,7 +119,7 @@ graph { - +
crimp Crimp ferrule
@@ -148,5 +148,5 @@ graph { W1:w2:e -- F11:w edge [color="#000000:#666600:#000000"] W1:w1:e -- F12:w - W1 [label=<
6x0.25 mm² (24 AWG)0.2 m
 
BN
RD
OG
YE
GN
BU
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W1 [label=<
W1
6x0.25 mm² (24 AWG)0.2 m
 
BN
RD
OG
YE
GN
BU
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] } diff --git a/examples/ex04.html b/examples/ex04.html new file mode 100644 index 0000000..807969f --- /dev/null +++ b/examples/ex04.html @@ -0,0 +1,232 @@ +

Diagram

+ + + + + + + + +F1 + + Crimp ferrule   +   + + + + +W1 + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  +BN + + + +RD + + + +OG + + + +YE + + + +GN + + + +BU + + + +  + + + +F1:e--W1:w + + + + + + +F2 + + Crimp ferrule   +   + + + + +F2:e--W1:w + + + + + + +F3 + + Crimp ferrule   +   + + + + +F3:e--W1:w + + + + + + +F4 + + Crimp ferrule   +   + + + + +F4:e--W1:w + + + + + + +F5 + + Crimp ferrule   +   + + + + +F5:e--W1:w + + + + + + +F6 + + Crimp ferrule   +   + + + + +F6:e--W1:w + + + + + + +F7 + +   + Crimp ferrule   + + + + +F8 + +   + Crimp ferrule   + + + + +F9 + +   + Crimp ferrule   + + + + +F10 + +   + Crimp ferrule   + + + + +F11 + +   + Crimp ferrule   + + + + +F12 + +   + Crimp ferrule   + + + + +W1:e--F7:w + + + + + + +W1:e--F8:w + + + + + + +W1:e--F9:w + + + + + + +W1:e--F10:w + + + + + + +W1:e--F11:w + + + + + + +W1:e--F12:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Crimp ferrule12
Wire 0.25 mm² BN0.2mW1
Wire 0.25 mm² BU0.2mW1
Wire 0.25 mm² GN0.2mW1
Wire 0.25 mm² OG0.2mW1
Wire 0.25 mm² RD0.2mW1
Wire 0.25 mm² YE0.2mW1
\ No newline at end of file diff --git a/examples/ex04.png b/examples/ex04.png index 5a1c603..d076724 100644 Binary files a/examples/ex04.png and b/examples/ex04.png differ diff --git a/examples/ex04.svg b/examples/ex04.svg index 2773290..8272dec 100644 --- a/examples/ex04.svg +++ b/examples/ex04.svg @@ -4,226 +4,228 @@ - + - + F1 - - crimp   -   - + + Crimp ferrule   +   + W1 - - -6x - -0.25 mm² (24 AWG) - -0.2 m -  -BN - - - -RD - - - -OG - - - -YE - - - -GN - - - -BU - - - -  + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  +BN + + + +RD + + + +OG + + + +YE + + + +GN + + + +BU + + + +  F1:e--W1:w - - - + + + F2 - - crimp   -   - + + Crimp ferrule   +   + F2:e--W1:w - - - + + + F3 - - crimp   -   - + + Crimp ferrule   +   + F3:e--W1:w - - - + + + F4 - - crimp   -   - + + Crimp ferrule   +   + F4:e--W1:w - - - + + + F5 - - crimp   -   - + + Crimp ferrule   +   + F5:e--W1:w - - - + + + F6 - - crimp   -   - + + Crimp ferrule   +   + F6:e--W1:w - - - + + + F7 - -   - crimp   - + +   + Crimp ferrule   + F8 - -   - crimp   - + +   + Crimp ferrule   + F9 - -   - crimp   - + +   + Crimp ferrule   + F10 - -   - crimp   - + +   + Crimp ferrule   + F11 - -   - crimp   - + +   + Crimp ferrule   + F12 - -   - crimp   - + +   + Crimp ferrule   + W1:e--F7:w - - - + + + W1:e--F8:w - - - + + + W1:e--F9:w - - - + + + W1:e--F10:w - - - + + + W1:e--F11:w - - - + + + W1:e--F12:w - - - + + + diff --git a/examples/ex04.yml b/examples/ex04.yml index 2ab5a3f..b9eb707 100644 --- a/examples/ex04.yml +++ b/examples/ex04.yml @@ -1,27 +1,27 @@ -# nodes: +# connectors: # X1: # type: D-Sub -# gender: female -# num_pins: 4 +# subtype: female +# pincount: 4 # X2: # type: Molex KK 254 -# gender: female -# num_pins: 3 +# subtype: female +# pincount: 3 -wires: +cables: W1: - mm2: 0.25 + gauge: 0.25 mm2 show_equiv: true length: 0.2 color_code: IEC - num_wires: 6 - type: bundle + wirecount: 6 + category: bundle ferrules: ferrule_crimp: - type: crimp + type: Crimp ferrule show_name: false - show_num_pins: false + show_pincount: false connections: - diff --git a/examples/ex05.bom.tsv b/examples/ex05.bom.tsv new file mode 100644 index 0000000..3314de6 --- /dev/null +++ b/examples/ex05.bom.tsv @@ -0,0 +1,6 @@ +Item Qty Unit Designators +Molex KK 254, female, 4 pins 3 X1, X2, X3 +Wire 0.25 mm² PK 0.4 m W1, W2 +Wire 0.25 mm² TQ 0.4 m W1, W2 +Wire 0.25 mm² VT 0.4 m W1, W2 +Wire 0.25 mm² YE 0.4 m W1, W2 diff --git a/examples/ex05.gv b/examples/ex05.gv index f4b51bb..b44ced5 100644 --- a/examples/ex05.gv +++ b/examples/ex05.gv @@ -19,7 +19,7 @@ graph { edge [color="#000000:#8000ff:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=<
4x0.25 mm²0.2 m
 
X1:1PKX2:1
X1:2TQX2:2
X1:3YEX2:3
X1:4VTX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W1 [label=<
W1
4x0.25 mm²0.2 m
 
X1:1PKX2:1
X1:2TQX2:2
X1:3YEX2:3
X1:4VTX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#ff66cc:#000000"] X2:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w @@ -32,5 +32,5 @@ graph { edge [color="#000000:#8000ff:#000000"] X2:p4r:e -- W2:w4:w W2:w4:e -- X3:p4l:w - W2 [label=<
4x0.25 mm²0.2 m
 
X2:1PKX3:1
X2:2TQX3:2
X2:3YEX3:3
X2:4VTX3:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W2 [label=<
W2
4x0.25 mm²0.2 m
 
X2:1PKX3:1
X2:2TQX3:2
X2:3YEX3:3
X2:4VTX3:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] } diff --git a/examples/ex05.html b/examples/ex05.html new file mode 100644 index 0000000..dc6d5dd --- /dev/null +++ b/examples/ex05.html @@ -0,0 +1,295 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 + + + +W1 + + +W1 + +4x + +0.25 mm² + +0.2 m +  +X1:1 +PK +X2:1 + + + +X1:2 +TQ +X2:2 + + + +X1:3 +YE +X2:3 + + + +X1:4 +VT +X2:4 + + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X2 + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 + + + +W2 + + +W2 + +4x + +0.25 mm² + +0.2 m +  +X2:1 +PK +X3:1 + + + +X2:2 +TQ +X3:2 + + + +X2:3 +YE +X3:3 + + + +X2:4 +VT +X3:4 + + + +  + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + + + + +X3 + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Molex KK 254, female, 4 pins3X1, X2, X3
Wire 0.25 mm² PK0.4mW1, W2
Wire 0.25 mm² TQ0.4mW1, W2
Wire 0.25 mm² VT0.4mW1, W2
Wire 0.25 mm² YE0.4mW1, W2
\ No newline at end of file diff --git a/examples/ex05.png b/examples/ex05.png index 715713f..4470666 100644 Binary files a/examples/ex05.png and b/examples/ex05.png differ diff --git a/examples/ex05.svg b/examples/ex05.svg index dcb33e6..acc8178 100644 --- a/examples/ex05.svg +++ b/examples/ex05.svg @@ -4,287 +4,291 @@ - - - + + + X1 - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -VCC - -SCL - -SDA - -1 - -2 - -3 - -4 + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 W1 - - -4x - -0.25 mm² - -0.2 m -  -X1:1 -PK -X2:1 - - - -X1:2 -TQ -X2:2 - - - -X1:3 -YE -X2:3 - - - -X1:4 -VT -X2:4 - - - -  + + +W1 + +4x + +0.25 mm² + +0.2 m +  +X1:1 +PK +X2:1 + + + +X1:2 +TQ +X2:2 + + + +X1:3 +YE +X2:3 + + + +X1:4 +VT +X2:4 + + + +  X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X2 - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -VCC - -SCL - -SDA - -1 - -2 - -3 - -4 + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 W2 - - -4x - -0.25 mm² - -0.2 m -  -X2:1 -PK -X3:1 - - - -X2:2 -TQ -X3:2 - - - -X2:3 -YE -X3:3 - - - -X2:4 -VT -X3:4 - - - -  + + +W2 + +4x + +0.25 mm² + +0.2 m +  +X2:1 +PK +X3:1 + + + +X2:2 +TQ +X3:2 + + + +X2:3 +YE +X3:3 + + + +X2:4 +VT +X3:4 + + + +  X2:e--W2:w - - - + + + X2:e--W2:w - - - + + + X2:e--W2:w - - - + + + X2:e--W2:w - - - + + + X3 - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -VCC - -SCL - -SDA + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W2:e--X3:w - - - + + + W2:e--X3:w - - - + + + W2:e--X3:w - - - + + + W2:e--X3:w - - - + + + diff --git a/examples/ex05.yml b/examples/ex05.yml index f5dc80e..9723b1f 100644 --- a/examples/ex05.yml +++ b/examples/ex05.yml @@ -2,15 +2,15 @@ templates: - &template_con type: Molex KK 254 - gender: female + subtype: female pinout: [GND, VCC, SCL, SDA] - &template_wire - mm2: 0.25 + gauge: 0.25 mm2 length: 0.2 colors: [PK, TQ, YE, VT] - type: bundle + category: bundle -nodes: +connectors: X1: <<: *template_con X2: @@ -18,7 +18,7 @@ nodes: X3: <<: *template_con -wires: +cables: W1: <<: *template_wire W2: diff --git a/examples/ex06.bom.tsv b/examples/ex06.bom.tsv new file mode 100644 index 0000000..d4bb657 --- /dev/null +++ b/examples/ex06.bom.tsv @@ -0,0 +1,6 @@ +Item Qty Unit Designators +Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 +Wire 0.25 mm² PK 1.0 m W1, W2, W3, W4, W5 +Wire 0.25 mm² TQ 1.0 m W1, W2, W3, W4, W5 +Wire 0.25 mm² VT 1.0 m W1, W2, W3, W4, W5 +Wire 0.25 mm² YE 1.0 m W1, W2, W3, W4, W5 diff --git a/examples/ex06.gv b/examples/ex06.gv index e3f4ea0..2779de2 100644 --- a/examples/ex06.gv +++ b/examples/ex06.gv @@ -22,7 +22,7 @@ graph { edge [color="#000000:#8000ff:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=<
4x0.25 mm²0.2 m
 
X1:1PKX2:1
X1:2TQX2:2
X1:3YEX2:3
X1:4VTX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W1 [label=<
W1
4x0.25 mm²0.2 m
 
X1:1PKX2:1
X1:2TQX2:2
X1:3YEX2:3
X1:4VTX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#ff66cc:#000000"] X3:p1r:e -- W2:w1:w W2:w1:e -- X2:p1l:w @@ -35,7 +35,7 @@ graph { edge [color="#000000:#8000ff:#000000"] X3:p4r:e -- W2:w4:w W2:w4:e -- X2:p4l:w - W2 [label=<
4x0.25 mm²0.2 m
 
X3:1PKX2:1
X3:2TQX2:2
X3:3YEX2:3
X3:4VTX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W2 [label=<
W2
4x0.25 mm²0.2 m
 
X3:1PKX2:1
X3:2TQX2:2
X3:3YEX2:3
X3:4VTX2:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#ff66cc:#000000"] X3:p1r:e -- W3:w1:w W3:w1:e -- X4:p1l:w @@ -48,7 +48,7 @@ graph { edge [color="#000000:#8000ff:#000000"] X3:p4r:e -- W3:w4:w W3:w4:e -- X4:p4l:w - W3 [label=<
4x0.25 mm²0.2 m
 
X3:1PKX4:1
X3:2TQX4:2
X3:3YEX4:3
X3:4VTX4:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W3 [label=<
W3
4x0.25 mm²0.2 m
 
X3:1PKX4:1
X3:2TQX4:2
X3:3YEX4:3
X3:4VTX4:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#ff66cc:#000000"] X5:p1r:e -- W4:w1:w W4:w1:e -- X4:p1l:w @@ -61,7 +61,7 @@ graph { edge [color="#000000:#8000ff:#000000"] X5:p4r:e -- W4:w4:w W4:w4:e -- X4:p4l:w - W4 [label=<
4x0.25 mm²0.2 m
 
X5:1PKX4:1
X5:2TQX4:2
X5:3YEX4:3
X5:4VTX4:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W4 [label=<
W4
4x0.25 mm²0.2 m
 
X5:1PKX4:1
X5:2TQX4:2
X5:3YEX4:3
X5:4VTX4:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] edge [color="#000000:#ff66cc:#000000"] X5:p1r:e -- W5:w1:w W5:w1:e -- X6:p1l:w @@ -74,5 +74,5 @@ graph { edge [color="#000000:#8000ff:#000000"] X5:p4r:e -- W5:w4:w W5:w4:e -- X6:p4l:w - W5 [label=<
4x0.25 mm²0.2 m
 
X5:1PKX6:1
X5:2TQX6:2
X5:3YEX6:3
X5:4VTX6:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] + W5 [label=<
W5
4x0.25 mm²0.2 m
 
X5:1PKX6:1
X5:2TQX6:2
X5:3YEX6:3
X5:4VTX6:4
 
> fillcolor=white margin=0 shape=box style="filled,dashed"] } diff --git a/examples/ex06.html b/examples/ex06.html new file mode 100644 index 0000000..1700d54 --- /dev/null +++ b/examples/ex06.html @@ -0,0 +1,656 @@ +

Diagram

+ + + + + + + + +X1 + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 + + + +W1 + + +W1 + +4x + +0.25 mm² + +0.2 m +  +X1:1 +PK +X2:1 + + + +X1:2 +TQ +X2:2 + + + +X1:3 +YE +X2:3 + + + +X1:4 +VT +X2:4 + + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X2 + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA + + + +X3 + +X3 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 + + + +W2 + + +W2 + +4x + +0.25 mm² + +0.2 m +  +X3:1 +PK +X2:1 + + + +X3:2 +TQ +X2:2 + + + +X3:3 +YE +X2:3 + + + +X3:4 +VT +X2:4 + + + +  + + + +X3:e--W2:w + + + + + + +X3:e--W2:w + + + + + + +X3:e--W2:w + + + + + + +X3:e--W2:w + + + + + + +W3 + + +W3 + +4x + +0.25 mm² + +0.2 m +  +X3:1 +PK +X4:1 + + + +X3:2 +TQ +X4:2 + + + +X3:3 +YE +X4:3 + + + +X3:4 +VT +X4:4 + + + +  + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X4 + +X4 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA + + + +X5 + +X5 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 + + + +W4 + + +W4 + +4x + +0.25 mm² + +0.2 m +  +X5:1 +PK +X4:1 + + + +X5:2 +TQ +X4:2 + + + +X5:3 +YE +X4:3 + + + +X5:4 +VT +X4:4 + + + +  + + + +X5:e--W4:w + + + + + + +X5:e--W4:w + + + + + + +X5:e--W4:w + + + + + + +X5:e--W4:w + + + + + + +W5 + + +W5 + +4x + +0.25 mm² + +0.2 m +  +X5:1 +PK +X6:1 + + + +X5:2 +TQ +X6:2 + + + +X5:3 +YE +X6:3 + + + +X5:4 +VT +X6:4 + + + +  + + + +X5:e--W5:w + + + + + + +X5:e--W5:w + + + + + + +X5:e--W5:w + + + + + + +X5:e--W5:w + + + + + + +X6 + +X6 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W5:e--X6:w + + + + + + +W5:e--X6:w + + + + + + +W5:e--X6:w + + + + + + +W5:e--X6:w + + + + + + +

Bill of Materials

ItemQtyUnitDesignators
Molex KK 254, female, 4 pins6X1, X2, X3, X4, X5, X6
Wire 0.25 mm² PK1.0mW1, W2, W3, W4, W5
Wire 0.25 mm² TQ1.0mW1, W2, W3, W4, W5
Wire 0.25 mm² VT1.0mW1, W2, W3, W4, W5
Wire 0.25 mm² YE1.0mW1, W2, W3, W4, W5
\ No newline at end of file diff --git a/examples/ex06.png b/examples/ex06.png index 43cc416..ba0a2bf 100644 Binary files a/examples/ex06.png and b/examples/ex06.png differ diff --git a/examples/ex06.svg b/examples/ex06.svg index 0646f25..a0d0387 100644 --- a/examples/ex06.svg +++ b/examples/ex06.svg @@ -4,642 +4,652 @@ - - - + + + X1 - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -VCC - -SCL - -SDA - -1 - -2 - -3 - -4 + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 W1 - - -4x - -0.25 mm² - -0.2 m -  -X1:1 -PK -X2:1 - - - -X1:2 -TQ -X2:2 - - - -X1:3 -YE -X2:3 - - - -X1:4 -VT -X2:4 - - - -  + + +W1 + +4x + +0.25 mm² + +0.2 m +  +X1:1 +PK +X2:1 + + + +X1:2 +TQ +X2:2 + + + +X1:3 +YE +X2:3 + + + +X1:4 +VT +X2:4 + + + +  X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + X2 - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -VCC - -SCL - -SDA + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA X3 - -X3 - -Molex KK 254 - -female - -4-pin - -GND - -VCC - -SCL - -SDA - -1 - -2 - -3 - -4 + +X3 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 W2 - - -4x - -0.25 mm² - -0.2 m -  -X3:1 -PK -X2:1 - - - -X3:2 -TQ -X2:2 - - - -X3:3 -YE -X2:3 - - - -X3:4 -VT -X2:4 - - - -  + + +W2 + +4x + +0.25 mm² + +0.2 m +  +X3:1 +PK +X2:1 + + + +X3:2 +TQ +X2:2 + + + +X3:3 +YE +X2:3 + + + +X3:4 +VT +X2:4 + + + +  X3:e--W2:w - - - + + + X3:e--W2:w - - - + + + X3:e--W2:w - - - + + + X3:e--W2:w - - - + + + W3 - - -4x - -0.25 mm² - -0.2 m -  -X3:1 -PK -X4:1 - - - -X3:2 -TQ -X4:2 - - - -X3:3 -YE -X4:3 - - - -X3:4 -VT -X4:4 - - - -  + + +W3 + +4x + +0.25 mm² + +0.2 m +  +X3:1 +PK +X4:1 + + + +X3:2 +TQ +X4:2 + + + +X3:3 +YE +X4:3 + + + +X3:4 +VT +X4:4 + + + +  X3:e--W3:w - - - + + + X3:e--W3:w - - - + + + X3:e--W3:w - - - + + + X3:e--W3:w - - - + + + X4 - -X4 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -VCC - -SCL - -SDA + +X4 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA X5 - -X5 - -Molex KK 254 - -female - -4-pin - -GND - -VCC - -SCL - -SDA - -1 - -2 - -3 - -4 + +X5 + +Molex KK 254 + +female + +4-pin + +GND + +VCC + +SCL + +SDA + +1 + +2 + +3 + +4 W4 - - -4x - -0.25 mm² - -0.2 m -  -X5:1 -PK -X4:1 - - - -X5:2 -TQ -X4:2 - - - -X5:3 -YE -X4:3 - - - -X5:4 -VT -X4:4 - - - -  + + +W4 + +4x + +0.25 mm² + +0.2 m +  +X5:1 +PK +X4:1 + + + +X5:2 +TQ +X4:2 + + + +X5:3 +YE +X4:3 + + + +X5:4 +VT +X4:4 + + + +  X5:e--W4:w - - - + + + X5:e--W4:w - - - + + + X5:e--W4:w - - - + + + X5:e--W4:w - - - + + + W5 - - -4x - -0.25 mm² - -0.2 m -  -X5:1 -PK -X6:1 - - - -X5:2 -TQ -X6:2 - - - -X5:3 -YE -X6:3 - - - -X5:4 -VT -X6:4 - - - -  + + +W5 + +4x + +0.25 mm² + +0.2 m +  +X5:1 +PK +X6:1 + + + +X5:2 +TQ +X6:2 + + + +X5:3 +YE +X6:3 + + + +X5:4 +VT +X6:4 + + + +  X5:e--W5:w - - - + + + X5:e--W5:w - - - + + + X5:e--W5:w - - - + + + X5:e--W5:w - - - + + + X6 - -X6 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -GND - -VCC - -SCL - -SDA + +X6 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 + +GND + +VCC + +SCL + +SDA W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W1:e--X2:w - - - + + + W2:e--X2:w - - - + + + W2:e--X2:w - - - + + + W2:e--X2:w - - - + + + W2:e--X2:w - - - + + + W3:e--X4:w - - - + + + W3:e--X4:w - - - + + + W3:e--X4:w - - - + + + W3:e--X4:w - - - + + + W4:e--X4:w - - - + + + W4:e--X4:w - - - + + + W4:e--X4:w - - - + + + W4:e--X4:w - - - + + + W5:e--X6:w - - - + + + W5:e--X6:w - - - + + + W5:e--X6:w - - - + + + W5:e--X6:w - - - + + + diff --git a/examples/ex06.yml b/examples/ex06.yml index a06f670..ea0d505 100644 --- a/examples/ex06.yml +++ b/examples/ex06.yml @@ -2,15 +2,15 @@ templates: - &template_con type: Molex KK 254 - gender: female + subtype: female pinout: [GND, VCC, SCL, SDA] - &template_wire - mm2: 0.25 + gauge: 0.25 mm2 length: 0.2 colors: [PK, TQ, YE, VT] - type: bundle + category: bundle -nodes: +connectors: X1: <<: *template_con X2: @@ -24,7 +24,7 @@ nodes: X6: <<: *template_con -wires: +cables: W1: <<: *template_wire W2: diff --git a/examples/readme.md b/examples/readme.md index 28326f1..5330f73 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -2,36 +2,36 @@ ## Example 01 ![](ex01.png) -[Source](ex01.yml) +[Source](ex01.yml) - [Bill of Materials](ex01.bom.tsv) ## Example 02 ![](ex02.png) -[Source](ex02.yml) +[Source](ex02.yml) - [Bill of Materials](ex02.bom.tsv) ## Example 03 ![](ex03.png) -[Source](ex03.yml) +[Source](ex03.yml) - [Bill of Materials](ex03.bom.tsv) ## Example 04 ![](ex04.png) -[Source](ex04.yml) +[Source](ex04.yml) - [Bill of Materials](ex04.bom.tsv) ## Example 05 ![](ex05.png) -[Source](ex05.yml) +[Source](ex05.yml) - [Bill of Materials](ex05.bom.tsv) ## Example 06 ![](ex06.png) -[Source](ex06.yml) +[Source](ex06.yml) - [Bill of Materials](ex06.bom.tsv) diff --git a/readme.md b/readme.md index 6aba0a7..b6373f3 100644 --- a/readme.md +++ b/readme.md @@ -20,6 +20,7 @@ WireViz is a simple yet flexible, YAML-based markup language for documenting cab * Optionally auto-calculates and displays AWG equivalent when specifying mm² * Allows more than one connector per side, as well as loopbacks * Allows for easy-autorouting for 1-to-1 wiring +* Generates BOM (Bill of Materials) _Note_: WireViz is not designed to represent the complete wiring of a system. Its main aim is to document the construction of individual wires and harnesses. @@ -29,45 +30,45 @@ _Note_: WireViz is not designed to represent the complete wiring of a system. It [WireViz input file](examples/demo01.yml): - nodes: + connectors: X1: type: D-Sub - gender: female + subtype: female pinout: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] X2: type: Molex KK 254 - gender: female - pinout: [GND, RX, TX, N/C, OUT, IN] + subtype: female + pinout: [GND, RX, TX] - wires: + cables: W1: - mm2: 0.25 + gauge: 0.25 mm2 length: 0.2 color_code: DIN - num_wires: 3 + wirecount: 3 shield: true connections: - - # format: connector->wire->connector + - - X1: [5,2,1] - W1: [1,2,3] - X2: [1,3,2] - - # format: connector->wire or wire->connector + - - X1: 5 - W1: s - - # loop: connector-connector - - X2: 5 - - X2: 6 Output file: ![Sample output diagram](examples/demo01.png) +[Bill of Materials](examples/demo01.bom.tsv) (auto-generated) + ### Demo 02 ![](examples/demo02.png) -[Source](examples/demo02.yml) +[Source](examples/demo02.yml) - [Bill of Materials](examples/demo02.bom.tsv) + ### More examples @@ -77,6 +78,10 @@ See the [example gallery](examples/) and included readme file. This is very much a [work in progress](todo.md). +## Requirements + +Developed and tested using Python 3.7; might not work with older Python versions. + ## License GNU GPLv3 diff --git a/src/batch.py b/src/batch.py index fc80270..7ca203e 100644 --- a/src/batch.py +++ b/src/batch.py @@ -9,13 +9,13 @@ with open(readme, 'w') as file: for i in range(1,3): fn = '../examples/demo{:02d}.yml'.format(i) print(fn) - wireviz.parse(fn) + wireviz.parse(fn, gen_bom=True) for i in range(1,7): fn = '../examples/ex{:02d}.yml'.format(i) print(fn) - wireviz.parse(fn) + wireviz.parse(fn, gen_bom=True) file.write('## Example {:02d}\n'.format(i)) file.write('![](ex{:02d}.png)\n\n'.format(i)) - file.write('[Source](ex{:02d}.yml)\n\n\n'.format(i)) + file.write('[Source](ex{:02d}.yml) - [Bill of Materials](ex{:02d}.bom.tsv)\n\n\n'.format(i,i)) diff --git a/src/wireviz.py b/src/wireviz.py index 0929a38..19a9561 100755 --- a/src/wireviz.py +++ b/src/wireviz.py @@ -2,80 +2,32 @@ import os from dataclasses import dataclass, field from typing import Any, List +from collections import Counter import yaml from graphviz import Graph -COLOR_CODES = {'DIN': ['WH','BN','GN','YE','GY','PK','BU','RD','BK','VT'], # ,'GYPK','RDBU','WHGN','BNGN','WHYE','YEBN','WHGY','GYBN','WHPK','PKBN'], - 'IEC': ['BN','RD','OG','YE','GN','BU','VT','GY','WH','BK'], - 'BW': ['BK','WH']} - -color_hex = { - 'BK': '#000000', - 'WH': '#ffffff', - 'GY': '#999999', - 'PK': '#ff66cc', - 'RD': '#ff0000', - 'OG': '#ff8000', - 'YE': '#ffff00', - 'GN': '#00ff00', - 'TQ': '#00ffff', - 'BU': '#0066ff', - 'VT': '#8000ff', - 'BN': '#666600', - } - -color_full = { - 'BK': 'black', - 'WH': 'white', - 'GY': 'grey', - 'PK': 'pink', - 'RD': 'red', - 'OG': 'orange', - 'YE': 'yellow', - 'GN': 'green', - 'TQ': 'turquoise', - 'BU': 'blue', - 'VT': 'violet', - 'BN': 'brown', -} - -color_ger = { - 'BK': 'sw', - 'WH': 'ws', - 'GY': 'gr', - 'PK': 'rs', - 'RD': 'rt', - 'OG': 'or', - 'YE': 'ge', - 'GN': 'gn', - 'TQ': 'tk', - 'BU': 'bl', - 'VT': 'vi', - 'BN': 'br', -} +import wv_colors +from wv_helper import nested, int2tuple, awg_equiv, flatten2d, tuplelist2tsv class Harness: def __init__(self): self.color_mode = 'SHORT' - self.nodes = {} + self.connectors = {} self.cables = {} - def add_node(self, name, *args, **kwargs): - self.nodes[name] = Node(name, *args, **kwargs) + def add_connector(self, name, *args, **kwargs): + self.connectors[name] = Connector(name, *args, **kwargs) def add_cable(self, name, *args, **kwargs): self.cables[name] = Cable(name, *args, **kwargs) - def loop(self, node_name, from_pin, to_pin): - self.nodes[node_name].loop(from_pin, to_pin) + def loop(self, connector_name, from_pin, to_pin): + self.connectors[connector_name].loop(from_pin, to_pin) def connect(self, from_name, from_pin, via_name, via_pin, to_name, to_pin): self.cables[via_name].connect(from_name, from_pin, via_pin, to_name, to_pin) - def connect_all_straight(self, cable_name, from_name, to_name): - self.cables[cable_name].connect_all_straight(from_name, to_name) - def create_graph(self): dot = Graph() dot.body.append('// Graph generated by WireViz') @@ -97,14 +49,15 @@ class Harness: for k, c in self.cables.items(): for x in c.connections: if x.from_port is not None: # connect to left - self.nodes[x.from_name].ports_right = True + self.connectors[x.from_name].ports_right = True if x.to_port is not None: # connect to right - self.nodes[x.to_name].ports_left = True + self.connectors[x.to_name].ports_left = True - for k, n in self.nodes.items(): + for k, n in self.connectors.items(): if n.category == 'ferrule': - infostring = '{type} {color}'.format(type=n.type, - color=translate_color(n.color, self.color_mode) if n.color else '') + infostring = '{type}{subtype} {color}'.format(type=n.type, + subtype=', {}'.format(n.subtype) if n.subtype else '', + color=wv_colors.translate_color(n.color, self.color_mode) if n.color else '') infostring_l = infostring if n.ports_right else '' infostring_r = infostring if n.ports_left else '' @@ -123,13 +76,13 @@ class Harness: >'''.format(infostring_l=infostring_l, infostring_r=infostring_r, - colorbar=''.format(translate_color(n.color, 'HEX')) if n.color else '')) - # dot.node(k, label='{A|B|{C|D|E}}') - else: + colorbar=''.format(wv_colors.translate_color(n.color, 'HEX')) if n.color else '')) + + else: # not a ferrule # a = attributes a = [n.type, - n.gender, - '{}-pin'.format(len(n.pinout)) if n.show_num_pins else ''] + n.subtype, + '{}-pin'.format(len(n.pinout)) if n.show_pincount else ''] # p = pinout p = [[],[],[]] p[1] = list(n.pinout) @@ -139,7 +92,7 @@ class Harness: if n.ports_right: p[2].append('{portno}'.format(portno=i)) # l = label - l = [n.name if n.show_name else '', a, p] + l = [n.name if n.show_name else '', a, p, n.notes] dot.node(k, label=nested(l)) if len(n.loops) > 0: @@ -158,19 +111,16 @@ class Harness: for k, c in self.cables.items(): # a = attributes - a = ['{}x'.format(len(c.colors)) if c.show_num_wires else '', - '{} mm\u00B2{}'.format(c.mm2, ' ({} AWG)'.format(awg_equiv(c.mm2)) if c.show_equiv else '') if c.mm2 is not None else '', - c.awg, + a = ['{}x'.format(len(c.colors)) if c.show_wirecount else '', + '{} {}{}'.format(c.gauge, c.gauge_unit, ' ({} AWG)'.format(awg_equiv(c.gauge)) if c.gauge_unit == 'mm\u00B2' and c.show_equiv else '') if c.gauge else '', # TODO: show equiv '+ S' if c.shield else '', '{} m'.format(c.length) if c.length > 0 else ''] - # print(a) a = list(filter(None, a)) - # print(a) html = '
' # main table html = html + '' # name+attributes table - if (not c.show_name) or c.type != 'bundle': + if c.show_name: html = html + ''.format(colspan=len(a), name=c.name) html = html + '' # attribute row for attrib in a: @@ -185,13 +135,13 @@ class Harness: for i, x in enumerate(c.colors,1): p = [] p.append(''.format(i)) - p.append(translate_color(x, self.color_mode)) + p.append(wv_colors.translate_color(x, self.color_mode)) p.append(''.format(i)) html = html + '' for bla in p: html = html + ''.format(bla) html = html + '' - html = html + ''.format(colspan=len(p), bgcolor=translate_color(x, 'hex'), port='w{}'.format(i)) + html = html + ''.format(colspan=len(p), bgcolor=wv_colors.translate_color(x, 'hex'), port='w{}'.format(i)) if c.shield: p = ['', 'Shield', ''] @@ -200,64 +150,174 @@ class Harness: for bla in p: html = html + ''.format(bla) html = html + '' - html = html + ''.format(colspan=len(p), bgcolor=translate_color(x, 'hex'), port='ws') + html = html + ''.format(colspan=len(p), bgcolor=wv_colors.translate_color(x, 'hex'), port='ws') html = html + '' # spacer at the end html = html + '
{name}
{}
{}
 
' # conductor table - html = html + '
' # main table + html = html + '' # main table + if c.notes: + html = html + '{}'.format(c.notes) # notes table + html = html + ' ' # spacer at the end - # print(html) + html = html + '' # main table # connections for x in c.connections: if isinstance(x.via_port, int): # check if it's an actual wire and not a shield search_color = c.colors[x.via_port-1] - if search_color in color_hex: - dot.attr('edge',color='#000000:{wire_color}:#000000'.format(wire_color=color_hex[search_color])) + if search_color in wv_colors.color_hex: + dot.attr('edge',color='#000000:{wire_color}:#000000'.format(wire_color=wv_colors.color_hex[search_color])) else: # color name not found dot.attr('edge',color='#000000') else: # it's a shield connection dot.attr('edge',color='#000000') if x.from_port is not None: # connect to left - from_ferrule = self.nodes[x.from_name].category is 'ferrule' + from_ferrule = self.connectors[x.from_name].category is 'ferrule' code_left_1 = '{from_name}{from_port}:e'.format(from_name=x.from_name, from_port=':p{}r'.format(x.from_port) if not from_ferrule else '') code_left_2 = '{via_name}:w{via_wire}:w'.format(via_name=c.name, via_wire=x.via_port, via_subport='i' if c.show_pinout else '') dot.edge(code_left_1, code_left_2) from_string = '{}:{}'.format(x.from_name, x.from_port) if not from_ferrule else '' html = html.replace(''.format(x.via_port), from_string) if x.to_port is not None: # connect to right - to_ferrule = self.nodes[x.to_name].category is 'ferrule' + to_ferrule = self.connectors[x.to_name].category is 'ferrule' code_right_1 = '{via_name}:w{via_wire}:e'.format(via_name=c.name, via_wire=x.via_port, via_subport='o' if c.show_pinout else '') code_right_2 = '{to_name}{to_port}:w'.format(to_name=x.to_name, to_port=':p{}l'.format(x.to_port) if not to_ferrule else '') dot.edge(code_right_1, code_right_2) to_string = '{}:{}'.format(x.to_name, x.to_port) if not to_ferrule else '' html = html.replace(''.format(x.via_port), to_string) - dot.node(c.name, label='<{html}>'.format(html=html), shape='box', style='filled,dashed' if c.type=='bundle' else '', margin='0', fillcolor='white') + dot.node(c.name, label='<{html}>'.format(html=html), shape='box', style='filled,dashed' if c.category=='bundle' else '', margin='0', fillcolor='white') return dot - def output(self, filename, directory='_output', view=False, cleanup=True, format='pdf'): + def output(self, filename, directory='_output', view=False, cleanup=True, format='pdf', gen_bom=False): + # graphical output d = self.create_graph() for f in format: d.format = f d.render(filename=filename, directory=directory, view=view, cleanup=cleanup) d.save(filename='{}.gv'.format(filename), directory=directory) + # bom output + bom_list = self.bom_list() + with open('{}.bom.tsv'.format(filename),'w') as file: + file.write(tuplelist2tsv(bom_list)) + # HTML output + with open('{}.html'.format(filename),'w') as file: + file.write('') + + file.write('

Diagram

') + with open('{}.svg'.format(filename),'r') as svg: + for l in svg: + file.write(l) + + file.write('

Bill of Materials

') + listy = flatten2d(bom_list) + file.write('') + file.write('') + for item in listy[0]: + file.write(''.format(item)) + file.write('') + for row in listy[1:]: + file.write('') + for i, item in enumerate(row): + file.write(''.format(content=item, align='align="right"' if listy[0][i] == 'Qty' else '')) + file.write('') + file.write('
{}
{content}
') + + file.write('') + + def bom(self): + bom = [] + bom_connectors = [] + bom_cables = [] + # connectors + types = Counter([(v.type, v.subtype, v.pincount) for v in self.connectors.values()]) + for type in types: + items = {k: v for k, v in self.connectors.items() if (v.type, v.subtype, v.pincount) == type} + shared = next(iter(items.values())) + designators = list(items.keys()) + designators.sort() + name = '{type}{subtype}{pincount}'.format(type = shared.type, + subtype = ', {}'.format(shared.subtype) if shared.subtype else '', + pincount = ', {} pins'.format(shared.pincount) if shared.category != 'ferrule' else '') + item = {'item': name, 'qty': len(designators), 'unit': '', 'designators': designators if shared.category != 'ferrule' else ''} + bom_connectors.append(item) + bom_connectors = sorted(bom_connectors, key=lambda k: k['item']) # https://stackoverflow.com/a/73050 + bom.extend(bom_connectors) + # cables + types = Counter([(v.category, v.gauge, v.gauge_unit, v.wirecount, v.shield) for v in self.cables.values()]) + for type in types: + items = {k: v for k, v in self.cables.items() if (v.category, v.gauge, v.gauge_unit, v.wirecount, v.shield) == type} + shared = next(iter(items.values())) + if shared.category != 'bundle': + designators = list(items.keys()) + designators.sort() + total_length = sum(i.length for i in items.values()) + name = 'Cable {wirecount} x{gauge}{shield}'.format(wirecount = shared.wirecount, + gauge = ' {} {}'.format(shared.gauge, shared.gauge_unit) if shared.gauge else '', + shield = ' shielded' if shared.shield else '') + 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 + types = Counter([(v.category, v.gauge, v.gauge_unit, v.length) for v in self.cables.values()]) + for type in types: + items = {k: v for k, v in self.cables.items() if (v.category, v.gauge, v.gauge_unit, v.length) == type} + shared = next(iter(items.values())) + # filter out cables that are not bundles + if shared.category == 'bundle': + 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, 'length': shared.length, 'color': color, 'designators': list(items.keys())}) + # join similar wires from all the bundles to a single BOM item + types = Counter([(v['gauge'], v['gauge_unit'], v['color']) for v in wirelist]) + for type in types: + items = [v for v in wirelist if (v['gauge'], v['gauge_unit'], v['color']) == type] + shared = items[0] + designators = [i['designators'] for i in items] + # flatten nested list + designators = [item for sublist in designators for item in sublist] # https://stackoverflow.com/a/952952 + # remove duplicates + designators = list(dict.fromkeys(designators)) + designators.sort() + total_length = sum(i['length'] for i in items) + name = 'Wire {} {} {}'.format(shared['gauge'], shared['gauge_unit'], shared['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 + bom.extend(bom_cables) + return bom + + def bom_list(self): + bom = self.bom() + keys = ['item', 'qty', 'unit', 'designators'] + bom_list = [] + bom_list.append([k.capitalize() for k in keys]) # create header row with keys + for item in bom: + item_list = [item.get(key, '') for key in keys] # fill missing values with blanks + for i, subitem in enumerate(item_list): + if isinstance(subitem, List): # convert any lists into comma separated strings + item_list[i] = ', '.join(subitem) + bom_list.append(item_list) + return bom_list @dataclass -class Node: +class Connector: name: str category: str = None type: str = None - gender: str = None - num_pins: int = None + subtype: str = None + pincount: int = None + notes: str = None pinout: List[Any] = field(default_factory=list) color: str = None show_name: bool = True - show_num_pins: bool = True + show_pincount: bool = True def __post_init__(self): self.ports_left = False @@ -265,12 +325,14 @@ class Node: self.loops = [] if self.pinout: - if self.num_pins is not None: - raise Exception('You cannot specify both pinout and num_pins') + if self.pincount is not None: + raise Exception('You cannot specify both pinout and pincount') + else: + self.pincount = len(self.pinout) else: - if not self.num_pins: - self.num_pins = 1 - self.pinout = ['',] * self.num_pins + if not self.pincount: + self.pincount = 1 + self.pinout = ['',] * self.pincount def loop(self, from_pin, to_pin): self.loops.append((from_pin, to_pin)) @@ -278,45 +340,61 @@ class Node: @dataclass class Cable: name: str + category : str = None type: str = None - mm2: float = None - awg: int = None + gauge: float = None + gauge_unit : str = 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!') + + if isinstance(self.gauge, str): # gauge and unit specified + try: + g, u = self.gauge.split(' ') + except: + raise Exception('Gauge must be a number, or number and unit separated by a space') + self.gauge = g + self.gauge_unit = u.replace('mm2','mm\u00B2') + elif self.gauge is not None: # gauge specified, assume mm2 + if self.gauge_unit is None: + self.gauge_unit = 'mm\u00B2' + else: + pass # gauge not specified + 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) - if self.color_code not in COLOR_CODES: + if self.color_code not in wv_colors.COLOR_CODES: raise Exception('Unknown color code') - self.colors = COLOR_CODES[self.color_code] + self.colors = wv_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] - - else: # num_wires implicit in length of color list + self.colors = self.colors[:self.wirecount] + 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) + + # for BOM generation + self.wirecount_and_shield = (self.wirecount, self.shield) def connect(self, from_name, from_pin, via_pin, to_name, to_pin): from_pin = int2tuple(from_pin) @@ -328,9 +406,6 @@ class Cable: # self.connections.append((from_name, from_pin[i], via_pin[i], to_name, to_pin[i])) self.connections.append(Connection(from_name, from_pin[i], via_pin[i], to_name, to_pin[i])) - def connect_all_straight(self, from_name, to_name): - self.connect(from_name, 'auto', 'auto', to_name, 'auto') - @dataclass class Connection: from_name: Any @@ -339,76 +414,7 @@ class Connection: to_name: Any to_port: Any -def nested(input): - l = [] - for x in input: - if isinstance(x, list): - if len(x) > 0: - n = nested(x) - if n != '': - l.append('{' + n + '}') - else: - if x is not None: - if x != '': - l.append(str(x)) - s = '|'.join(l) - return s - -def int2tuple(input): - if isinstance(input, tuple): - output = input - else: - output = (input,) - return output - -def translate_color(input, color_mode): - if input == '': - output = '' - else: - if color_mode == 'full': - output = color_full[input].lower() - elif color_mode == 'FULL': - output = color_full[input].upper() - elif color_mode == 'hex': - output = color_hex[input].lower() - elif color_mode == 'HEX': - output = color_hex[input].upper() - elif color_mode == 'ger': - output = color_ger[input].lower() - elif color_mode == 'GER': - output = color_ger[input].upper() - elif color_mode == 'short': - output = input.lower() - elif color_mode == 'SHORT': - output = input.upper() - else: - raise Exception('Unknown color mode') - return output - -def awg_equiv(mm2): - awg_equiv_table = { - '0.09': 28, - '0.14': 26, - '0.25': 24, - '0.34': 22, - '0.5': 21, - '0.75': 20, - '1': 18, - '1.5': 16, - '2.5': 14, - '4': 12, - '6': 10, - '10': 8, - '16': 6, - '25': 4, - } - k = str(mm2) - if k in awg_equiv_table: - return awg_equiv_table[k] - else: - return None - -def parse(file_in, file_out=None): +def parse(file_in, file_out=None, gen_bom=False): file_in = os.path.abspath(file_in) if not file_out: @@ -418,10 +424,7 @@ def parse(file_in, file_out=None): file_out = os.path.abspath(file_out) with open(file_in, 'r') as stream: - try: - input = yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) + input = yaml.safe_load(stream) def expand(input): # input can be: @@ -453,7 +456,6 @@ def parse(file_in, file_out=None): def check_designators(what, where): for i, x in enumerate(what): - # print('Looking for {} in {}'.format(x,where[i])) if x not in input[where[i]]: return False return True @@ -461,24 +463,22 @@ def parse(file_in, file_out=None): h = Harness() # add items - sections = ['nodes','wires','ferrules','connections'] + sections = ['connectors','cables','ferrules','connections'] types = [dict, dict, dict, list] for sec, ty in zip(sections, types): if sec in input and type(input[sec]) == ty: if len(input[sec]) > 0: if ty == dict: for k, o in input[sec].items(): - if sec == 'nodes': - h.add_node(name=k, **o) - elif sec == 'wires': + if sec == 'connectors': + h.add_connector(name=k, **o) + elif sec == 'cables': h.add_cable(name=k, **o) elif sec == 'ferrules': pass - # h.add_node(name=k, category='ferrule', **o) else: - print('{} section empty'.format(sec)) - else: - print('No {} section found'.format(sec)) + pass # section exists but is empty + else: # section does not exist, create empty section if ty == dict: input[sec] = {} elif ty == list: @@ -487,7 +487,7 @@ def parse(file_in, file_out=None): # add connections ferrule_counter = 0 for con in input['connections']: - if len(con) == 3: # format: connector -- wire -- conector + if len(con) == 3: # format: connector -- cable -- conector for c in con: if len(list(c.keys())) != 1: # check that each entry in con has only one key, which is the designator @@ -497,7 +497,8 @@ def parse(file_in, file_out=None): via_name = list(con[1].keys())[0] to_name = list(con[2].keys())[0] - if not check_designators([from_name,via_name,to_name],('nodes','wires','nodes')): + if not check_designators([from_name,via_name,to_name],('connectors','cables','connectors')): + print([from_name,via_name,to_name]) raise Exception('Bad connection definition (3)') from_pins = expand(con[0][from_name]) @@ -517,7 +518,7 @@ def parse(file_in, file_out=None): if len(list(c.keys())) != 1: # check that each entry in con has only one key, which is the designator raise Exception('Too many keys') - # hack to make the format for ferrules compatible with the formats for connectors and wires + # hack to make the format for ferrules compatible with the formats for connectors and cables if type(con[0]) == str: name = con[0] con[0] = {} @@ -530,72 +531,73 @@ def parse(file_in, file_out=None): from_name = list(con[0].keys())[0] to_name = list(con[1].keys())[0] - n_w = check_designators([from_name, to_name],('nodes','wires')) - w_n = check_designators([from_name, to_name],('wires','nodes')) - n_n = check_designators([from_name, to_name],('nodes','nodes')) + con_cbl = check_designators([from_name, to_name],('connectors','cables')) + cbl_con = check_designators([from_name, to_name],('cables','connectors')) + con_con = check_designators([from_name, to_name],('connectors','connectors')) - f_w = check_designators([from_name, to_name],('ferrules','wires')) - w_f = check_designators([from_name, to_name],('wires','ferrules')) + fer_cbl = check_designators([from_name, to_name],('ferrules','cables')) + cbl_fer = check_designators([from_name, to_name],('cables','ferrules')) - if not n_w and not w_n and not n_n and not f_w and not w_f: + if not con_cbl and not cbl_con and not con_con and not fer_cbl and not cbl_fer: raise Exception('Wrong designators') from_pins = expand(con[0][from_name]) to_pins = expand(con[1][to_name]) - if n_w or w_n or n_n: + if con_cbl or cbl_con or con_con: if len(from_pins) != len(to_pins): raise Exception('List length mismatch') - if n_w or w_n: + if con_cbl or cbl_con: for (from_pin, to_pin) in zip(from_pins, to_pins): - if n_w: + if con_cbl: h.connect(from_name, from_pin, to_name, to_pin, None, None) - else: # w_n + else: # cbl_con h.connect(None, None, from_name, from_pin, to_name, to_pin) - elif n_n: - con_name = list(con[0].keys())[0] + elif con_con: + cocon_coname = list(con[0].keys())[0] from_pins = expand(con[0][from_name]) to_pins = expand(con[1][to_name]) for (from_pin, to_pin) in zip(from_pins, to_pins): - h.loop(con_name, from_pin, to_pin) - if f_w or w_f: + h.loop(cocon_coname, from_pin, to_pin) + if fer_cbl or cbl_fer: from_pins = expand(con[0][from_name]) to_pins = expand(con[1][to_name]) - if f_w: + if fer_cbl: ferrule_name = from_name - wire_name = to_name - wire_pins = to_pins + cable_name = to_name + cable_pins = to_pins else: ferrule_name = to_name - wire_name = from_name - wire_pins = from_pins + cable_name = from_name + cable_pins = from_pins ferrule_params = input['ferrules'][ferrule_name] - for wire_pin in wire_pins: + for cable_pin in cable_pins: ferrule_counter = ferrule_counter + 1 ferrule_id = 'F{}'.format(ferrule_counter) - h.add_node(ferrule_id, category='ferrule', **ferrule_params) + h.add_connector(ferrule_id, category='ferrule', **ferrule_params) - if f_w: - h.connect(ferrule_id, 1, wire_name, wire_pin, None, None) + if fer_cbl: + h.connect(ferrule_id, 1, cable_name, cable_pin, None, None) else: - h.connect(None, None, wire_name, wire_pin, ferrule_id, 1) + h.connect(None, None, cable_name, cable_pin, ferrule_id, 1) else: raise Exception('Wrong number of connection parameters') - h.output(filename=file_out, format=('png','svg'), view=False) + h.output(filename=file_out, format=('png','svg'), gen_bom=gen_bom, view=False) if __name__ == '__main__': import argparse ap = argparse.ArgumentParser() ap.add_argument('file_input', nargs='?', default='_test/test.yml') ap.add_argument('file_output', nargs='?', default=None) + ap.add_argument('--bom', action='store_const', default=True, const=True) args = ap.parse_args() - parse(args.file_input, args.file_output) + parse(args.file_input, file_out=args.file_output, gen_bom=args.bom) diff --git a/src/wv_colors.py b/src/wv_colors.py new file mode 100644 index 0000000..32c90c9 --- /dev/null +++ b/src/wv_colors.py @@ -0,0 +1,74 @@ +COLOR_CODES = { + 'DIN': ['WH','BN','GN','YE','GY','PK','BU','RD','BK','VT'], # ,'GYPK','RDBU','WHGN','BNGN','WHYE','YEBN','WHGY','GYBN','WHPK','PKBN'], + 'IEC': ['BN','RD','OG','YE','GN','BU','VT','GY','WH','BK'], + 'BW': ['BK','WH'] + } + +color_hex = { + 'BK': '#000000', + 'WH': '#ffffff', + 'GY': '#999999', + 'PK': '#ff66cc', + 'RD': '#ff0000', + 'OG': '#ff8000', + 'YE': '#ffff00', + 'GN': '#00ff00', + 'TQ': '#00ffff', + 'BU': '#0066ff', + 'VT': '#8000ff', + 'BN': '#666600', + } + +color_full = { + 'BK': 'black', + 'WH': 'white', + 'GY': 'grey', + 'PK': 'pink', + 'RD': 'red', + 'OG': 'orange', + 'YE': 'yellow', + 'GN': 'green', + 'TQ': 'turquoise', + 'BU': 'blue', + 'VT': 'violet', + 'BN': 'brown', +} + +color_ger = { + 'BK': 'sw', + 'WH': 'ws', + 'GY': 'gr', + 'PK': 'rs', + 'RD': 'rt', + 'OG': 'or', + 'YE': 'ge', + 'GN': 'gn', + 'TQ': 'tk', + 'BU': 'bl', + 'VT': 'vi', + 'BN': 'br', +} + +def translate_color(input, color_mode): + if input == '': + output = '' + else: + if color_mode == 'full': + output = color_full[input].lower() + elif color_mode == 'FULL': + output = color_full[input].upper() + elif color_mode == 'hex': + output = color_hex[input].lower() + elif color_mode == 'HEX': + output = color_hex[input].upper() + elif color_mode == 'ger': + output = color_ger[input].lower() + elif color_mode == 'GER': + output = color_ger[input].upper() + elif color_mode == 'short': + output = input.lower() + elif color_mode == 'SHORT': + output = input.upper() + else: + raise Exception('Unknown color mode') + return output diff --git a/src/wv_helper.py b/src/wv_helper.py new file mode 100644 index 0000000..49b9c3d --- /dev/null +++ b/src/wv_helper.py @@ -0,0 +1,59 @@ +from typing import Any, List + +def awg_equiv(mm2): + awg_equiv_table = { + '0.09': 28, + '0.14': 26, + '0.25': 24, + '0.34': 22, + '0.5': 21, + '0.75': 20, + '1': 18, + '1.5': 16, + '2.5': 14, + '4': 12, + '6': 10, + '10': 8, + '16': 6, + '25': 4, + } + k = str(mm2) + if k in awg_equiv_table: + return awg_equiv_table[k] + else: + return 'unknown' + +def nested(input): + l = [] + for x in input: + if isinstance(x, list): + if len(x) > 0: + n = nested(x) + if n != '': + l.append('{' + n + '}') + else: + if x is not None: + if x != '': + l.append(str(x)) + s = '|'.join(l) + return s + +def int2tuple(input): + if isinstance(input, tuple): + output = input + else: + output = (input,) + return output + +def flatten2d(input): + output = [[str(item) if not isinstance(item, List) else ', '.join(item) for item in row] for row in input] + return output + +def tuplelist2tsv(input, header=None): + output = '' + if header is not None: + input.insert(0, header) + input = flatten2d(input) + for row in input: + output = output + '\t'.join(str(item) for item in row) + '\n' + return output diff --git a/todo.md b/todo.md index fc64aa5..64c9a55 100644 --- a/todo.md +++ b/todo.md @@ -2,11 +2,6 @@ ## Support for more connector types -* Generic connectors - * Ferrules - * Blade terminals - * Loose ends / stubs - * Graphical representation? * Inline connectors (IDC) * Possibly join two logical wires into one physical wire, add up length for BOM creation * Designators like W1_1, W1_2 or similar to group them? @@ -37,14 +32,10 @@ ## Export * Export to PDF with frame, title block, ... -* Automatic BOM generation ## Other * Set global parameters (show_pins, ...) and allow override on per-item basis -* Improve nomenclature - * terminal (connector, ferrule, blade, loose) - * link (cable, wire bundle) * Allow custom GraphViz code before/after WireViz-generated code * Make "unit tests" for different features/situations * Missing parameters