diff --git a/README.md b/README.md index 3b90b58..abf8db7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ WireViz is a tool for easily documenting cables, wiring harnesses and connector * [DIN 47100](https://en.wikipedia.org/wiki/DIN_47100) (WT/BN/GN/YE/GY/PK/BU/RD/BK/VT/...) * [IEC 62](https://en.wikipedia.org/wiki/Electronic_color_code#Color_band_system) (BN/RD/OR/YE/GN/BU/VT/GY/WT/BK/...) * Understands wire gauge in mm² or AWG - * Optionally auto-calculates and displays AWG equivalent when specifying mm² + * Optionally auto-calculates equivalent gauge between mm² and AWG * 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) diff --git a/examples/ex02.bom.tsv b/examples/ex02.bom.tsv index 4c8d11e..67cb7f0 100644 --- a/examples/ex02.bom.tsv +++ b/examples/ex02.bom.tsv @@ -1,4 +1,5 @@ Item Qty Unit Designators Connector, Molex Micro-Fit, female, 2 pins 3 X2, X3, X4 Connector, Molex Micro-Fit, male, 2 pins 1 X1 -Cable, 2 x 0.25 mm² 0.6 m W1, W2, W3 +Cable, 2 x 0.25 mm² 0.4 m W1, W2 +Cable, 2 x 20 AWG 0.2 m W3 diff --git a/examples/ex02.gv b/examples/ex02.gv index b914864..8f29aaf 100644 --- a/examples/ex02.gv +++ b/examples/ex02.gv @@ -28,5 +28,5 @@ graph { edge [color="#000000:#ff0000:#000000"] X1:p2r:e -- W3:w2:w W3:w2:e -- X4:p2l:w - W3 [label=<
W3
2x0.25 mm² (24 AWG)0.2 m
 
X1:1BKX4:1
X1:2RDX4:2
 
> fillcolor=white margin=0 shape=box style=""] + W3 [label=<
W3
2x20 AWG (0.75 mm²)0.2 m
 
X1:1BKX4:1
X1:2RDX4:2
 
> fillcolor=white margin=0 shape=box style=""] } diff --git a/examples/ex02.html b/examples/ex02.html index 148fa57..be3f0ab 100644 --- a/examples/ex02.html +++ b/examples/ex02.html @@ -119,7 +119,7 @@ 2x -0.25 mm² (24 AWG) +20 AWG (0.75 mm²) 0.2 m   @@ -255,4 +255,4 @@ -

Bill of Materials

ItemQtyUnitDesignators
Connector, Molex Micro-Fit, female, 2 pins3X2, X3, X4
Connector, Molex Micro-Fit, male, 2 pins1X1
Cable, 2 x 0.25 mm²0.6mW1, W2, W3
\ No newline at end of file +

Bill of Materials

ItemQtyUnitDesignators
Connector, Molex Micro-Fit, female, 2 pins3X2, X3, X4
Connector, Molex Micro-Fit, male, 2 pins1X1
Cable, 2 x 0.25 mm²0.4mW1, W2
Cable, 2 x 20 AWG0.2mW3
\ No newline at end of file diff --git a/examples/ex02.png b/examples/ex02.png index 7dbb395..28d54eb 100644 Binary files a/examples/ex02.png and b/examples/ex02.png differ diff --git a/examples/ex02.svg b/examples/ex02.svg index 6ddeb7b..5de828e 100644 --- a/examples/ex02.svg +++ b/examples/ex02.svg @@ -119,7 +119,7 @@ 2x -0.25 mm² (24 AWG) +20 AWG (0.75 mm²) 0.2 m   diff --git a/examples/ex02.yml b/examples/ex02.yml index 056e6fe..8a671e6 100644 --- a/examples/ex02.yml +++ b/examples/ex02.yml @@ -22,6 +22,7 @@ cables: <<: *wire_power # create from template W3: <<: *wire_power # create from template + gauge: 20 awg connections: - diff --git a/examples/ex08.gv b/examples/ex08.gv index a949333..2e189bb 100644 --- a/examples/ex08.gv +++ b/examples/ex08.gv @@ -4,7 +4,7 @@ graph { 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] - Key [label="Key|{Phone Connector|male 3.5|3-pin}|{{Dot|Dash|Ground}|{T|R|S}}"] + Key [label="Key|{Phone Connector|male 3.5}|{{Dot|Dash|Ground}|{T|R|S}}"] edge [color="#000000:#ffffff:#000000"] Key:pSr:e -- W1:w1:w edge [color="#000000:#666600:#000000"] diff --git a/examples/ex08.html b/examples/ex08.html index c290a0f..854d239 100644 --- a/examples/ex08.html +++ b/examples/ex08.html @@ -4,95 +4,93 @@ - + - + Key - -Key - + +Key + Phone Connector male 3.5 - -3-pin - -Dot - -Dash - -Ground - -T - -R - -S + +Dot + +Dash + +Ground + +T + +R + +S W1 - - -W1 - -3x - -24 AWG - -+ S - -0.2 m -  -Key:S -WH - - - -Key:R -BN - - - -Key:T -GN - - - -  -Key:S -Shield - -  + + +W1 + +3x + +24 AWG + ++ S + +0.2 m +  +Key:S +WH + + + +Key:R +BN + + + +Key:T +GN + + + +  +Key:S +Shield + +  Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - + diff --git a/examples/ex08.png b/examples/ex08.png index a0270f7..7767320 100644 Binary files a/examples/ex08.png and b/examples/ex08.png differ diff --git a/examples/ex08.svg b/examples/ex08.svg index 0599c11..630f541 100644 --- a/examples/ex08.svg +++ b/examples/ex08.svg @@ -4,95 +4,93 @@ - + - + Key - -Key - + +Key + Phone Connector male 3.5 - -3-pin - -Dot - -Dash - -Ground - -T - -R - -S + +Dot + +Dash + +Ground + +T + +R + +S W1 - - -W1 - -3x - -24 AWG - -+ S - -0.2 m -  -Key:S -WH - - - -Key:R -BN - - - -Key:T -GN - - - -  -Key:S -Shield - -  + + +W1 + +3x + +24 AWG + ++ S + +0.2 m +  +Key:S +WH + + + +Key:R +BN + + + +Key:T +GN + + + +  +Key:S +Shield + +  Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - + diff --git a/examples/ex08.yml b/examples/ex08.yml index 0d42be5..e65813a 100644 --- a/examples/ex08.yml +++ b/examples/ex08.yml @@ -6,6 +6,7 @@ connectors: subtype: male 3.5 pinnumbers: [T, R, S] pinout: [Dot, Dash, Ground] + show_pincount: false cables: W1: diff --git a/setup.py b/setup.py index 83dbc55..950e314 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( ], license='GPLv3', keywords='cable connector hardware harness wiring wiring-diagram wiring-harness', - url='https://github.com/n42/WireViz', + url='https://github.com/formatc1702/WireViz', package_dir={'': 'src'}, packages=find_packages('src'), entry_points={ diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index a2f2a9e..6bc9eb8 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -83,7 +83,12 @@ class Cable: except Exception: 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') + + if u.upper() == 'AWG': + self.gauge_unit = u.upper() + else: + 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' diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index c11ad9a..c50384e 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -4,7 +4,7 @@ from wireviz.DataClasses import Connector, Cable from graphviz import Graph from wireviz import wv_colors -from wireviz.wv_helper import awg_equiv, tuplelist2tsv, nested, flatten2d +from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, flatten2d from collections import Counter from typing import List @@ -113,9 +113,19 @@ class Harness: f'{connector.name}:p{loop[1]}{loop_side}:{loop_dir}') for _, cable in self.cables.items(): - awg_fmt = f' ({awg_equiv(cable.gauge)} AWG)' if cable.gauge_unit == 'mm\u00B2' and cable.show_equiv else '' + + awg_fmt = '' + if cable.show_equiv: + # Only convert units we actually know about, i.e. currently + # mm2 and awg --- other units _are_ technically allowed, + # and passed through as-is. + if cable.gauge_unit =='mm\u00B2': + awg_fmt = f' ({awg_equiv(cable.gauge)} AWG)' + elif cable.gauge_unit.upper() == 'AWG': + awg_fmt = f' ({mm2_equiv(cable.gauge)} mm\u00B2)' + attributes = [f'{len(cable.colors)}x' if cable.show_wirecount else '', - f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else '', # TODO: show equiv + f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else '', '+ S' if cable.shield else '', f'{cable.length} m' if cable.length > 0 else ''] attributes = list(filter(None, attributes)) diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 65ccdb3..222fd74 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -3,32 +3,32 @@ from typing import List +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', + '35': '2', + '50': '1', +} + +mm2_equiv_table = {v:k for k,v in awg_equiv_table.items()} 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, - '35': 2, - '50': 1, - } - k = str(mm2) - if k in awg_equiv_table: - return awg_equiv_table[k] - else: - return 'unknown' + return awg_equiv_table.get(str(mm2), 'Unknown') +def mm2_equiv(awg): + return mm2_equiv_table.get(str(awg), 'Unknown') def nested(inp): l = []