implemented functionality to hide pins that are not connected

This commit is contained in:
Morrison-Reed Elliot (BEG/EVS1-NA) 2020-06-24 11:45:05 -04:00
parent 66a47169e6
commit c3621498a7
9 changed files with 268 additions and 2 deletions

4
examples/ex07.bom.tsv Normal file
View File

@ -0,0 +1,4 @@
Item Qty Unit Designators
Connector, D-Sub, female, 9 pins 1 X2
Connector, TE 776164-1, female, 35 pins 1 X1
Cable, 2 x 20 AWG 1 m C1
1 Item Qty Unit Designators
2 Connector, D-Sub, female, 9 pins 1 X2
3 Connector, TE 776164-1, female, 35 pins 1 X1
4 Cable, 2 x 20 AWG 1 m C1

16
examples/ex07.gv Normal file
View File

@ -0,0 +1,16 @@
graph {
// Graph generated by WireViz
// https://github.com/formatc1702/WireViz
graph [bgcolor=white fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor=white fontname=arial shape=record style=filled]
edge [fontname=arial style=bold]
X1 [label="X1|{TE 776164-1|female|35-pin}|{{<p5r>5|<p6r>6}}"]
X2 [label="X2|{D-Sub|female|9-pin}|{{<p2l>2|<p7l>7}}"]
edge [color="#000000:#ffff00:#000000"]
X1:p5r:e -- C1:w1:w
C1:w1:e -- X2:p7l:w
edge [color="#000000:#00ff00:#000000"]
X1:p6r:e -- C1:w2:w
C1:w2:e -- X2:p2l:w
C1 [label=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td colspan="3">C1</td></tr><tr><td>2x</td><td>20 AWG</td><td>1 m</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td><table border="0" cellspacing="0" cellborder="0"><tr><td>X1:5</td><td>YE</td><td>X2:7</td></tr><tr><td colspan="3" cellpadding="0" height="6" bgcolor="#ffff00" border="2" sides="tb" port="w1"></td></tr><tr><td>X1:6</td><td>GN</td><td>X2:2</td></tr><tr><td colspan="3" cellpadding="0" height="6" bgcolor="#00ff00" border="2" sides="tb" port="w2"></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table>> fillcolor=white margin=0 shape=box style=""]
}

101
examples/ex07.html Normal file
View File

@ -0,0 +1,101 @@
<html><body style="font-family:Arial"><h1>Diagram</h1><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: %3 Pages: 1 -->
<svg width="800pt" height="138pt"
viewBox="0.00 0.00 800.00 138.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 134)">
<title>%3</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-134 796,-134 796,4 -4,4"/>
<!-- X1 -->
<g id="node1" class="node">
<title>X1</title>
<polygon fill="#ffffff" stroke="#000000" points="0,-12 0,-104 218,-104 218,-12 0,-12"/>
<text text-anchor="middle" x="109" y="-88.8" font-family="arial" font-size="14.00" fill="#000000">X1</text>
<polyline fill="none" stroke="#000000" points="0,-81 218,-81 "/>
<text text-anchor="middle" x="50.5" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">TE 776164&#45;1</text>
<polyline fill="none" stroke="#000000" points="101,-58 101,-81 "/>
<text text-anchor="middle" x="131" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">female</text>
<polyline fill="none" stroke="#000000" points="161,-58 161,-81 "/>
<text text-anchor="middle" x="189.5" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">35&#45;pin</text>
<polyline fill="none" stroke="#000000" points="0,-58 218,-58 "/>
<text text-anchor="middle" x="109" y="-42.8" font-family="arial" font-size="14.00" fill="#000000">5</text>
<polyline fill="none" stroke="#000000" points="0,-35 218,-35 "/>
<text text-anchor="middle" x="109" y="-19.8" font-family="arial" font-size="14.00" fill="#000000">6</text>
</g>
<!-- C1 -->
<g id="node3" class="node">
<title>C1</title>
<polygon fill="none" stroke="#000000" points="481,-130 362,-130 362,0 481,0 481,-130"/>
<polygon fill="none" stroke="#000000" points="362.5,-107 362.5,-130 481.5,-130 481.5,-107 362.5,-107"/>
<text text-anchor="start" x="412.5" y="-114.8" font-family="arial" font-size="14.00" fill="#000000">C1</text>
<polygon fill="none" stroke="#000000" points="362.5,-84 362.5,-107 386.5,-107 386.5,-84 362.5,-84"/>
<text text-anchor="start" x="366.5" y="-91.8" font-family="arial" font-size="14.00" fill="#000000">2x</text>
<polygon fill="none" stroke="#000000" points="386.5,-84 386.5,-107 448.5,-107 448.5,-84 386.5,-84"/>
<text text-anchor="start" x="390.5" y="-91.8" font-family="arial" font-size="14.00" fill="#000000">20 AWG</text>
<polygon fill="none" stroke="#000000" points="448.5,-84 448.5,-107 481.5,-107 481.5,-84 448.5,-84"/>
<text text-anchor="start" x="452.5" y="-91.8" font-family="arial" font-size="14.00" fill="#000000">1 m</text>
<text text-anchor="start" x="420" y="-72.8" font-family="arial" font-size="14.00" fill="#000000"> </text>
<text text-anchor="start" x="368.5" y="-55.8" font-family="arial" font-size="14.00" fill="#000000">X1:5</text>
<text text-anchor="start" x="412.5" y="-55.8" font-family="arial" font-size="14.00" fill="#000000">YE</text>
<text text-anchor="start" x="445" y="-55.8" font-family="arial" font-size="14.00" fill="#000000">X2:7</text>
<polygon fill="#ffff00" stroke="transparent" points="362.5,-44 362.5,-50 481.5,-50 481.5,-44 362.5,-44"/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="363.5,-45 480.5,-45 "/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="480.5,-49 363.5,-49 "/>
<text text-anchor="start" x="368.5" y="-30.8" font-family="arial" font-size="14.00" fill="#000000">X1:6</text>
<text text-anchor="start" x="411.5" y="-30.8" font-family="arial" font-size="14.00" fill="#000000">GN</text>
<text text-anchor="start" x="445" y="-30.8" font-family="arial" font-size="14.00" fill="#000000">X2:2</text>
<polygon fill="#00ff00" stroke="transparent" stroke-width="2" points="362.5,-19 362.5,-25 481.5,-25 481.5,-19 362.5,-19"/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="363.5,-20 480.5,-20 "/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="480.5,-24 363.5,-24 "/>
<text text-anchor="start" x="382" y="-5.8" font-family="arial" font-size="14.00" fill="#000000"> </text>
</g>
<!-- X1&#45;&#45;C1 -->
<g id="edge1" class="edge">
<title>X1:e&#45;&#45;C1:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-44C282.3481,-44.0039 298.4006,-45.0039 362.5,-45"/>
<path fill="none" stroke="#ffff00" stroke-width="2" d="M218,-46C282.2238,-46 298.2762,-47 362.5,-47"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-48C282.0994,-47.9961 298.1519,-48.9961 362.5,-49"/>
</g>
<!-- X1&#45;&#45;C1 -->
<g id="edge3" class="edge">
<title>X1:e&#45;&#45;C1:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-21C282.0994,-21.0039 298.1519,-20.0039 362.5,-20"/>
<path fill="none" stroke="#00ff00" stroke-width="2" d="M218,-23C282.2238,-23 298.2762,-22 362.5,-22"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-25C282.3481,-24.9961 298.4006,-23.9961 362.5,-24"/>
</g>
<!-- X2 -->
<g id="node2" class="node">
<title>X2</title>
<polygon fill="#ffffff" stroke="#000000" points="625,-12 625,-104 792,-104 792,-12 625,-12"/>
<text text-anchor="middle" x="708.5" y="-88.8" font-family="arial" font-size="14.00" fill="#000000">X2</text>
<polyline fill="none" stroke="#000000" points="625,-81 792,-81 "/>
<text text-anchor="middle" x="654" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">D&#45;Sub</text>
<polyline fill="none" stroke="#000000" points="683,-58 683,-81 "/>
<text text-anchor="middle" x="713" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">female</text>
<polyline fill="none" stroke="#000000" points="743,-58 743,-81 "/>
<text text-anchor="middle" x="767.5" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">9&#45;pin</text>
<polyline fill="none" stroke="#000000" points="625,-58 792,-58 "/>
<text text-anchor="middle" x="708.5" y="-42.8" font-family="arial" font-size="14.00" fill="#000000">2</text>
<polyline fill="none" stroke="#000000" points="625,-35 792,-35 "/>
<text text-anchor="middle" x="708.5" y="-19.8" font-family="arial" font-size="14.00" fill="#000000">7</text>
</g>
<!-- C1&#45;&#45;X2 -->
<g id="edge2" class="edge">
<title>C1:e&#45;&#45;X2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-45C544.1626,-45.9797 558.397,-21.9797 625,-21"/>
<path fill="none" stroke="#ffff00" stroke-width="2" d="M481,-47C545.8828,-47 560.1172,-23 625,-23"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-49C547.603,-48.0203 561.8374,-24.0203 625,-25"/>
</g>
<!-- C1&#45;&#45;X2 -->
<g id="edge4" class="edge">
<title>C1:e&#45;&#45;X2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-20C547.603,-20.9797 561.8374,-44.9797 625,-44"/>
<path fill="none" stroke="#00ff00" stroke-width="2" d="M481,-22C545.8828,-22 560.1172,-46 625,-46"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-24C544.1626,-23.0203 558.397,-47.0203 625,-48"/>
</g>
</g>
</svg>
<h1>Bill of Materials</h1><table style="border:1px solid #000000; font-size: 14pt; border-spacing: 0px"><tr><th align="left" style="border:1px solid #000000; padding: 8px">Item</th><th align="left" style="border:1px solid #000000; padding: 8px">Qty</th><th align="left" style="border:1px solid #000000; padding: 8px">Unit</th><th align="left" style="border:1px solid #000000; padding: 8px">Designators</th></tr><tr><td style="border:1px solid #000000; padding: 4px">Connector, D-Sub, female, 9 pins</td><td align="right" style="border:1px solid #000000; padding: 4px">1</td><td style="border:1px solid #000000; padding: 4px"></td><td style="border:1px solid #000000; padding: 4px">X2</td></tr><tr><td style="border:1px solid #000000; padding: 4px">Connector, TE 776164-1, female, 35 pins</td><td align="right" style="border:1px solid #000000; padding: 4px">1</td><td style="border:1px solid #000000; padding: 4px"></td><td style="border:1px solid #000000; padding: 4px">X1</td></tr><tr><td style="border:1px solid #000000; padding: 4px">Cable, 2 x 20 AWG</td><td align="right" style="border:1px solid #000000; padding: 4px">1</td><td style="border:1px solid #000000; padding: 4px">m</td><td style="border:1px solid #000000; padding: 4px">C1</td></tr></table></body></html>

BIN
examples/ex07.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

100
examples/ex07.svg Normal file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: %3 Pages: 1 -->
<svg width="800pt" height="138pt"
viewBox="0.00 0.00 800.00 138.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 134)">
<title>%3</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-134 796,-134 796,4 -4,4"/>
<!-- X1 -->
<g id="node1" class="node">
<title>X1</title>
<polygon fill="#ffffff" stroke="#000000" points="0,-12 0,-104 218,-104 218,-12 0,-12"/>
<text text-anchor="middle" x="109" y="-88.8" font-family="arial" font-size="14.00" fill="#000000">X1</text>
<polyline fill="none" stroke="#000000" points="0,-81 218,-81 "/>
<text text-anchor="middle" x="50.5" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">TE 776164&#45;1</text>
<polyline fill="none" stroke="#000000" points="101,-58 101,-81 "/>
<text text-anchor="middle" x="131" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">female</text>
<polyline fill="none" stroke="#000000" points="161,-58 161,-81 "/>
<text text-anchor="middle" x="189.5" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">35&#45;pin</text>
<polyline fill="none" stroke="#000000" points="0,-58 218,-58 "/>
<text text-anchor="middle" x="109" y="-42.8" font-family="arial" font-size="14.00" fill="#000000">5</text>
<polyline fill="none" stroke="#000000" points="0,-35 218,-35 "/>
<text text-anchor="middle" x="109" y="-19.8" font-family="arial" font-size="14.00" fill="#000000">6</text>
</g>
<!-- C1 -->
<g id="node3" class="node">
<title>C1</title>
<polygon fill="none" stroke="#000000" points="481,-130 362,-130 362,0 481,0 481,-130"/>
<polygon fill="none" stroke="#000000" points="362.5,-107 362.5,-130 481.5,-130 481.5,-107 362.5,-107"/>
<text text-anchor="start" x="412.5" y="-114.8" font-family="arial" font-size="14.00" fill="#000000">C1</text>
<polygon fill="none" stroke="#000000" points="362.5,-84 362.5,-107 386.5,-107 386.5,-84 362.5,-84"/>
<text text-anchor="start" x="366.5" y="-91.8" font-family="arial" font-size="14.00" fill="#000000">2x</text>
<polygon fill="none" stroke="#000000" points="386.5,-84 386.5,-107 448.5,-107 448.5,-84 386.5,-84"/>
<text text-anchor="start" x="390.5" y="-91.8" font-family="arial" font-size="14.00" fill="#000000">20 AWG</text>
<polygon fill="none" stroke="#000000" points="448.5,-84 448.5,-107 481.5,-107 481.5,-84 448.5,-84"/>
<text text-anchor="start" x="452.5" y="-91.8" font-family="arial" font-size="14.00" fill="#000000">1 m</text>
<text text-anchor="start" x="420" y="-72.8" font-family="arial" font-size="14.00" fill="#000000"> </text>
<text text-anchor="start" x="368.5" y="-55.8" font-family="arial" font-size="14.00" fill="#000000">X1:5</text>
<text text-anchor="start" x="412.5" y="-55.8" font-family="arial" font-size="14.00" fill="#000000">YE</text>
<text text-anchor="start" x="445" y="-55.8" font-family="arial" font-size="14.00" fill="#000000">X2:7</text>
<polygon fill="#ffff00" stroke="transparent" points="362.5,-44 362.5,-50 481.5,-50 481.5,-44 362.5,-44"/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="363.5,-45 480.5,-45 "/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="480.5,-49 363.5,-49 "/>
<text text-anchor="start" x="368.5" y="-30.8" font-family="arial" font-size="14.00" fill="#000000">X1:6</text>
<text text-anchor="start" x="411.5" y="-30.8" font-family="arial" font-size="14.00" fill="#000000">GN</text>
<text text-anchor="start" x="445" y="-30.8" font-family="arial" font-size="14.00" fill="#000000">X2:2</text>
<polygon fill="#00ff00" stroke="transparent" stroke-width="2" points="362.5,-19 362.5,-25 481.5,-25 481.5,-19 362.5,-19"/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="363.5,-20 480.5,-20 "/>
<polyline fill="none" stroke="#000000" stroke-width="2" points="480.5,-24 363.5,-24 "/>
<text text-anchor="start" x="382" y="-5.8" font-family="arial" font-size="14.00" fill="#000000"> </text>
</g>
<!-- X1&#45;&#45;C1 -->
<g id="edge1" class="edge">
<title>X1:e&#45;&#45;C1:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-44C282.3481,-44.0039 298.4006,-45.0039 362.5,-45"/>
<path fill="none" stroke="#ffff00" stroke-width="2" d="M218,-46C282.2238,-46 298.2762,-47 362.5,-47"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-48C282.0994,-47.9961 298.1519,-48.9961 362.5,-49"/>
</g>
<!-- X1&#45;&#45;C1 -->
<g id="edge3" class="edge">
<title>X1:e&#45;&#45;C1:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-21C282.0994,-21.0039 298.1519,-20.0039 362.5,-20"/>
<path fill="none" stroke="#00ff00" stroke-width="2" d="M218,-23C282.2238,-23 298.2762,-22 362.5,-22"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M218,-25C282.3481,-24.9961 298.4006,-23.9961 362.5,-24"/>
</g>
<!-- X2 -->
<g id="node2" class="node">
<title>X2</title>
<polygon fill="#ffffff" stroke="#000000" points="625,-12 625,-104 792,-104 792,-12 625,-12"/>
<text text-anchor="middle" x="708.5" y="-88.8" font-family="arial" font-size="14.00" fill="#000000">X2</text>
<polyline fill="none" stroke="#000000" points="625,-81 792,-81 "/>
<text text-anchor="middle" x="654" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">D&#45;Sub</text>
<polyline fill="none" stroke="#000000" points="683,-58 683,-81 "/>
<text text-anchor="middle" x="713" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">female</text>
<polyline fill="none" stroke="#000000" points="743,-58 743,-81 "/>
<text text-anchor="middle" x="767.5" y="-65.8" font-family="arial" font-size="14.00" fill="#000000">9&#45;pin</text>
<polyline fill="none" stroke="#000000" points="625,-58 792,-58 "/>
<text text-anchor="middle" x="708.5" y="-42.8" font-family="arial" font-size="14.00" fill="#000000">2</text>
<polyline fill="none" stroke="#000000" points="625,-35 792,-35 "/>
<text text-anchor="middle" x="708.5" y="-19.8" font-family="arial" font-size="14.00" fill="#000000">7</text>
</g>
<!-- C1&#45;&#45;X2 -->
<g id="edge2" class="edge">
<title>C1:e&#45;&#45;X2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-45C544.1626,-45.9797 558.397,-21.9797 625,-21"/>
<path fill="none" stroke="#ffff00" stroke-width="2" d="M481,-47C545.8828,-47 560.1172,-23 625,-23"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-49C547.603,-48.0203 561.8374,-24.0203 625,-25"/>
</g>
<!-- C1&#45;&#45;X2 -->
<g id="edge4" class="edge">
<title>C1:e&#45;&#45;X2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-20C547.603,-20.9797 561.8374,-44.9797 625,-44"/>
<path fill="none" stroke="#00ff00" stroke-width="2" d="M481,-22C545.8828,-22 560.1172,-46 625,-46"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M481,-24C544.1626,-23.0203 558.397,-47.0203 625,-48"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.9 KiB

25
examples/ex07.yml Normal file
View File

@ -0,0 +1,25 @@
connectors:
X1:
type: TE 776164-1
subtype: female
hide_disconnected_pins: True
pincount: 35
X2:
type: D-Sub
subtype: female
pincount: 9
hide_disconnected_pins: True
cables:
C1:
wirecount: 2
gauge: 20 AWG
colors: [YE, GN]
length: 1
connections:
-
- X1: [5,6]
- C1: [1,2]
- X2: [7,2]

View File

@ -35,3 +35,9 @@
[Source](ex06.yml) - [Bill of Materials](ex06.bom.tsv)
## Example 07
![](ex07.png)
[Source](ex07.yml) - [Bill of Materials](ex07.bom.tsv)

View File

@ -2,7 +2,7 @@ import wireviz
import os
demos = 0 # 2
examples = 0 # 6
examples = 0 # 7
tutorials = 7 # 7
if demos:

View File

@ -27,6 +27,10 @@ class Harness:
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)
if from_name in self.connectors:
self.connectors[from_name].activate_pin(from_pin)
if to_name in self.connectors:
self.connectors[to_name].activate_pin(to_pin)
def create_graph(self):
dot = Graph()
@ -85,8 +89,10 @@ class Harness:
'{}-pin'.format(len(n.pinout)) if n.show_pincount else '']
# p = pinout
p = [[],[],[]]
p[1] = list(n.pinout)
for i, x in enumerate(n.pinout, 1):
if n.hide_disconnected_pins and not n.visible_pins.get(i, False):
continue
p[1].append(x)
if n.ports_left:
p[0].append('<p{portno}l>{portno}'.format(portno=i))
if n.ports_right:
@ -321,11 +327,13 @@ class Connector:
color: str = None
show_name: bool = True
show_pincount: bool = True
hide_disconnected_pins: bool = False
def __post_init__(self):
self.ports_left = False
self.ports_right = False
self.loops = []
self.visible_pins = {}
if self.pinout:
if self.pincount is not None:
@ -339,6 +347,12 @@ class Connector:
def loop(self, from_pin, to_pin):
self.loops.append((from_pin, to_pin))
if self.hide_disconnected_pins:
self.visible_pins[from_pin] = True
self.visible_pins[to_pin] = True
def activate_pin(self, pin):
self.visible_pins[pin] = True
@dataclass
class Cable: