WireViz/examples/ex02.html
Andreas Nordin 08e53bcd48
Feature: bidirectional AWG/mm2 unit conversion (#41)
* Fix AWG<-> mm2 conversions

Add an inverted dictionary and a lookup function from awg -> mm2. Also
do some minor refactoring. Both sides of the conversion table were
converted to strings, since '0000' and '2/0' are perfectly valid AWG
values.

* Update example ex02 with awg -> mm2 conversion

Show conversions for ex02, and make sure it displays conversions in both
directions. Rebuild the example files.

* Fix faulty conversion of non-(mm2,AWG) units

The parsing allows arbitrary units to be used for cable dimensions --
this might be valid units, e.g. square inches, or invalid, e.g. bananas.
We only allow conversion between mm2 and AWG, so check that the
gauge_unit is either of those before conversion. If not, pass through as
is.

* Fix AWG string casing in output

Convert e.g. 'awg, 'AwG' to upper case for consistent rendering. Leave
any other input gauge units as they were.

Co-authored-by: Daniel Rojas <github@danielrojas.net>
2020-06-29 14:41:45 +02:00

258 lines
19 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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.44.0 (0)
-->
<!-- Pages: 1 -->
<svg width="913pt" height="446pt"
viewBox="0.00 0.00 913.00 446.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 442)">
<polygon fill="white" stroke="transparent" points="-4,4 -4,-442 909,-442 909,4 -4,4"/>
<!-- X1 -->
<g id="node1" class="node">
<title>X1</title>
<polygon fill="white" stroke="black" points="0,-166 0,-258 204,-258 204,-166 0,-166"/>
<text text-anchor="middle" x="102" y="-242.8" font-family="arial" font-size="14.00">X1</text>
<polyline fill="none" stroke="black" points="0,-235 204,-235 "/>
<text text-anchor="middle" x="55" y="-219.8" font-family="arial" font-size="14.00">Molex Micro&#45;Fit</text>
<polyline fill="none" stroke="black" points="110,-212 110,-235 "/>
<text text-anchor="middle" x="133.5" y="-219.8" font-family="arial" font-size="14.00">male</text>
<polyline fill="none" stroke="black" points="157,-212 157,-235 "/>
<text text-anchor="middle" x="180.5" y="-219.8" font-family="arial" font-size="14.00">2&#45;pin</text>
<polyline fill="none" stroke="black" points="0,-212 204,-212 "/>
<text text-anchor="middle" x="56.5" y="-196.8" font-family="arial" font-size="14.00">GND</text>
<polyline fill="none" stroke="black" points="0,-189 113,-189 "/>
<text text-anchor="middle" x="56.5" y="-173.8" font-family="arial" font-size="14.00">VCC</text>
<polyline fill="none" stroke="black" points="113,-166 113,-212 "/>
<text text-anchor="middle" x="158.5" y="-196.8" font-family="arial" font-size="14.00">1</text>
<polyline fill="none" stroke="black" points="113,-189 204,-189 "/>
<text text-anchor="middle" x="158.5" y="-173.8" font-family="arial" font-size="14.00">2</text>
</g>
<!-- W1 -->
<g id="node5" class="node">
<title>W1</title>
<polygon fill="none" stroke="black" points="546,-438 348,-438 348,-308 546,-308 546,-438"/>
<polygon fill="none" stroke="black" points="348,-415 348,-438 546,-438 546,-415 348,-415"/>
<text text-anchor="start" x="436" y="-422.8" font-family="arial" font-size="14.00">W1</text>
<polygon fill="none" stroke="black" points="348,-392 348,-415 371,-415 371,-392 348,-392"/>
<text text-anchor="start" x="352" y="-399.8" font-family="arial" font-size="14.00">2x</text>
<polygon fill="none" stroke="black" points="371,-392 371,-415 503,-415 503,-392 371,-392"/>
<text text-anchor="start" x="375" y="-399.8" font-family="arial" font-size="14.00">0.25 mm² (24 AWG)</text>
<polygon fill="none" stroke="black" points="503,-392 503,-415 546,-415 546,-392 503,-392"/>
<text text-anchor="start" x="507" y="-399.8" font-family="arial" font-size="14.00">0.2 m</text>
<text text-anchor="start" x="445" y="-380.8" font-family="arial" font-size="14.00"> </text>
<text text-anchor="start" x="368.5" y="-363.8" font-family="arial" font-size="14.00">X1:1</text>
<text text-anchor="start" x="438" y="-363.8" font-family="arial" font-size="14.00">BK</text>
<text text-anchor="start" x="498" y="-363.8" font-family="arial" font-size="14.00">X2:1</text>
<polygon fill="#000000" stroke="transparent" points="348,-352 348,-358 546,-358 546,-352 348,-352"/>
<polyline fill="none" stroke="black" stroke-width="2" points="349,-353 545,-353 "/>
<polyline fill="none" stroke="black" stroke-width="2" points="545,-357 349,-357 "/>
<text text-anchor="start" x="368.5" y="-338.8" font-family="arial" font-size="14.00">X1:2</text>
<text text-anchor="start" x="437.5" y="-338.8" font-family="arial" font-size="14.00">RD</text>
<text text-anchor="start" x="498" y="-338.8" font-family="arial" font-size="14.00">X2:2</text>
<polygon fill="#ff0000" stroke="transparent" stroke-width="2" points="348,-327 348,-333 546,-333 546,-327 348,-327"/>
<polyline fill="none" stroke="black" stroke-width="2" points="349,-328 545,-328 "/>
<polyline fill="none" stroke="black" stroke-width="2" points="545,-332 349,-332 "/>
<text text-anchor="start" x="380.5" y="-313.8" font-family="arial" font-size="14.00"> </text>
</g>
<!-- X1&#45;&#45;W1 -->
<g id="edge1" class="edge">
<title>X1:e&#45;&#45;W1:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-198C299.95,-200.55 255.89,-355.55 348,-353"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-200C298.03,-200 253.97,-355 348,-355"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-202C296.11,-199.45 252.05,-354.45 348,-357"/>
</g>
<!-- X1&#45;&#45;W1 -->
<g id="edge3" class="edge">
<title>X1:e&#45;&#45;W1:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-175C299.31,-177.54 256.55,-330.54 348,-328"/>
<path fill="none" stroke="#ff0000" stroke-width="2" d="M204,-177C297.38,-177 254.62,-330 348,-330"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-179C295.45,-176.46 252.69,-329.46 348,-332"/>
</g>
<!-- W2 -->
<g id="node6" class="node">
<title>W2</title>
<polygon fill="none" stroke="black" points="546,-284 348,-284 348,-154 546,-154 546,-284"/>
<polygon fill="none" stroke="black" points="348,-261 348,-284 546,-284 546,-261 348,-261"/>
<text text-anchor="start" x="436" y="-268.8" font-family="arial" font-size="14.00">W2</text>
<polygon fill="none" stroke="black" points="348,-238 348,-261 371,-261 371,-238 348,-238"/>
<text text-anchor="start" x="352" y="-245.8" font-family="arial" font-size="14.00">2x</text>
<polygon fill="none" stroke="black" points="371,-238 371,-261 503,-261 503,-238 371,-238"/>
<text text-anchor="start" x="375" y="-245.8" font-family="arial" font-size="14.00">0.25 mm² (24 AWG)</text>
<polygon fill="none" stroke="black" points="503,-238 503,-261 546,-261 546,-238 503,-238"/>
<text text-anchor="start" x="507" y="-245.8" font-family="arial" font-size="14.00">0.2 m</text>
<text text-anchor="start" x="445" y="-226.8" font-family="arial" font-size="14.00"> </text>
<text text-anchor="start" x="368.5" y="-209.8" font-family="arial" font-size="14.00">X1:1</text>
<text text-anchor="start" x="438" y="-209.8" font-family="arial" font-size="14.00">BK</text>
<text text-anchor="start" x="498" y="-209.8" font-family="arial" font-size="14.00">X3:1</text>
<polygon fill="#000000" stroke="transparent" points="348,-198 348,-204 546,-204 546,-198 348,-198"/>
<polyline fill="none" stroke="black" stroke-width="2" points="349,-199 545,-199 "/>
<polyline fill="none" stroke="black" stroke-width="2" points="545,-203 349,-203 "/>
<text text-anchor="start" x="368.5" y="-184.8" font-family="arial" font-size="14.00">X1:2</text>
<text text-anchor="start" x="437.5" y="-184.8" font-family="arial" font-size="14.00">RD</text>
<text text-anchor="start" x="498" y="-184.8" font-family="arial" font-size="14.00">X3:2</text>
<polygon fill="#ff0000" stroke="transparent" stroke-width="2" points="348,-173 348,-179 546,-179 546,-173 348,-173"/>
<polyline fill="none" stroke="black" stroke-width="2" points="349,-174 545,-174 "/>
<polyline fill="none" stroke="black" stroke-width="2" points="545,-178 349,-178 "/>
<text text-anchor="start" x="380.5" y="-159.8" font-family="arial" font-size="14.00"> </text>
</g>
<!-- X1&#45;&#45;W2 -->
<g id="edge5" class="edge">
<title>X1:e&#45;&#45;W2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-198C268.13,-198 284.12,-199 348,-199"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-200C268,-200 284,-201 348,-201"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-202C267.88,-202 283.87,-203 348,-203"/>
</g>
<!-- X1&#45;&#45;W2 -->
<g id="edge7" class="edge">
<title>X1:e&#45;&#45;W2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-175C267.88,-175 283.87,-174 348,-174"/>
<path fill="none" stroke="#ff0000" stroke-width="2" d="M204,-177C268,-177 284,-176 348,-176"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-179C268.13,-179 284.12,-178 348,-178"/>
</g>
<!-- W3 -->
<g id="node7" class="node">
<title>W3</title>
<polygon fill="none" stroke="black" points="541.5,-130 352.5,-130 352.5,0 541.5,0 541.5,-130"/>
<polygon fill="none" stroke="black" points="353,-107 353,-130 542,-130 542,-107 353,-107"/>
<text text-anchor="start" x="436.5" y="-114.8" font-family="arial" font-size="14.00">W3</text>
<polygon fill="none" stroke="black" points="353,-84 353,-107 376,-107 376,-84 353,-84"/>
<text text-anchor="start" x="357" y="-91.8" font-family="arial" font-size="14.00">2x</text>
<polygon fill="none" stroke="black" points="376,-84 376,-107 499,-107 499,-84 376,-84"/>
<text text-anchor="start" x="380" y="-91.8" font-family="arial" font-size="14.00">20 awg (0.75 mm²)</text>
<polygon fill="none" stroke="black" points="499,-84 499,-107 542,-107 542,-84 499,-84"/>
<text text-anchor="start" x="503" y="-91.8" font-family="arial" font-size="14.00">0.2 m</text>
<text text-anchor="start" x="445.5" y="-72.8" font-family="arial" font-size="14.00"> </text>
<text text-anchor="start" x="372" y="-55.8" font-family="arial" font-size="14.00">X1:1</text>
<text text-anchor="start" x="438.5" y="-55.8" font-family="arial" font-size="14.00">BK</text>
<text text-anchor="start" x="495.5" y="-55.8" font-family="arial" font-size="14.00">X4:1</text>
<polygon fill="#000000" stroke="transparent" points="353,-44 353,-50 542,-50 542,-44 353,-44"/>
<polyline fill="none" stroke="black" stroke-width="2" points="354,-45 541,-45 "/>
<polyline fill="none" stroke="black" stroke-width="2" points="541,-49 354,-49 "/>
<text text-anchor="start" x="372" y="-30.8" font-family="arial" font-size="14.00">X1:2</text>
<text text-anchor="start" x="438" y="-30.8" font-family="arial" font-size="14.00">RD</text>
<text text-anchor="start" x="495.5" y="-30.8" font-family="arial" font-size="14.00">X4:2</text>
<polygon fill="#ff0000" stroke="transparent" stroke-width="2" points="353,-19 353,-25 542,-25 542,-19 353,-19"/>
<polyline fill="none" stroke="black" stroke-width="2" points="354,-20 541,-20 "/>
<polyline fill="none" stroke="black" stroke-width="2" points="541,-24 354,-24 "/>
<text text-anchor="start" x="384" y="-5.8" font-family="arial" font-size="14.00"> </text>
</g>
<!-- X1&#45;&#45;W3 -->
<g id="edge9" class="edge">
<title>X1:e&#45;&#45;W3:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-198C296.68,-200.52 255.46,-47.52 352,-45"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-200C298.61,-200 257.39,-47 352,-47"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-202C300.54,-199.48 259.32,-46.48 352,-49"/>
</g>
<!-- X1&#45;&#45;W3 -->
<g id="edge11" class="edge">
<title>X1:e&#45;&#45;W3:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-175C297.32,-177.53 254.82,-22.53 352,-20"/>
<path fill="none" stroke="#ff0000" stroke-width="2" d="M204,-177C299.25,-177 256.75,-22 352,-22"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M204,-179C301.18,-176.47 258.68,-21.47 352,-24"/>
</g>
<!-- X2 -->
<g id="node2" class="node">
<title>X2</title>
<polygon fill="white" stroke="black" points="690,-320 690,-412 905,-412 905,-320 690,-320"/>
<text text-anchor="middle" x="797.5" y="-396.8" font-family="arial" font-size="14.00">X2</text>
<polyline fill="none" stroke="black" points="690,-389 905,-389 "/>
<text text-anchor="middle" x="745" y="-373.8" font-family="arial" font-size="14.00">Molex Micro&#45;Fit</text>
<polyline fill="none" stroke="black" points="800,-366 800,-389 "/>
<text text-anchor="middle" x="829" y="-373.8" font-family="arial" font-size="14.00">female</text>
<polyline fill="none" stroke="black" points="858,-366 858,-389 "/>
<text text-anchor="middle" x="881.5" y="-373.8" font-family="arial" font-size="14.00">2&#45;pin</text>
<polyline fill="none" stroke="black" points="690,-366 905,-366 "/>
<text text-anchor="middle" x="738" y="-350.8" font-family="arial" font-size="14.00">1</text>
<polyline fill="none" stroke="black" points="690,-343 786,-343 "/>
<text text-anchor="middle" x="738" y="-327.8" font-family="arial" font-size="14.00">2</text>
<polyline fill="none" stroke="black" points="786,-320 786,-366 "/>
<text text-anchor="middle" x="845.5" y="-350.8" font-family="arial" font-size="14.00">GND</text>
<polyline fill="none" stroke="black" points="786,-343 905,-343 "/>
<text text-anchor="middle" x="845.5" y="-327.8" font-family="arial" font-size="14.00">VCC</text>
</g>
<!-- X3 -->
<g id="node3" class="node">
<title>X3</title>
<polygon fill="white" stroke="black" points="690,-166 690,-258 905,-258 905,-166 690,-166"/>
<text text-anchor="middle" x="797.5" y="-242.8" font-family="arial" font-size="14.00">X3</text>
<polyline fill="none" stroke="black" points="690,-235 905,-235 "/>
<text text-anchor="middle" x="745" y="-219.8" font-family="arial" font-size="14.00">Molex Micro&#45;Fit</text>
<polyline fill="none" stroke="black" points="800,-212 800,-235 "/>
<text text-anchor="middle" x="829" y="-219.8" font-family="arial" font-size="14.00">female</text>
<polyline fill="none" stroke="black" points="858,-212 858,-235 "/>
<text text-anchor="middle" x="881.5" y="-219.8" font-family="arial" font-size="14.00">2&#45;pin</text>
<polyline fill="none" stroke="black" points="690,-212 905,-212 "/>
<text text-anchor="middle" x="738" y="-196.8" font-family="arial" font-size="14.00">1</text>
<polyline fill="none" stroke="black" points="690,-189 786,-189 "/>
<text text-anchor="middle" x="738" y="-173.8" font-family="arial" font-size="14.00">2</text>
<polyline fill="none" stroke="black" points="786,-166 786,-212 "/>
<text text-anchor="middle" x="845.5" y="-196.8" font-family="arial" font-size="14.00">GND</text>
<polyline fill="none" stroke="black" points="786,-189 905,-189 "/>
<text text-anchor="middle" x="845.5" y="-173.8" font-family="arial" font-size="14.00">VCC</text>
</g>
<!-- X4 -->
<g id="node4" class="node">
<title>X4</title>
<polygon fill="white" stroke="black" points="690,-12 690,-104 905,-104 905,-12 690,-12"/>
<text text-anchor="middle" x="797.5" y="-88.8" font-family="arial" font-size="14.00">X4</text>
<polyline fill="none" stroke="black" points="690,-81 905,-81 "/>
<text text-anchor="middle" x="745" y="-65.8" font-family="arial" font-size="14.00">Molex Micro&#45;Fit</text>
<polyline fill="none" stroke="black" points="800,-58 800,-81 "/>
<text text-anchor="middle" x="829" y="-65.8" font-family="arial" font-size="14.00">female</text>
<polyline fill="none" stroke="black" points="858,-58 858,-81 "/>
<text text-anchor="middle" x="881.5" y="-65.8" font-family="arial" font-size="14.00">2&#45;pin</text>
<polyline fill="none" stroke="black" points="690,-58 905,-58 "/>
<text text-anchor="middle" x="738" y="-42.8" font-family="arial" font-size="14.00">1</text>
<polyline fill="none" stroke="black" points="690,-35 786,-35 "/>
<text text-anchor="middle" x="738" y="-19.8" font-family="arial" font-size="14.00">2</text>
<polyline fill="none" stroke="black" points="786,-12 786,-58 "/>
<text text-anchor="middle" x="845.5" y="-42.8" font-family="arial" font-size="14.00">GND</text>
<polyline fill="none" stroke="black" points="786,-35 905,-35 "/>
<text text-anchor="middle" x="845.5" y="-19.8" font-family="arial" font-size="14.00">VCC</text>
</g>
<!-- W1&#45;&#45;X2 -->
<g id="edge2" class="edge">
<title>W1:e&#45;&#45;X2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-353C609.88,-353 625.87,-352 690,-352"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-355C610,-355 626,-354 690,-354"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-357C610.13,-357 626.12,-356 690,-356"/>
</g>
<!-- W1&#45;&#45;X2 -->
<g id="edge4" class="edge">
<title>W1:e&#45;&#45;X2:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-328C610.13,-328 626.12,-329 690,-329"/>
<path fill="none" stroke="#ff0000" stroke-width="2" d="M546,-330C610,-330 626,-331 690,-331"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-332C609.88,-332 625.87,-333 690,-333"/>
</g>
<!-- W2&#45;&#45;X3 -->
<g id="edge6" class="edge">
<title>W2:e&#45;&#45;X3:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-199C609.88,-199 625.87,-198 690,-198"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-201C610,-201 626,-200 690,-200"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-203C610.13,-203 626.12,-202 690,-202"/>
</g>
<!-- W2&#45;&#45;X3 -->
<g id="edge8" class="edge">
<title>W2:e&#45;&#45;X3:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-174C610.13,-174 626.12,-175 690,-175"/>
<path fill="none" stroke="#ff0000" stroke-width="2" d="M546,-176C610,-176 626,-177 690,-177"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M546,-178C609.88,-178 625.87,-179 690,-179"/>
</g>
<!-- W3&#45;&#45;X4 -->
<g id="edge10" class="edge">
<title>W3:e&#45;&#45;X4:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M543,-45C608.21,-45 624.54,-44 690,-44"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M543,-47C608.33,-47 624.67,-46 690,-46"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M543,-49C608.46,-49 624.79,-48 690,-48"/>
</g>
<!-- W3&#45;&#45;X4 -->
<g id="edge12" class="edge">
<title>W3:e&#45;&#45;X4:w</title>
<path fill="none" stroke="#000000" stroke-width="2" d="M543,-20C608.46,-20 624.79,-21 690,-21"/>
<path fill="none" stroke="#ff0000" stroke-width="2" d="M543,-22C608.33,-22 624.67,-23 690,-23"/>
<path fill="none" stroke="#000000" stroke-width="2" d="M543,-24C608.21,-24 624.54,-25 690,-25"/>
</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, Molex Micro-Fit, female, 2 pins</td><td align="right" style="border:1px solid #000000; padding: 4px">3</td><td style="border:1px solid #000000; padding: 4px"></td><td style="border:1px solid #000000; padding: 4px">X2, X3, X4</td></tr><tr><td style="border:1px solid #000000; padding: 4px">Connector, Molex Micro-Fit, male, 2 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 0.25 mm²</td><td align="right" style="border:1px solid #000000; padding: 4px">0.4</td><td style="border:1px solid #000000; padding: 4px">m</td><td style="border:1px solid #000000; padding: 4px">W1, W2</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">0.2</td><td style="border:1px solid #000000; padding: 4px">m</td><td style="border:1px solid #000000; padding: 4px">W3</td></tr></table></body></html>