diff --git a/examples/ex16.bom.tsv b/examples/ex16.bom.tsv
new file mode 100644
index 0000000..dd1dfe8
--- /dev/null
+++ b/examples/ex16.bom.tsv
@@ -0,0 +1,3 @@
+Id Description Qty Unit Designators
+1 Cable, Serial, 4 x 0.25 mm² shielded 0.2 m W1
+2 Connector, Molex KK 254, female, 7 pins 2 X1, X2
diff --git a/examples/ex16.gv b/examples/ex16.gv
new file mode 100644
index 0000000..cfbaae9
--- /dev/null
+++ b/examples/ex16.gv
@@ -0,0 +1,236 @@
+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 [color="#000000:#FF66CC:#000000"]
+ X1:p1r:e -- X1:p5r:e
+ X1:p5r:e -- X1:p7r:e
+ edge [color="#FF0000" headclip=false style="solid,bold" tailclip=false]
+ X1:p2j:c -- X1:p6j:c [straight=straight]
+ edge [headclip=true style=bold tailclip=true]
+ X1 [label=<
+
+ |
+
+ |
+
+
+ | Molex KK 254 |
+ female |
+ 7-pin |
+
+ |
+
+
+
+ |
+ SH2 |
+ |
+
+
+ | GND |
+ |
+ 1 |
+
+
+ | VCC |
+ ⬤ |
+ 2 |
+
+
+ | RX |
+ |
+ 3 |
+
+
+ | TX |
+ |
+ 4 |
+
+
+ | GND |
+ |
+ 5 |
+
+
+ | VCC |
+ ⬤ |
+ 6 |
+
+
+ | GND |
+ |
+ 7 |
+
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+ edge [color="#000000:#000000:#000000"]
+ X2:p1l:w -- X2:p5l:w
+ X2:p5l:w -- X2:p7l:w
+ edge [color="#000000:#000000:#000000"]
+ X2:p2l:w -- X2:p6l:w
+ edge [headclip=true style=bold tailclip=true]
+ X2 [label=<
+
+ |
+
+ |
+
+
+ | Molex KK 254 |
+ female |
+ 7-pin |
+
+ |
+
+
+
+ | 1 |
+ GND |
+
+
+ | 2 |
+ VCC |
+
+
+ | 3 |
+ RX |
+
+
+ | 4 |
+ TX |
+
+
+ | 5 |
+ GND |
+
+
+ | 6 |
+ VCC |
+
+
+ | 7 |
+ GND |
+
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+ edge [color="#000000:#895956:#000000"]
+ X1:p1r:e -- W1:w1:w
+ W1:w1:e -- X2:p1l:w
+ edge [color="#000000:#ff0000:#000000"]
+ X1:p2r:e -- W1:w2:w
+ W1:w2:e -- X2:p2l:w
+ edge [color="#000000:#ff8000:#000000"]
+ X1:p3r:e -- W1:w3:w
+ W1:w3:e -- X2:p4l:w
+ edge [color="#000000:#ffff00:#000000"]
+ X1:p4r:e -- W1:w4:w
+ W1:w4:e -- X2:p3l:w
+ edge [color="#000000"]
+ X1:p1r:e -- W1:ws:w
+ W1 [label=<
+
+ |
+
+ |
+
+
+ | 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 |
+ |
+
+ |
+ | |
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+}
diff --git a/examples/ex16.html b/examples/ex16.html
new file mode 100644
index 0000000..53e776b
--- /dev/null
+++ b/examples/ex16.html
@@ -0,0 +1,321 @@
+
+
+
+
+ ex16
+
+
+ex16
+Diagram
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Bill of Materials
+
+
+
+
+ | Id |
+ Description |
+ Qty |
+ Unit |
+ Designators |
+
+
+ | 1 |
+ Cable, Serial, 4 x 0.25 mm² shielded |
+ 0.2 |
+ m |
+ W1 |
+
+
+ | 2 |
+ Connector, Molex KK 254, female, 7 pins |
+ 2 |
+ |
+ X1, X2 |
+
+
+
+
+
+
diff --git a/examples/ex16.png b/examples/ex16.png
new file mode 100644
index 0000000..54f0441
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 0000000..17dbd81
--- /dev/null
+++ b/examples/ex16.svg
@@ -0,0 +1,255 @@
+
+
+
+
+
diff --git a/examples/ex16.yml b/examples/ex16.yml
new file mode 100644
index 0000000..c831cb2
--- /dev/null
+++ b/examples/ex16.yml
@@ -0,0 +1,43 @@
+connectors:
+ X1:
+ type: Molex KK 254 # more information
+ subtype: female
+ pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] # pincount is implicit in pinout
+ shorts:
+ SH1:
+ pins: [1, 5, 7]
+ color: PK
+ type: loop
+ SH2:
+ pins: [2, 6]
+ color: RD
+ X2:
+ type: Molex KK 254
+ subtype: female
+ pinlabels: [GND, VCC, RX, TX, GND, VCC, GND]
+ shorts:
+ SH1:
+ pins: [1, 5, 7]
+ type: loop
+ SH2:
+ pins: [2, 6]
+ type: loop
+
+cables:
+ W1:
+ color_code: IEC # auto-color wires based on a standard
+ wirecount: 4 # need to specify number of wires explicitly when using a color code
+ gauge: 0.25 mm2 # also accepts AWG as unit
+ show_equiv: true # auto-calculate AWG equivalent from metric gauge
+ length: 0.2 # length in m
+ shield: true
+ type: Serial
+
+connections:
+ -
+ - X1: [1-4]
+ - W1: [1-4]
+ - X2: [1,2,4,3] # crossover
+ - # connection from connector pin to wire shielding
+ - X1: 1
+ - W1: s
diff --git a/examples/readme.md b/examples/readme.md
index e785dd3..b4934bc 100644
--- a/examples/readme.md
+++ b/examples/readme.md
@@ -90,3 +90,9 @@
[Source](ex15.yml) - [Bill of Materials](ex15.bom.tsv)
+## Example 16
+
+
+[Source](ex16.yml) - [Bill of Materials](ex16.bom.tsv)
+
+
diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py
index 0b54d1e..f62bfa2 100644
--- a/src/wireviz/DataClasses.py
+++ b/src/wireviz/DataClasses.py
@@ -146,6 +146,7 @@ class Short:
description: Optional[str] = None
length: Optional[float] = None
length_unit: Optional[str] = None
+ type: Optional[MultilineHypertext] = None
@dataclass
diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py
index eb79165..48dd42e 100644
--- a/src/wireviz/Harness.py
+++ b/src/wireviz/Harness.py
@@ -186,9 +186,6 @@ class Harness:
fontname=self.options.fontname,
)
dot.attr("edge", style="bold", fontname=self.options.fontname)
-
- # print(self.connectors)
- # print(self.connectors.values())
for connector in self.connectors.values():
@@ -223,8 +220,14 @@ class Harness:
pinhtml.append(
''
)
+
+ intShorts = False
+
+ for shortName in connector.shorts:
+ if connector.shorts[shortName].get("type") == None or connector.shorts[shortName].get("type") == "internal":
+ intShorts = True
- if len(connector.shorts) > 0:
+ if len(connector.shorts) > 0 and intShorts:
pinhtml.append(" ")
if connector.ports_left:
pinhtml.append(f' | ')
@@ -232,7 +235,8 @@ class Harness:
pinhtml.append(f" | ")
for shortName in connector.shorts:
- pinhtml.append(f' {shortName} | ')
+ if connector.shorts[shortName].get("type") == None or connector.shorts[shortName].get("type") == "internal":
+ pinhtml.append(f' {shortName} | ')
if connector.ports_right:
pinhtml.append(f' | ')
@@ -270,19 +274,24 @@ class Harness:
for shortName in connector.shorts:
short = connector.shorts[shortName]
- shPins = short.get('pins');
- shColor = short.get('color');
+ shPins = short.get('pins')
+ shColor = short.get('color')
+ shType = short.get('type')
# shManufacturer = short.get('manufacturer');
# shMpn = short.get('mpn');
# shDescription = short.get('description');
- if shColor == None:
- shColor = "BK"
-
- if pinindex+1 in shPins:
- pinhtml.append(f' ⬤ | ')
- else:
- pinhtml.append(f' | ')
+ if shType == None or shType == "internal":
+ if shColor == None:
+ shColor = "BK"
+
+ if pinindex+1 in shPins:
+ pinhtml.append(f' ⬤ | ')
+ else:
+ pinhtml.append(f' | ')
+ elif shType == "loop":
+ pass
+
if connector.ports_right:
pinhtml.append(f' {pinname} | ')
@@ -320,12 +329,13 @@ class Harness:
for shortName in connector.shorts:
short = connector.shorts[shortName]
- shPins = short.get('pins');
- shColor = short.get('color');
- shManufacturer = short.get('manufacturer') if short.get('manufacturer') != None else "";
- shMpn = short.get('mpn') if short.get('mpn') != None else "";
- shDescription = short.get('description') if short.get('description') != None else "";
- length = short.get('length') if short.get('length') != None else "";
+ shPins = short.get('pins')
+ shColor = short.get('color')
+ shType = short.get('type')
+ shManufacturer = short.get('manufacturer') if short.get('manufacturer') != None else ""
+ shMpn = short.get('mpn') if short.get('mpn') != None else ""
+ shDescription = short.get('description') if short.get('description') != None else ""
+ length = short.get('length') if short.get('length') != None else ""
if short.get('length_unit') != None and short.get('length') != None:
length_unit = short.get('length_unit')
elif short.get('length') == None:
@@ -357,19 +367,39 @@ class Harness:
short = connector.shorts[shortName]
shPins = short.get('pins');
shColor = short.get('color');
+ shType = short.get('type')
# shManufacturer = short.get('manufacturer');
# shMpn = short.get('mpn');
# shDescription = short.get('description');
if shColor == None:
shColor = "BK"
- dot.attr("edge", color=str(wv_colors.translate_color(shColor, "HEX")), headclip="false", tailclip="false", style="solid,bold")
- for i in range(1, len(shPins)):
- dot.edge(
- f"{connector.name}:p{shPins[i - 1]}j:c",
- f"{connector.name}:p{shPins[i]}j:c",
- straight="straight"
- )
+
+
+ if shType == None or shType == "internal":
+ dot.attr("edge", color=str(wv_colors.translate_color(shColor, "HEX")), headclip="false", tailclip="false", style="solid,bold")
+ for i in range(1, len(shPins)):
+ dot.edge(
+ f"{connector.name}:p{shPins[i - 1]}j:c",
+ f"{connector.name}:p{shPins[i]}j:c",
+ straight="straight"
+ )
+ elif shType == "loop":
+ dot.attr("edge", color=f'#000000:{wv_colors.translate_color(shColor, "HEX")}:#000000')
+ if connector.ports_left:
+ loop_side = "l"
+ loop_dir = "w"
+ elif connector.ports_right:
+ loop_side = "r"
+ loop_dir = "e"
+ else:
+ raise Exception("No side for loops")
+
+ for i in range(1, len(shPins)):
+ dot.edge(
+ f"{connector.name}:p{shPins[i - 1]}{loop_side}:{loop_dir}",
+ f"{connector.name}:p{shPins[i]}{loop_side}:{loop_dir}",
+ )
dot.attr("edge", headclip="true", tailclip="true", style="bold")