diff --git a/.gitignore b/.gitignore index 7484ecbd..cd250416 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ venv/ desktop.ini thumbs.db temp/ +.~lock +# diff --git a/docs/README.md b/docs/README.md index 732f6714..970655b7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -148,6 +148,12 @@ To see how to specify the output formats, as well as additional options, run: $ wireviz --help ``` +For using the .gv output one needs to use the following command: + +``` +dot .gv | gvpr -q -cf _pin2pin.gvpr | neato -n2 -T -o . +``` + ### (Re-)Building the example projects diff --git a/docs/syntax.md b/docs/syntax.md index de672847..573c62d3 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -83,8 +83,18 @@ tweak: # optional tweaking of .gv output hide_disconnected_pins: # defaults to false # loops - loops: # every list item is itself a list of exactly two pins - # on the connector that are to be shorted + loops: # a list(dict) of loops + - : # every list item is itself a list of pins + # on the connector that are to be shorted with a cable loop + # more information about the loop can be added by additional + # components definition (see below) + # Shorts + shorts: # a list(dict) of shorts + - : # every list item is itself a list of pins + # on the connector that are to be shorted represented inside + # the connector table + # more information about the loop can be added by additional + # components definition (see below) ``` ## Cable attributes @@ -421,6 +431,13 @@ Parts can be added to a connector or cable in the section ` # supplier name spn: # supplier part number bgcolor: # Background color of entry in diagram component box + + references: # A list of designators that are related to this + # component, for example shorts or loops + + # Shorts and Loops specific attributs + color: # if a reference to a short or loop is defined than + # this color is used for the short or loop ``` Alternatively items can be added to just the BOM by putting them in the section `` above. diff --git a/examples/demo01.gv b/examples/demo01.gv index 8b327c4d..2fb294dd 100644 --- a/examples/demo01.gv +++ b/examples/demo01.gv @@ -1,9 +1,10 @@ graph { -// Graph generated by WireViz 0.4 +// Graph generated by WireViz 0.5-dev // https://github.com/formatc1702/WireViz graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] edge [fontname=arial style=bold] + edge [headclip=true style=bold tailclip=true] X1 [label=<
@@ -60,6 +61,7 @@ graph {
> fillcolor="#FFFFFF" shape=box style=filled] + edge [headclip=true style=bold tailclip=true] X2 [label=< diff --git a/examples/demo01.html b/examples/demo01.html index 2786c1c7..50fd8333 100644 --- a/examples/demo01.html +++ b/examples/demo01.html @@ -1,7 +1,7 @@ - + demo01 + +

ex15

+

Diagram

+ +
+ +
+ +
+ + + + + + + + +X1 + + +X1 + +Molex KK 254 + +female + +7-pin + + +SH1 + +SH2 + + +GND + + + +1 + +VCC + + + +2 + +RX + + + +3 + +TX + + + +4 + +GND + + + +5 + +VCC + + + +6 + +GND + + + +7 + +Additional components + +42 mm x SH1 x #3 (shortPartA) + +1 x SH2 x #4 (shortPartB) + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + + + +W1 + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1:GND +     1:BUWH     +X2:1:GND +X1:2:VCC +     2:WHBU     +X2:2:VCC +X1:3:RX +     3:OGWH     +X2:4:TX +X1:4:TX +     4:WHOG     +X2:3:RX +  +X1:1:GND +Shield +  + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + +X2 + + +X2 + +Molex KK 254 + +female + +7-pin + + + +SH1 + +SH2 + +1 + +GND + + + +2 + +VCC + + + +3 + +RX + + + +4 + +TX + + + +5 + +GND + + + +6 + +VCC + + + +7 + +GND + + + + + +W1:e--X2:w + + + + + + + + +W1:e--X2:w + + + + + + + + +W1:e--X2:w + + + + + + + + +W1:e--X2:w + + + + + + + + +X2:c--X2:c + + + + +X2:c--X2:c + + + + +X2:c--X2:c + + + + +__CIRCLE__1 + + + + +__CIRCLE__2 + + + + +__CIRCLE__3 + + + + +__CIRCLE__4 + + + + +__CIRCLE__5 + + + + +__CIRCLE__6 + + + + +__CIRCLE__7 + + + + +__CIRCLE__8 + + + + +__CIRCLE__9 + + + + +__CIRCLE__10 + + + + +__CIRCLE__11 + + + + +__CIRCLE__12 + + + + + +
+ +
+ +
+ +

Bill of Materials

+ +
+
@@ -95,14 +97,18 @@ graph { edge [color="#000000:#ffffff:#000000"] X1:p5r:e -- W1:w1:w W1:w1:e -- X2:p1l:w + W1:w1:w -- W1:w1:e [straight=straight] edge [color="#000000:#895956:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p3l:w + W1:w2:w -- W1:w2:e [straight=straight] edge [color="#000000:#00ff00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p2l:w + W1:w3:w -- W1:w3:e [straight=straight] edge [color="#000000"] X1:p5r:e -- W1:ws:w + W1:ws:w -- W1:ws:e [straight=straight] W1 [label=< @@ -147,9 +151,7 @@ graph { @@ -163,9 +165,7 @@ graph { @@ -175,7 +175,7 @@ graph { - +
@@ -131,9 +137,7 @@ graph {
- - - +
- - - +
- - - +
Shield
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdDescriptionQtyUnitDesignatorsManufacturerMPN
1Cable, Serial, 4 x 0.25 mm² shielded0.2mW1
2Connector, Molex KK 254, female, 7 pins2X1, X2
3shortPartA42mmX1-SH1WireViz42XCD42A5
4shortPartB1X1-SH2WireViz42XCD42A5
+ + + + diff --git a/examples/ex15.png b/examples/ex15.png new file mode 100644 index 00000000..757da1ce Binary files /dev/null and b/examples/ex15.png differ diff --git a/examples/ex15.svg b/examples/ex15.svg new file mode 100644 index 00000000..ebdb3797 --- /dev/null +++ b/examples/ex15.svg @@ -0,0 +1,384 @@ + + + + + + + + + +X1 + + +X1 + +Molex KK 254 + +female + +7-pin + + +SH1 + +SH2 + + +GND + + + +1 + +VCC + + + +2 + +RX + + + +3 + +TX + + + +4 + +GND + + + +5 + +VCC + + + +6 + +GND + + + +7 + +Additional components + +42 mm x SH1 x #3 (shortPartA) + +1 x SH2 x #4 (shortPartB) + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + + + +W1 + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1:GND +     1:BUWH     +X2:1:GND +X1:2:VCC +     2:WHBU     +X2:2:VCC +X1:3:RX +     3:OGWH     +X2:4:TX +X1:4:TX +     4:WHOG     +X2:3:RX +  +X1:1:GND +Shield +  + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + + + + + +W1:w--W1:e + + + + +X2 + + +X2 + +Molex KK 254 + +female + +7-pin + + + +SH1 + +SH2 + +1 + +GND + + + +2 + +VCC + + + +3 + +RX + + + +4 + +TX + + + +5 + +GND + + + +6 + +VCC + + + +7 + +GND + + + + + +W1:e--X2:w + + + + + + + + +W1:e--X2:w + + + + + + + + +W1:e--X2:w + + + + + + + + +W1:e--X2:w + + + + + + + + +X2:c--X2:c + + + + +X2:c--X2:c + + + + +X2:c--X2:c + + + + +__CIRCLE__1 + + + + +__CIRCLE__2 + + + + +__CIRCLE__3 + + + + +__CIRCLE__4 + + + + +__CIRCLE__5 + + + + +__CIRCLE__6 + + + + +__CIRCLE__7 + + + + +__CIRCLE__8 + + + + +__CIRCLE__9 + + + + +__CIRCLE__10 + + + + +__CIRCLE__11 + + + + +__CIRCLE__12 + + + + diff --git a/examples/ex15.yml b/examples/ex15.yml new file mode 100644 index 00000000..9fb30f14 --- /dev/null +++ b/examples/ex15.yml @@ -0,0 +1,47 @@ +connectors: # This is based on ex1 and adds some Shorts to the connectors + X1: # An example of Shorts with more information + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + shorts: # A List(Dict) of shorts is created + - SH1: [1, 5, 7] # First is the designator than a list of pins to be shorted + - SH2: [2, 6] + additional_components: # Some Additional Components to describe the short in more detail + - references: SH1 + color: PK # The color of the short, can also be multicolor + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartA + qty: 42 # The length or some other quantity + unit: mm # The unit of the qty, in this example the length + - references: SH2 + color: RD + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartB + X2: # An example of a simple short definition + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + shorts: # The definition is the same as above but there is no additional_components for more information + - SH1: [1, 5, 7] + - SH2: [2, 6] + +cables: + W1: + color_code: TEL + wirecount: 4 + gauge: 0.25 mm2 + show_equiv: true + length: 0.2 + shield: true + type: Serial + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - + - X1: 1 + - W1: s diff --git a/examples/ex15_pin2pin.gvpr b/examples/ex15_pin2pin.gvpr new file mode 100644 index 00000000..4c4e2878 --- /dev/null +++ b/examples/ex15_pin2pin.gvpr @@ -0,0 +1,57 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex16.bom.tsv b/examples/ex16.bom.tsv new file mode 100644 index 00000000..1fb930f5 --- /dev/null +++ b/examples/ex16.bom.tsv @@ -0,0 +1,6 @@ +Id Description Qty Unit Designators Manufacturer MPN +1 Cable, Serial, 4 x 0.25 mm² shielded 0.2 m W1 +2 Connector, Molex KK 254, female, 7 pins 2 X1, X2 +3 loopPartA 42 mm X1-LO1 WireViz 42XCD42A5 +4 loopPartB 74 mm X1-LO2 WireViz 42XCD42A5 +5 loopPartC 21 mm X2-LO1; X2-LO2 WireViz 42XCD42A5 diff --git a/examples/ex16.gv b/examples/ex16.gv new file mode 100644 index 00000000..125e82b4 --- /dev/null +++ b/examples/ex16.gv @@ -0,0 +1,246 @@ +graph { +// Graph generated by WireViz 0.5-dev +// https://github.com/formatc1702/WireViz + graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] + node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] + edge [fontname=arial style=bold] + edge [headclip=true style=bold tailclip=true] + X1 [label=< + + + + + + + +
+ + +
X1
+
+ + + + +
Molex KK 254female7-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GND1
VCC2
RX3
TX4
GND5
VCC6
GND7
+
+ + +
Additional components
+
+ + +
42 mm x LO1 x loopPartA
WireViz: 42XCD42A5
+
+ + +
74 mm x LO2 x loopPartB
WireViz: 42XCD42A5
+
+> fillcolor="#FFFFFF" shape=box style=filled] + edge [color="#000000:#FF66CC:#000000"] + X1:p1r:e -- X1:p5r:e [label=" "] + X1:p5r:e -- X1:p7r:e [label=" "] + edge [color="#000000:#FF0000:#0066FF:#FF8000:#A0DFFF:#000000"] + X1:p2r:e -- X1:p6r:e [label=" "] + edge [headclip=true style=bold tailclip=true] + X2 [label=< + + + + + + +
+ + +
X2
+
+ + + + +
Molex KK 254female7-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1GND
2VCC
3RX
4TX
5GND
6VCC
7GND
+
+ + +
Additional components
+
+ + +
42 mm x LO1; LO2 x loopPartC
WireViz: 42XCD42A5
+
+> fillcolor="#FFFFFF" shape=box style=filled] + edge [color="#000000:#FF66CC:#000000"] + X2:p1l:w -- X2:p5l:w [label=" "] + X2:p5l:w -- X2:p7l:w [label=" "] + edge [color="#000000:#FF66CC:#000000"] + X2:p2l:w -- X2:p6l:w [label=" "] + edge [color="#000000:#895956:#000000"] + X1:p1r:e -- W1:w1:w + W1:w1:e -- X2:p1l:w + W1:w1:w -- W1:w1:e [straight=straight] + edge [color="#000000:#ff0000:#000000"] + X1:p2r:e -- W1:w2:w + W1:w2:e -- X2:p2l:w + W1:w2:w -- W1:w2:e [straight=straight] + edge [color="#000000:#ff8000:#000000"] + X1:p3r:e -- W1:w3:w + W1:w3:e -- X2:p4l:w + W1:w3:w -- W1:w3:e [straight=straight] + edge [color="#000000:#ffff00:#000000"] + X1:p4r:e -- W1:w4:w + W1:w4:e -- X2:p3l:w + W1:w4:w -- W1:w4:e [straight=straight] + edge [color="#000000"] + X1:p1r:e -- W1:ws:w + W1:ws:w -- W1:ws:e [straight=straight] + W1 [label=< + + + + +
+ + +
W1
+
+ + + + + + +
Serial4x0.25 mm² (24 AWG)+ S0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND + 1:BN + X2:1:GND
+ + +
+
X1:2:VCC + 2:RD + X2:2:VCC
+ + +
+
X1:3:RX + 3:OG + X2:4:TX
+ + +
+
X1:4:TX + 4:YE + X2:3:RX
+ + +
+
 
X1:1:GNDShield
 
+
+> fillcolor="#FFFFFF" shape=box style=filled] +} diff --git a/examples/ex16.html b/examples/ex16.html new file mode 100644 index 00000000..e9ba9654 --- /dev/null +++ b/examples/ex16.html @@ -0,0 +1,385 @@ + + + + + ex16 + + +

ex16

+

Diagram

+ +
+ +
+ +
+ + + + + + + + +X1 + + +X1 + +Molex KK 254 + +female + +7-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 + +GND + +5 + +VCC + +6 + +GND + +7 + +Additional components + +42 mm x LO1 x loopPartA +WireViz: 42XCD42A5 + +74 mm x LO2 x loopPartB +WireViz: 42XCD42A5 + + + +X1:e--X1:e + + + + + + + +X1:e--X1:e + + + + + + + +X1:e--X1:e + + + + + + + + + + +W1 + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1:GND +     1:BN     +X2:1:GND +X1:2:VCC +     2:RD     +X2:2:VCC +X1:3:RX +     3:OG     +X2:4:TX +X1:4:TX +     4:YE     +X2:3:RX +  +X1:1:GND +Shield +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + +X2 + + +X2 + +Molex KK 254 + +female + +7-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX + +5 + +GND + +6 + +VCC + +7 + +GND + +Additional components + +42 mm x LO1; LO2 x loopPartC +WireViz: 42XCD42A5 + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + + +
+ +
+ +
+ +

Bill of Materials

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdDescriptionQtyUnitDesignatorsManufacturerMPN
1Cable, Serial, 4 x 0.25 mm² shielded0.2mW1
2Connector, Molex KK 254, female, 7 pins2X1, X2
3loopPartA42mmX1-LO1WireViz42XCD42A5
4loopPartB74mmX1-LO2WireViz42XCD42A5
5loopPartC21mmX2-LO1; X2-LO2WireViz42XCD42A5
+ +
+ + diff --git a/examples/ex16.png b/examples/ex16.png new file mode 100644 index 00000000..23c5ad8b Binary files /dev/null and b/examples/ex16.png differ diff --git a/examples/ex16.svg b/examples/ex16.svg new file mode 100644 index 00000000..a33c3d40 --- /dev/null +++ b/examples/ex16.svg @@ -0,0 +1,286 @@ + + + + + + + + + +X1 + + +X1 + +Molex KK 254 + +female + +7-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 + +GND + +5 + +VCC + +6 + +GND + +7 + +Additional components + +42 mm x LO1 x loopPartA +WireViz: 42XCD42A5 + +74 mm x LO2 x loopPartB +WireViz: 42XCD42A5 + + + +X1:e--X1:e + + + + + + + +X1:e--X1:e + + + + + + + +X1:e--X1:e + + + + + + + + + + +W1 + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1:GND +     1:BN     +X2:1:GND +X1:2:VCC +     2:RD     +X2:2:VCC +X1:3:RX +     3:OG     +X2:4:TX +X1:4:TX +     4:YE     +X2:3:RX +  +X1:1:GND +Shield +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + +X2 + + +X2 + +Molex KK 254 + +female + +7-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX + +5 + +GND + +6 + +VCC + +7 + +GND + +Additional components + +42 mm x LO1; LO2 x loopPartC +WireViz: 42XCD42A5 + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + diff --git a/examples/ex16.yml b/examples/ex16.yml new file mode 100644 index 00000000..882302db --- /dev/null +++ b/examples/ex16.yml @@ -0,0 +1,61 @@ +options: + mini_bom_mode: false # disable mini_bom to show difference to ex15 + +connectors: # This is based on ex1 and adds some Loops to the connectors + X1: + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + loops: # A List(Dict) of loops is created + - LO1: [1, 5, 7] # First is the designator than a list of pins to be shorted + - LO2: [2, 6] + additional_components: # Some Additional Components to describe the short in more detail + - references: LO1 + color: PK # The color of the short, can also be multicolor + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartA + qty: 42 # The length or some other quantity + unit: mm # The unit of the qty, in this example the length + - references: LO2 + color: RDBUOGLB # multicolor example + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartB + qty: 74 + unit: mm + + X2: + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + loops: + - LO1: [1, 5, 7] + - LO2: [2, 6] + additional_components: + - references: [LO1, LO2] # example to show how one additional_components can reference more than one short or loop + color: PK + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartC + qty: 21 + unit: mm + +cables: + W1: + color_code: IEC + wirecount: 4 + gauge: 0.25 mm2 + show_equiv: true + length: 0.2 + shield: true + type: Serial + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - + - X1: 1 + - W1: s diff --git a/examples/ex16_pin2pin.gvpr b/examples/ex16_pin2pin.gvpr new file mode 100644 index 00000000..4c4e2878 --- /dev/null +++ b/examples/ex16_pin2pin.gvpr @@ -0,0 +1,57 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/readme.md b/examples/readme.md index 88a4389c..b4934bcd 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -84,3 +84,15 @@ [Source](ex14.yml) - [Bill of Materials](ex14.bom.tsv) +## Example 15 +![](ex15.png) + +[Source](ex15.yml) - [Bill of Materials](ex15.bom.tsv) + + +## Example 16 +![](ex16.png) + +[Source](ex16.yml) - [Bill of Materials](ex16.bom.tsv) + + diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 5b4bb068..45e4ae1a 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -128,6 +128,8 @@ class AdditionalComponent: unit: Optional[str] = None qty_multiplier: Union[ConnectorMultiplier, CableMultiplier, None] = None bgcolor: Optional[Color] = None + color: Optional[Color] = None + references: Optional[List[str]] = field(default_factory=list) @property def description(self) -> str: @@ -136,7 +138,6 @@ def description(self) -> str: t = t + st return t - @dataclass class Connector: name: Designator @@ -161,9 +162,10 @@ class Connector: show_name: Optional[bool] = None show_pincount: Optional[bool] = None hide_disconnected_pins: bool = False - loops: List[List[Pin]] = field(default_factory=list) - ignore_in_bom: bool = False + loops: Dict = field(default_factory=list)# List[List[Pin]] = field(default_factory=list) + ignore_in_bom: bool = False#ß additional_components: List[AdditionalComponent] = field(default_factory=list) + shorts: Dict = field(default_factory=list) def __post_init__(self) -> None: @@ -208,15 +210,14 @@ def __post_init__(self) -> None: for loop in self.loops: # TODO: allow using pin labels in addition to pin numbers, just like when defining regular connections # TODO: include properties of wire used to create the loop - if len(loop) != 2: - raise Exception("Loops must be between exactly two pins!") - for pin in loop: - if pin not in self.pins: - raise Exception( - f'Unknown loop pin "{pin}" for connector "{self.name}"!' - ) - # Make sure loop connected pins are not hidden. - self.activate_pin(pin, None) + for loopName in loop: + for pin in loop[loopName]: + if pin not in self.pins: + raise Exception( + f'Unknown loop pin "{pin}" for connector "{self.name}"!' + ) + # Make sure loop connected pins are not hidden. + self.activate_pin(pin, None) for i, item in enumerate(self.additional_components): if isinstance(item, dict): @@ -228,6 +229,8 @@ def activate_pin(self, pin: Pin, side: Side) -> None: self.ports_left = True elif side == Side.RIGHT: self.ports_right = True + + # def get_qty_shorts_AddComp() def get_qty_multiplier(self, qty_multiplier: Optional[ConnectorMultiplier]) -> int: if not qty_multiplier: diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 30468a6a..0eb7ebcf 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -1,11 +1,15 @@ # -*- coding: utf-8 -*- +import os +import shutil import re from collections import Counter from dataclasses import dataclass from itertools import zip_longest from pathlib import Path from typing import Any, List, Union +from dataclasses import asdict +from distutils.spawn import find_executable from graphviz import Graph @@ -19,6 +23,7 @@ Options, Tweak, Side, + Image, ) from wireviz.svgembed import embed_svg_images_file from wireviz.wv_bom import ( @@ -65,6 +70,11 @@ def check_old(node: str, old_attr: dict, args: dict) -> None: if attr in args: raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}") +def getAddCompFromRef(reference, part): + for comp in part.additional_components: + if reference in comp.references: + return comp; + @dataclass class Harness: metadata: Metadata @@ -218,6 +228,22 @@ def create_graph(self) -> Graph: '' ) + if len(connector.shorts) > 0: + pinhtml.append(" ") + if connector.ports_left: + pinhtml.append(f' ') + if connector.pinlabels: + pinhtml.append(f" ") + + for short in connector.shorts: + shortName = list(short.keys())[0] + pinhtml.append(f' ') + + if connector.ports_right: + pinhtml.append(f' ') + pinhtml.append(" ") + + for pinindex, (pinname, pinlabel, pincolor) in enumerate( zip_longest( connector.pins, connector.pinlabels, connector.pincolors @@ -246,9 +272,25 @@ def create_graph(self) -> Graph: # fmt: on else: pinhtml.append(' ') + # Add Short columns + for short in connector.shorts: + shortName = list(short.keys())[0] + shortPins = list(short.values())[0] + shortComp = getAddCompFromRef(shortName, connector) + + shColor = "BK" + if shortComp != None and shortComp.color != None: + shColor = shortComp.color + + if pinindex+1 in shortPins: + pinhtml.append(f' ') + else: + pinhtml.append(f' ') + if connector.ports_right: pinhtml.append(f' ') + pinhtml.append(" ") pinhtml.append("
{shortName}
{pinname}
") @@ -258,6 +300,28 @@ def create_graph(self) -> Graph: for row in html ] + # Add short connections/vertical lines with dots + for short in connector.shorts: + shortName = list(short.keys())[0] + shortPins = list(short.values())[0] + shortComp = getAddCompFromRef(shortName, connector) + + shColor = "BK" + if shortComp != None and shortComp.color != None: + shColor = shortComp.color + + dot.attr("edge", color=str(wv_colors.translate_color(shColor, "HEX")), headclip="false", tailclip="false", style="solid,bold") + for i in range(1, len(shortPins)): + dot.edge( + f"{connector.name}:p{shortPins[i - 1]}j:c", + f"{connector.name}:p{shortPins[i]}j:c", + straight="straight", + addPTS=".18", # Size of the point at the end of the straight line/edge, it also enables the drawing of it + colorPTS=str(wv_colors.translate_color(shColor, "HEX")), # the color of the point at the end of the line, it is required that the circle is drawing + ) + + dot.attr("edge", headclip="true", tailclip="true", style="bold") + html = "\n".join(html) dot.node( connector.name, @@ -267,8 +331,17 @@ def create_graph(self) -> Graph: fillcolor=translate_color(self.options.bgcolor_connector, "HEX"), ) - if len(connector.loops) > 0: - dot.attr("edge", color="#000000:#ffffff:#000000") + # Draw loop connections + for loop in connector.loops: + loopName = list(loop.keys())[0] + loopPins = list(loop.values())[0] + loopComp = getAddCompFromRef(loopName, connector) + + loColor = "BK" + if loopComp != None and loopComp.color != None: + loColor = loopComp.color + + dot.attr("edge", color=f"#000000:{wv_colors.translate_color(loColor, 'HEX')}:#000000") if connector.ports_left: loop_side = "l" loop_dir = "w" @@ -277,10 +350,11 @@ def create_graph(self) -> Graph: loop_dir = "e" else: raise Exception("No side for loops") - for loop in connector.loops: + for i in range(1, len(loopPins)): dot.edge( - f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}", - f"{connector.name}:p{loop[1]}{loop_side}:{loop_dir}", + f"{connector.name}:p{loopPins[i - 1]}{loop_side}:{loop_dir}", + f"{connector.name}:p{loopPins[i]}{loop_side}:{loop_dir}", + label= " ", ) # determine if there are double- or triple-colored wires in the harness; @@ -365,8 +439,9 @@ def create_graph(self) -> Graph: wirehtml.append(f" ") wirehtml.append(f' ') wirehtml.append(' ') - for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors - wirehtml.append(f' ') + #for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors + # wirehtml.append(f' ') + wirehtml.append(f' ') wirehtml.append("
") wirehtml.append(" ") wirehtml.append(" ") @@ -426,11 +501,11 @@ def create_graph(self) -> Graph: # shield is shown with specified color and black borders shield_color_hex = wv_colors.get_color_hex(cable.shield)[0] attributes = ( - f'height="6" bgcolor="{shield_color_hex}" border="2" sides="tb"' + f'height="6" border="2" sides="tb"'# bgcolor="{shield_color_hex}" ) else: # shield is shown as a thin black wire - attributes = f'height="2" bgcolor="#000000" border="0"' + attributes = f'height="2" border="0"' # bgcolor="#000000" # fmt: off wirehtml.append(f' ') # fmt: on @@ -516,6 +591,14 @@ def create_graph(self) -> Graph: for row in html ] + # Connection in the Wire + code_left_1 = f"{cable.name}:w{connection.via_port}:w" + code_left_2 = f"{cable.name}:w{connection.via_port}:e" + dot.edge(code_left_1, + code_left_2, + straight="straight", + ) + style, bgcolor = ( ("filled,dashed", self.options.bgcolor_bundle) if cable.category == "bundle" @@ -647,6 +730,22 @@ def typecheck(name: str, value: Any, expect: type) -> None: # do not access directly, use self.graph instead _graph = None + # This renders the graph with gvpr and neato, this is needed to be able to draw the stright lines for the jumpers + def graphRender(self, type, filename, graph): + # Chack if the needed commands are existing + if find_executable("dot") and find_executable("gvpr") and find_executable("neato"): + # Set enviorments variable to path of this file + os.environ['GVPRPATH'] = str(Path(__file__).parent) + # Export the gv output to a temporay file + graph.save(filename=f"{filename}_tmp.gv") + # Run the vomand and generait the output + os.system(f"dot {filename}_tmp.gv | gvpr -q -cf pin2pin.gvpr | neato -n2 -T{type} -o {filename}.{type}") + # Remove the temporary file + os.remove(f"{filename}_tmp.gv") + else: + print('The "dot", "gvpr" and "neato" comand where not found on the system, use old methode of generaiton, this may lead to not wanted output.') + graph.render(filename=filename) # old rendering methode, befor jumper implementations + @property def graph(self): if not self._graph: # no cached graph exists, generate one @@ -671,8 +770,6 @@ def svg(self): def output( self, filename: (str, Path), - view: bool = False, - cleanup: bool = True, fmt: tuple = ("html", "png", "svg", "tsv"), ) -> None: # graphical output @@ -689,13 +786,17 @@ def output( _filename = f"{filename}.tmp" if f == "svg" else filename # TODO: prevent rendering SVG twice when both SVG and HTML are specified graph.format = f - graph.render(filename=_filename, view=view, cleanup=cleanup) + self.graphRender(f, _filename, graph) # embed images into SVG output if "svg" in fmt or "html" in fmt: embed_svg_images_file(f"{filename}.tmp.svg") # GraphViz output if "gv" in fmt: graph.save(filename=f"{filename}.gv") + # Print the needed comand for generaitong an output + filename_str = str(filename) + shutil.copyfile(str(Path(__file__).parent).replace('\\', '/') + "/pin2pin.gvpr", filename_str + "_pin2pin.gvpr") + print(f"Use: dot {filename_str}.gv | gvpr -q -cf {filename_str}_pin2pin.gvpr | neato -n2 -T -o {filename_str}.") # BOM output bomlist = bom_list(self.bom()) if "tsv" in fmt: diff --git a/src/wireviz/pin2pin.gvpr b/src/wireviz/pin2pin.gvpr new file mode 100644 index 00000000..4c4e2878 --- /dev/null +++ b/src/wireviz/pin2pin.gvpr @@ -0,0 +1,57 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index bc974e86..983f1744 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -377,7 +377,7 @@ def alternate_type(): # flip between connector and cable/arrow harness.add_bom_item(line) if output_formats: - harness.output(filename=output_file, fmt=output_formats, view=False) + harness.output(filename=output_file, fmt=output_formats) if return_types: returns = [] diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index 27ee59b0..41f01b4c 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -40,12 +40,26 @@ def get_additional_component_table( part for part in component.additional_components if component.get_qty_multiplier(part.qty_multiplier) - ]: - common_args = { - "qty": part.qty * component.get_qty_multiplier(part.qty_multiplier), - "unit": part.unit, - "bgcolor": part.bgcolor, - } + ]: + + if type(part.references) == str: + numRef = 1 + else: + numRef = len(part.references) + + if numRef > 0: + common_args = { + "qty": part.qty * numRef, + "unit": part.unit, + "bgcolor": part.bgcolor, + "designators": part.references, + } + else: + common_args = { + "qty": part.qty * component.get_qty_multiplier(part.qty_multiplier), + "unit": part.unit, + "bgcolor": part.bgcolor, + } if harness.options.mini_bom_mode: id = get_bom_index( harness.bom(), @@ -64,7 +78,6 @@ def get_additional_component_table( ) return rows - def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOMEntry]: """Return a list of BOM entries with additional components.""" bom_entries = [] @@ -79,12 +92,22 @@ def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOM "description": part.description, "qty": part.qty * component.get_qty_multiplier(part.qty_multiplier), "unit": part.unit, - "designators": component.name if component.show_name else None, + "designators": additional_component_bom_desig(component, part), # component.name if component.show_name else None, **optional_fields(part), } ) return bom_entries - +# "designators": part.references, +def additional_component_bom_desig(component: Union[Connector, Cable], part) -> Union[str, None]: + if component.show_name and not part.references: + return component.name + elif component.show_name and part.references: + if type(part.references) == str: + return component.name + "-" + part.references + else: + return '; '.join([component.name + "-" + x for x in part.references]) + else: + return None def bom_entry_key(entry: BOMEntry) -> BOMKey: """Return a tuple of string values from the dict that must be equal to join BOM entries.""" @@ -252,6 +275,7 @@ def component_table_entry( mpn: Optional[str] = None, supplier: Optional[str] = None, spn: Optional[str] = None, + designators: Optional[str] = None, ) -> str: """Return a diagram node table row string with an additional component.""" part_number_list = [ @@ -262,6 +286,7 @@ def component_table_entry( output = ( f"{qty}" + (f" {unit}" if unit else "") + + (f" x {designators_info_string(designators)}" if designators else "") + f" x {type}" + ("
" if any(part_number_list) else "") + (", ".join([pn for pn in part_number_list if pn])) @@ -283,6 +308,11 @@ def pn_info_string( else: return None +def designators_info_string(designators: list) -> str: + if type(designators) == str: + return designators + else: + return '; '.join(designators) def index_if_list(value: Any, index: int) -> Any: """Return the value indexed if it is a list, or simply the value otherwise.""" diff --git a/tutorial/readme.md b/tutorial/readme.md index 56f9cce5..e7caa90f 100644 --- a/tutorial/readme.md +++ b/tutorial/readme.md @@ -417,3 +417,72 @@ additional_bom_items: [Source](tutorial08.yml) - [Bill of Materials](tutorial08.bom.tsv) +## 09 - Shorts/Loops/Jumpers + +* Short and Loops + * with optional additional component + +```yaml +connectors: # This is based on tutorial3(ex1) and adds some Shorts to the connectors + X1: # An example of Shorts + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + shorts: # A List(Dict) of shorts is created + - SH1: [1, 5, 7] # First is the designator than a list of pins to be shorted + - SH2: [2, 6] + additional_components: # Some Additional Components to describe the short in more detail, they are not necessary if no further detail is needed + - references: SH1 + color: PK # The color of the short, can also be multicolor + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartA + qty: 42 # The length or some other quantity + unit: mm # The unit of the qty, in this example the length + - references: SH2 + color: RD + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartB + + X2: # An example of Loops and how an Additional Component can describe more than one Short or Loop + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + loops: + - LO1: [1, 5, 7] + - LO2: [2, 6] + additional_components: + - references: [LO1, LO2] # example to show how one additional_components can reference more than one short or loop + color: PK + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartC + qty: 21 + unit: mm + +cables: + W1: + color_code: IEC + wirecount: 4 + gauge: 0.25 mm2 + show_equiv: true + length: 0.2 + shield: true + type: Serial + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - + - X1: 1 + - W1: s +``` + +![](tutorial09.png) + +[Source](tutorial09.yml) - [Bill of Materials](tutorial09.bom.tsv) + + diff --git a/tutorial/tutorial01.gv b/tutorial/tutorial01.gv index df4ec3de..a05dd8eb 100644 --- a/tutorial/tutorial01.gv +++ b/tutorial/tutorial01.gv @@ -1,9 +1,10 @@ graph { -// Graph generated by WireViz 0.4 +// Graph generated by WireViz 0.5-dev // https://github.com/formatc1702/WireViz graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] edge [fontname=arial style=bold] + edge [headclip=true style=bold tailclip=true] X1 [label=<
@@ -34,6 +35,7 @@ graph {
> fillcolor="#FFFFFF" shape=box style=filled] + edge [headclip=true style=bold tailclip=true] X2 [label=<
@@ -67,15 +69,19 @@ graph { edge [color="#000000:#ffffff:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w + W1:w1:w -- W1:w1:e [straight=straight] edge [color="#000000:#ffffff:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w + W1:w2:w -- W1:w2:e [straight=straight] edge [color="#000000:#ffffff:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w + W1:w3:w -- W1:w3:e [straight=straight] edge [color="#000000:#ffffff:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w + W1:w4:w -- W1:w4:e [straight=straight] W1 [label=< @@ -118,9 +122,7 @@ graph { @@ -134,9 +136,7 @@ graph { @@ -150,9 +150,7 @@ graph { diff --git a/tutorial/tutorial01.html b/tutorial/tutorial01.html index 8865161b..8b08f9ab 100644 --- a/tutorial/tutorial01.html +++ b/tutorial/tutorial01.html @@ -1,7 +1,7 @@ - + tutorial01 + +

tutorial09

+

Diagram

+ +
+ +
+ +
+ + + + + + + + +X1 + + +X1 + +Molex KK 254 + +female + +7-pin + + +SH1 + +SH2 + + +GND + + + +1 + +VCC + + + +2 + +RX + + + +3 + +TX + + + +4 + +GND + + + +5 + +VCC + + + +6 + +GND + + + +7 + +Additional components + +42 mm x SH1 x #4 (shortPartA) + +1 x SH2 x #5 (shortPartB) + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + +W1 + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1:GND +     1:BN     +X2:1:GND +X1:2:VCC +     2:RD     +X2:2:VCC +X1:3:RX +     3:OG     +X2:4:TX +X1:4:TX +     4:YE     +X2:3:RX +  +X1:1:GND +Shield +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + +X2 + + +X2 + +Molex KK 254 + +female + +7-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX + +5 + +GND + +6 + +VCC + +7 + +GND + +Additional components + +42 mm x LO1; LO2 x #3 (loopPartC) + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + +__CIRCLE__1 + + + + +__CIRCLE__2 + + + + +__CIRCLE__3 + + + + +__CIRCLE__4 + + + + +__CIRCLE__5 + + + + +__CIRCLE__6 + + + + + +
+ +
+ +
+ +

Bill of Materials

+ +
+
@@ -102,9 +108,7 @@ graph {
- - - +
- - - +
- - - +
- - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdDescriptionQtyUnitDesignatorsManufacturerMPN
1Cable, Serial, 4 x 0.25 mm² shielded0.2mW1
2Connector, Molex KK 254, female, 7 pins2X1, X2
3loopPartC21mmX2-LO1; X2-LO2WireViz42XCD42A5
4shortPartA42mmX1-SH1WireViz42XCD42A5
5shortPartB1X1-SH2WireViz42XCD42A5
+ + + + diff --git a/tutorial/tutorial09.md b/tutorial/tutorial09.md new file mode 100644 index 00000000..f895321f --- /dev/null +++ b/tutorial/tutorial09.md @@ -0,0 +1,4 @@ +## Shorts/Loops/Jumpers + +* Short and Loops + * with optional additional component \ No newline at end of file diff --git a/tutorial/tutorial09.png b/tutorial/tutorial09.png new file mode 100644 index 00000000..3b2a6451 Binary files /dev/null and b/tutorial/tutorial09.png differ diff --git a/tutorial/tutorial09.svg b/tutorial/tutorial09.svg new file mode 100644 index 00000000..d79d05f9 --- /dev/null +++ b/tutorial/tutorial09.svg @@ -0,0 +1,321 @@ + + + + + + + + + +X1 + + +X1 + +Molex KK 254 + +female + +7-pin + + +SH1 + +SH2 + + +GND + + + +1 + +VCC + + + +2 + +RX + + + +3 + +TX + + + +4 + +GND + + + +5 + +VCC + + + +6 + +GND + + + +7 + +Additional components + +42 mm x SH1 x #4 (shortPartA) + +1 x SH2 x #5 (shortPartB) + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + +X1:c--X1:c + + + + +W1 + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  +X1:1:GND +     1:BN     +X2:1:GND +X1:2:VCC +     2:RD     +X2:2:VCC +X1:3:RX +     3:OG     +X2:4:TX +X1:4:TX +     4:YE     +X2:3:RX +  +X1:1:GND +Shield +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + + + +W1:w--W1:e + + + + +X2 + + +X2 + +Molex KK 254 + +female + +7-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX + +5 + +GND + +6 + +VCC + +7 + +GND + +Additional components + +42 mm x LO1; LO2 x #3 (loopPartC) + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + +X2:w--X2:w + + + + + + + +__CIRCLE__1 + + + + +__CIRCLE__2 + + + + +__CIRCLE__3 + + + + +__CIRCLE__4 + + + + +__CIRCLE__5 + + + + +__CIRCLE__6 + + + + diff --git a/tutorial/tutorial09.yml b/tutorial/tutorial09.yml new file mode 100644 index 00000000..48a5e1f1 --- /dev/null +++ b/tutorial/tutorial09.yml @@ -0,0 +1,56 @@ +connectors: # This is based on tutorial3(ex1) and adds some Shorts to the connectors + X1: # An example of Shorts + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + shorts: # A List(Dict) of shorts is created + - SH1: [1, 5, 7] # First is the designator than a list of pins to be shorted + - SH2: [2, 6] + additional_components: # Some Additional Components to describe the short in more detail, they are not necessary if no further detail is needed + - references: SH1 + color: PK # The color of the short, can also be multicolor + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartA + qty: 42 # The length or some other quantity + unit: mm # The unit of the qty, in this example the length + - references: SH2 + color: RD + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartB + + X2: # An example of Loops and how an Additional Component can describe more than one Short or Loop + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + loops: + - LO1: [1, 5, 7] + - LO2: [2, 6] + additional_components: + - references: [LO1, LO2] # example to show how one additional_components can reference more than one short or loop + color: PK + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartC + qty: 21 + unit: mm + +cables: + W1: + color_code: IEC + wirecount: 4 + gauge: 0.25 mm2 + show_equiv: true + length: 0.2 + shield: true + type: Serial + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - + - X1: 1 + - W1: s diff --git a/tutorial/tutorial09_pin2pin.gvpr b/tutorial/tutorial09_pin2pin.gvpr new file mode 100644 index 00000000..4c4e2878 --- /dev/null +++ b/tutorial/tutorial09_pin2pin.gvpr @@ -0,0 +1,57 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file