diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index e60a740..d57e8ff 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -13,7 +13,7 @@ if __name__== '__main__': sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from wireviz import wv_colors -from wireviz.wv_helper import nested, int2tuple, awg_equiv, flatten2d, tuplelist2tsv +from wireviz.wv_helper import nested, int2tuple, mm2_equiv, awg_equiv, flatten2d, tuplelist2tsv class Harness: @@ -117,8 +117,16 @@ class Harness: for k, c in self.cables.items(): # a = attributes + if c.show_equiv: + if c.gauge_unit == 'mm\u00B2': + gauge_equiv = ' ({} AWG)'.format(awg_equiv(c.gauge)) + else: + gauge_equiv = ' ({} mm\u00B2)'.format(mm2_equiv(c.gauge)) + else: + gauge_equiv = '' + a = ['{}x'.format(len(c.colors)) if c.show_wirecount else '', - '{} {}{}'.format(c.gauge, c.gauge_unit, ' ({} AWG)'.format(awg_equiv(c.gauge)) if c.gauge_unit == 'mm\u00B2' and c.show_equiv else '') if c.gauge else '', # TODO: show equiv + '{} {}{}'.format(c.gauge, c.gauge_unit, gauge_equiv) if c.gauge else '', '+ S' if c.shield else '', '{} m'.format(c.length) if c.length > 0 else ''] a = list(filter(None, a)) diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 49b9c3d..f44214a 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -1,27 +1,28 @@ -from typing import Any, List +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', + } +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, - } - 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(input): l = []