Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implementing banded colors #120

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

[WIP] Implementing banded colors #120

wants to merge 3 commits into from

Conversation

SnowMB
Copy link
Contributor

@SnowMB SnowMB commented Jul 22, 2020

I gave a first shot to implementing #109. For now I threw the color stripe out. I will implement it back using the same technique with overlaying multiple edges later when we decide on how to distinguish the multicolor mode (stripe / banded) (on the wire / on the cable ?).

I used a dashed overlay for the edges which in the png looks nice, but the svg renderings on my machine do not look as good. Unfortunately for the wire table I have to predefine a number of color bands. Here I used 12 which should work up to 4 colors, but then the dashes on the edges are much shorter than the bands inside the table. Maybe we try a few values here. Or someone has a better idea. How much can the wire table grow in width?

@SnowMB
Copy link
Contributor Author

SnowMB commented Jul 22, 2020

ex09
ex10

@SnowMB
Copy link
Contributor Author

SnowMB commented Jul 23, 2020

So I asked in the graphviz forum if my findings are actually intended and got a very helpful tip about splitting graphviz calculation in multiple steps with specifying dot as the output format. Graphviz then will output the graph to the dot format but will add position data to the nodes and edges as attributes. In the second run it can be configured to respect the position data and not move the objects anymore.

See https://graphviz.org/doc/info/output.html#d:dot

I played around a little bit and this basically enables me to

  • draw edges on top of nodes without affecting them so we don't need a html table cell hack to represent the wires inside the cable node
  • add edges after the nodes are placed without affecting them
  • merge all edges that represent a single wire into one spline so that the color banding is continuous over the whole wire
  • copy the coordinates of an edge spline and create new edges with the same coordinates that will be drawn on top of each other without relying on some obscure trick with invisble edges
  • add custom attributes to the initial dot representation to later find them again when scripting after the first graphviz run
  • (theoretically with some math) compute the length of a spline from it's coordinates and compute a nice banding scheme

Now the caveat:

Unfortunately the underlying python library graphviz does not really support anything else than specifying and render the graph. Iterating and changing existing nodes / edges does not seem possible. Everything is directly translated into a dot style string. So it either comes to direct string manipulation or maybe we can have a look at something like the official graphviz python bindings gv.3python

ex10 gv dot

hacked_ex10.gv.dot.txt

dot -Tdot ex10.gv -O
#do some hacking in the file
neato -Tsvg -Tpng -n2 hacked_ex10.gv.dot -O

@formatc1702
Copy link
Collaborator

formatc1702 commented Jul 23, 2020

That looks impressive!
I don't have much time to look into this, and it's a bit lower priority than other open points for the v0.2 milestone, but please keep on hacking! It all seems very promising.

Why not link to this PR in the GraphViz forum, maybe someone else wants to join in on the fun? 😎

@formatc1702 formatc1702 added this to the v0.3 = do later milestone Jul 24, 2020
@formatc1702 formatc1702 marked this pull request as draft July 24, 2020 13:36
@formatc1702 formatc1702 added the WIP Work in progress label Jul 24, 2020
@X-Ryl669
Copy link

Tested it with this example:

connectors:
  X1:
    type: AC RCCB
    subtype: Type B
    pinlabels: [Lin, Nin, Lout, Nout]
  X3/AC:
    type: EVSE Main board
    subtype: 230V RMS AC Side
    pinlabels: [TI+, TI-, Lout, Nout, Lrel, Lin, Nin]
  Earth:
    type: Common Earth
    subtype: female
    pinlabels: [GND1, GND2, GND3, GND4, GND5, GND6]
  Main:
    type: Main furniture
    subtype: 230V RMS AC 1 phase
    pinlabels: [L, N, Earth, Opt. Teleinfo+, Opt. Teleinfo-]

cables:
  W(Teleinfo):
    gauge: 1.5 mm2
    length: 0.2
    color_code: DIN
    wirecount: 2
    shield: false
    category: bundle
  W(PowerAC):
    gauge: 1.5 mm2
    length: 0.2
    color_code: DIN
    wirecount: 2
    shield: false
    category: bundle
    colors: [BN, BU]
  W(PowerRCCB):
    gauge: 6 mm2
    length: 0.1
    color_code: DIN
    wirecount: 2
    shield: false
    category: bundle
    colors: [BN, BU]
  W(EarthCommon1):
    gauge: 6 mm2
    length: 0.3
    color_code: DIN
    wirecount: 2
    shield: false
    shield: false
    category: bundle
  W(PowerAC):
    gauge: 1.5 mm2
    length: 0.2
    color_code: DIN
    wirecount: 2
    shield: false
    category: bundle
    colors: [BN, BU]
  W(PowerRCCB):
    gauge: 6 mm2
    length: 0.1
    color_code: DIN
    wirecount: 2
    shield: false
    category: bundle
    colors: [BN, BU]
  W(EarthCommon1):
    gauge: 6 mm2
    length: 0.3
    color_code: DIN
    wirecount: 2
    shield: false
    category: bundle
    colors: [YEGN, YEGN]

connections:
  -
    - Main: [1,2]
    - W(PowerRCCB): [1,2]
    - X1: [1,2]
  -
    - X3/AC: [6,7]
    - W(PowerAC): [1,2]
    - X1: [3,4]
  -
    - X3/AC: [1,2]
    - W(Teleinfo): [1,2]
    - Main: [4,5]
  -
    - Main: [3]
    - W(EarthCommon1): [1]
    - Earth: [1]

And it failed drawing the wires correctly.

@SnowMB
Copy link
Contributor Author

SnowMB commented Jul 27, 2020

@X-Ryl669 Thanks for the test. I was suspecting, that the hack I used in the example would not work reliably and this seems to proof this. Anyway I'm working on a better solution, but I'm not finished to show it off for testing.

Here the output for anybody interested:
test

@X-Ryl669
Copy link

The wires on the top are just perfect. It's a shame those of the bottom are so mangled out... 😢

@SnowMB
Copy link
Contributor Author

SnowMB commented Jul 27, 2020

A little bit progress information for @formatc1702:

I've looked around a little bit and tried a few python libs working with graphviz and / or the dot language. I think for a clean implementation of the banded output it is necessary to use graphviz in two steps. This may enable us to implement other features that are not supported by graphviz in the future (I'm thinking stuff like drawing twisted pair wires 😁).

  1. Create the initial graph and let graphviz do the layout (this step is equivalent to running dot -Tdot <file> > file.dot. Graphviz then outputs a new file in dot format containing the graph and additional position data. This data is stored for each node and edge in the pos attribute.
  2. Use the output from step 1 and manipulate the generated dot file to add / extend edges. The manipulated dot graph can be processed by graphviz with respecting the included position data neato -n2 -Tpng -Tsvg <file> -O

Problems to overcome when doing this:

  • After specifying the initial graph and letting graphviz run for generating layout data, graphviz reorders edge and node definitions so that the drawing order can get all messed up.
  • The now used python library does not support parsing the dot language and manipulating an existing graph. It is solely usable for generating new graphs. Working with the output would require to partially implement a dot language parser.

Here two other libs I've tried:

official python bindings: I've tried the "official" python binding that are included in the graphviz project. Here I can manipulate a graph directly without the intermediate dot language. The library has a clean interface and supports splitting layout generation and output, so that the positional arguments can be inspected / manipulated, but I have not yet found a way to overcome the reordering of the edges. However installing / using the bindings can be a hassle. In arch linux the bindings are part of the graphviz package. In ubuntu they are bundled seperatly. It is not installable via pip.

pydot: Another package I've tried is pydot. This seemed to have a fairly large user base and works a bit like the graphviz lib you are currently using. But it also includes a fully featured dot file format parses that supports reading and manipulating existing graphs.

pydot example:

from pydot import graph_from_dot_data, Dot, Edge,Node

g = Dot()
g.set_type("graph")
g.set("rankdir", "LR")

n1 = Node('n1')
n2 = Node('n2', penwidth="3.0")
n3 = Node('n3')

g.add_node(n1)
g.add_node(n2)
g.add_node(n3)

e1 = Edge(n1,n2, color="red", penwidth="6.0", wv_reference="0", wv_id="0")

e2 = Edge(n1,n2, color="blue", penwidth="6.0", wv_reference="1", wv_id="0")
e3 = Edge(n2,n3, color="blue", penwidth="6.0", wv_reference="1", wv_id="1")

e4 = Edge(n1,n3, color="yellow", penwidth="6.0", wv_reference="2", wv_id="0")

g.add_edge(e1)
g.add_edge(e2)
g.add_edge(e3)
g.add_edge(e4)

g2 = graph_from_dot_data(g.create_dot(prog="dot", f="dot").decode('utf-8'))[0] #generating layout via the dot command and passing the output directly to the parser
print(g2)

Also the output generation (calling dot, neato, ect. ) can be customized and piped into the parser without needing intermediate file system access. The problem with this package seems to be that the last commit is from 2018 and although there is a good amount of interest in the lib (issues, pull requests) I'm not sure if it's still in active development. But it can be easily installed with pip.

For now this is the only lib that seems to have all features to easily implement the banded output and I've done some examples verifying that it is indeed possible 😄. I'll make a branch where I replace the use of graphviz with pydot in the next days so that you can try this out.

But maybe you can state your opinion on changing the backend lib. Do you see this as an option or do you want to move forward with graphviz? There might be a possibility to still achieve the same goal. Maybe we can try to contact the graphviz python lib developer and see if there's plans to enable graph manipulation.

@X-Ryl669
Copy link

X-Ryl669 commented Jul 28, 2020

The more I think about it the more I think we should just dismiss using graphviz. After all, the graph is very simple and we don't need the advanced features for node / edge placement that dot is doing.

As I understand the placement, we only have connectors even column (2n) and wire on odd column (2n+1) :

[Connector]       [Wire ]      [Connector] ...
      2n           2n+1              2(n+1)

Since the connectors' and wires' height are known beforehand the position of the connectors and wire can be layout easily.

The technical difficulty is finding which connector is terminal but currently, one has to swap the connections in the yml file to get graphviz to draw correctly, so this shouldn't change much at first. I've thought about counting the connection to the connector and ordering them left to right from the most connected to the less connected (or top to bottom).

So once the position of the nodes are found (with keeping a scale factor for letting some margin for edge routing), drawing the edges should be a bit harder to route but not too hard either, since we can take advantage of bus routing (all the cables should be parallel and horizontal while crossing a odd column) so it's mainly finding the vertical position they should be to touch the wires' node and then draw a nice and standard cubic spline (or, better, a 45° polyline) from their starting position to the ending position. The vertical bus routing is also quite standard.

One thing I'm still puzzled at is how to deal with cable crossing's depth position. It can be random, but I'm not sure how to get the best result.

This would also mean that the output will be a SVG file and use whatever renderer to convert it to a PNG file if required.

@SnowMB
Copy link
Contributor Author

SnowMB commented Jul 28, 2020

One thing I'm still puzzled at is how to deal with cable crossing's depth position. It can be random, but I'm not sure how to get the best result.

Graphviz draws the edges in specified order so it's also just top to bottom. The reordering I was talking about only occurs on writing to dot format.

@SnowMB
Copy link
Contributor Author

SnowMB commented Jul 30, 2020

I hacked a quick working example with using pydot instead of the graphviz python lib. you can find it here:

https://github.com/SnowMB/WireViz/tree/banded_wires_pydot

The examples and tutorials seem to work, the only thing I have to figure out is how I draw the splines for the wires if one or both connections are missing. (For example for the shield or in the file @X-Ryl669 provided)

ex09

ex10
test32_new

You can see in the commit history of that branch that changing the lib requires minimal changes.

@ericbhanson
Copy link

ericbhanson commented Aug 1, 2020

I am rebuilding a motorcycle wiring harness that uses banded wiring, so I've been following this PR with interest. @SnowMB I ran your branch using the following YAML file:

Source
connectors:
  ALT:
    type: Molex
    subtype: male
    pincount: 3
    notes: Alternator
  BL-SW-M:
    type: Bullet
    subtype: male
    pincount: 1
    notes: Blue Shockwave Module
  F-L-TS:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Front Left Turn Signal
  F-R-TS:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Front Right Turn Signal
  F-STP-SW:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Front Stop Switch
  GR-SW-M:
    type: Bullet
    subtype: male
    pincount: 1
    notes: Green Shockwave Module
  HDLGT:
    type: Bullet
    subtype: male
    pincount: 3
    notes: Headlight
  R-HD-CTRL:
    type: Molex
    subtype: male
    pincount: 6
    notes: Headlight Control, Ignition, Starter
  HB-IND:
    type: Bullet
    subtype: male
    pincount: 2
    notes: High Beam Indicator
  HRN:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Horn
  L-IG-CL:
    type: Bullet
    subtype: male
    pincount: 1
    notes: Left Ignition Coil
  IG-SW:
    type: Bullet
    subtype: male
    pincount: 4
    notes: Main/Ignition Switch
  NTL-IND:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Neutral Indicator
  NTL-SW:
    type: Bullet
    subtype: male
    pincount: 1
    notes: Neutral Switch
  R-L-TS:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Rear Left Turn Signal
  R-R-TS:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Rear Right Turn Signal
  R-STP-SW:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Rear Stop Switch
  REG-REC:
    type: Molex
    subtype: male
    pincount: 4
    notes: Regulator Rectifier
  R-IG-CL:
    type: Bullet
    subtype: male
    pincount: 1
    notes: Right Ignition Coil
  ST-MAG-SW:
    type: Bullet
    subtype: male
    pincount: 3
    notes: Starter Magnetic Switch
  TL-LT:
    type: Bullet
    subtype: male
    pincount: 3
    notes: Tail Light
  T-SIG-IND:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Turn Signal Indicator
  L-HD-CTRL:
    type: Molex
    subtype: male
    pincount: 9
    notes: Turn Signal, Horn, Dimmer
  WNK-RLY:
    type: Blade
    subtype: male
    pincount: 2
    notes: Winker Relay
  SPD-LGT:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Speedometer Illuminating Light
  TCH-LGT:
    type: Bullet
    subtype: male
    pincount: 2
    notes: Tachometer Illuminating Light
  BLC-MN:
    type: Eye
    pincount: 12
    notes: Fuse Block (Main Terminals)
  BLC-GD:
    type: Eye
    pincount: 6
    notes: Fuse Block (Ground)

cables:
  W-YE-WH:
    colors: [WH, YE, YE]
    gauge: 16 AWG
  W-GN-YE:
    category: bundle
    colors: [GNYE, GNYE, GNYE]
    gauge: 16 AWG
  W-BU:
    category: bundle
    colors: [BU, BU]
    gauge: 16 AWG
  W-LG:
    colors: [LG, LG]
    gauge: 16 AWG
  W-LG-RD:
    colors: [LGRD, LGRD]
    gauge: 16 AWG
  W-GN:
    category: bundle
    colors: [GN, GN, GN, GN, GN, GN, GN, GN, GN, GN]
    gauge: 16 AWG
  W-BK:
    category: bundle
    colors: [BK, BK, BK, BK, BK, BK, BK, BK]
    gauge: 16 AWG
  W-BK-WH:
    category: bundle
    colors: [BKWH, BKWH, BKWH, BKWH, BKWH]
    gauge: 16 AWG
  W-GY:
    colors: [GY, GY]
    gauge: 16 AWG
  W-LB:
    category: bundle
    colors: [LB, LB, LB]
    gauge: 16 AWG
  W-LB-2:
    colors: [LB]
    gauge: 16 AWG
  W-OG:
    category: bundle
    colors: [OG, OG, OG]
    gauge: 16 AWG
  W-OG-2:
    colors: [OG]
    gauge: 16 AWG
  W-RD:
    category: bundle
    colors: [RD, RD, RD]
    gauge: 16 AWG
  W-WH:
    colors: [WH]
    gauge: 16 AWG
  W-YE-RD:
    colors: [YERD, YERD]
    gauge: 16 AWG
  W-BR-WH:
    category: bundle
    colors: [BRWH, BRWH, BRWH]
    gauge: 16 AWG
  W-BK-RD:
    category: bundle
    colors: [BKRD, BKRD]
    gauge: 16 AWG
  W-BR:
    colors: [BR]
    gauge: 16 AWG
  W-PK:
    colors: [PK]
    gauge: 16 AWG

connections:
  -
    - ALT: [1]
    - W-PK: [1]
    - REG-REC: [2]
  -
    - ALT: [2-3]
    - W-YE-WH: [1-2]
    - REG-REC: [4, 4]
  -
    - F-L-TS: [1]
    - W-GN: [1]
    - BLC-GD: [1]
  -
    - F-R-TS: [1]
    - W-GN: [2]
    - BLC-GD: [1]
  -
    - HDLGT: [2]
    - W-GN: [3]
    - BLC-GD: [1]
  -
    - HB-IND: [2]
    - W-GN: [4]
    - BLC-GD: [1]
  -
    - R-L-TS: [1]
    - W-GN: [5]
    - BLC-GD: [1]
  -
    - R-R-TS: [1]
    - W-GN: [6]
    - BLC-GD: [6]
  - 
    - REG-REC: [1]
    - W-GN: [7]
    - BLC-GD: [6]
  -
    - TL-LT: [2]
    - W-GN: [8]
    - BLC-GD: [6]
  -
    - SPD-LGT: [2]
    - W-GN: [9]
    - BLC-GD: [6]
  - 
    - TCH-LGT: [2]
    - W-GN: [10]
    - BLC-GD: [6]
  -
    - F-STP-SW: [1]
    - W-BK: [1]
    - BLC-MN: [1]
  -
    - R-HD-CTRL: [1]
    - W-BK: [2]
    - BLC-MN: [1]
  -
    - HRN: [1]
    - W-BK: [3]
    - BLC-MN: [1]
  -
    - IG-SW: [1]
    - W-BK: [4]
    - BLC-MN: [1]
  -
    - NTL-IND: [1]    
    - W-BK: [5]
    - BLC-MN: [1]
  -
    - R-STP-SW: [1]
    - W-BK: [6]
    - BLC-MN: [1]
  -
    - ST-MAG-SW: [1]
    - W-BK: [7]
    - BLC-MN: [1]
  -
    - WNK-RLY: [1]
    - W-BK: [8]
    - BLC-MN: [1]
  - 
    - BL-SW-M: [1]
    - W-BK-WH: [1]
    - BLC-MN: [2]
  - 
    - GR-SW-M: [1]
    - W-BK-WH: [2]
    - BLC-MN: [2]
  -
    - R-HD-CTRL: [5]
    - W-BK-WH: [3]
    - BLC-MN: [2]
  -
    - L-IG-CL: [1]
    - W-BK-WH: [4]
    - BLC-MN: [2]
  -
    - R-IG-CL: [1]
    - W-BK-WH: [5]
    - BLC-MN: [2]
  -
    - HB-IND: [1]
    - W-BU: [1]
    - HDLGT: [1]
  - 
    - L-HD-CTRL: [2]
    - W-BU: [2]
    - HDLGT: [1]
  -
    - F-STP-SW: [2]
    - W-GN-YE: [1]
    - BLC-MN: [10]
  -
    - R-STP-SW: [2]
    - W-GN-YE: [2]
    - BLC-MN: [10]
  - 
    - TL-LT: [3]
    - W-GN-YE: [3]
    - BLC-MN: [10]
  - 
    - L-HD-CTRL: [8]
    - W-GY: [1]
    - BLC-MN: [7]
  - 
    - WNK-RLY: [2]
    - W-GY: [2]
    - BLC-MN: [7]
  - 
    - F-R-TS: [2]
    - W-LB: [1]
    - T-SIG-IND: [2]
  -
    - R-R-TS: [2]
    - W-LB-2: [1]
    - BLC-MN: [12]
  - 
    - L-HD-CTRL: [6]
    - W-LB: [3]
    - T-SIG-IND: [2]
  - 
    - HRN: [2]
    - W-LG: [1]
    - BLC-MN: [6]
  - 
    - L-HD-CTRL: [9]
    - W-LG: [2]
    - BLC-MN: [5]
  -
    - NTL-IND: [2]
    - W-LG-RD: [1]
    - BLC-MN: [5]
  - 
    - NTL-SW: [1]
    - W-LG-RD: [2]
    - BLC-MN: [6]
  -
    - F-L-TS: [2]
    - W-OG: [1]
    - T-SIG-IND: [1]
  - 
    - R-L-TS: [2]
    - W-OG-2: [1]
    - BLC-MN: [11]
  -
    - L-HD-CTRL: [7]
    - W-OG: [3]
    - T-SIG-IND: [1]
  -
    - IG-SW: [4]
    - W-RD: [1]
    - BLC-MN: [3]
  -
    - ST-MAG-SW: [2]
    - W-RD: [2]
    - BLC-MN: [3]
  - 
    - REG-REC: [3]
    - W-RD: [3]
    - BLC-MN: [3]
  -
    - L-HD-CTRL: [1]
    - W-WH: [1]
    - HDLGT: [3]  
  -
    - R-HD-CTRL: [6]
    - W-YE-RD: [1]
    - BLC-MN: [9]
  -
    - ST-MAG-SW: [3]
    - W-YE-RD: [2]
    - BLC-MN: [9]
  - 
    - R-HD-CTRL: [4]
    - W-YE-WH: [3]
    - REG-REC: [4]
  - 
    - R-HD-CTRL: [3]
    - W-BK-RD: [1]
    - BLC-MN: [4]
  - 
    - L-HD-CTRL: [4]
    - W-BK-RD: [2]
    - BLC-MN: [4]
  -
    - IG-SW: [3]
    - W-BR-WH: [1]
    - BLC-MN: [8]
  -
    - SPD-LGT: [1]
    - W-BR-WH: [2]
    - BLC-MN: [8]
  -
    - TCH-LGT: [1]
    - W-BR-WH: [3]
    - BLC-MN: [8]
  -
    - BLC-MN: [11]
    - W-OG: [2]
    - T-SIG-IND: [1]    
  -
    - BLC-MN: [12]
    - W-LB: [2]
    - T-SIG-IND: [2]

Here's the output:
wh

One thing I noticed while running this is that I'd get an exception from stringToPoint() that I traced to a ///n character being inserted into the string. As a workaround, I modified the function to the following:

def stringToPoint(str):
  split = re.split(r'(\d+\.?\d?)', str)
  return tuple([float(split[1]), float(split[3])])

Hopefully this is of some help to you. Looking forward to further developments and thank you @formatc1702 for this great tool and @SnowMB for working on this feature!

@SnowMB
Copy link
Contributor Author

SnowMB commented Aug 1, 2020

@ericbhanson I looked at your example. You made a small mistake in your regex resulting in sometimes cutting the 2nd digit of a float number and mistake it for the y coordinate of the point. this causes the mess 😁

def stringToPoint(str):
  split = re.split(r'(\d+\.?\d+)', str)
  return tuple([float(split[1]), float(split[3])])

(notice the + instead of a ?)

I made a new commit to my branch so you can try it out!

You also have some unknown colors specified:

Unknown color specified: LG
Unknown color specified: LG
Unknown color specified: LGRD
Unknown color specified: LGRD
Unknown color specified: BRWH
Unknown color specified: BRWH
Unknown color specified: BRWH
Unknown color specified: BR
Unknown color specified: LG
Unknown color specified: LG
Unknown color specified: LGRD
Unknown color specified: LGRD
Unknown color specified: BRWH
Unknown color specified: BRWH
Unknown color specified: BRWH

I guess BR should be BN for brown. But what's LG ?

I must admit that the output still looks fairly messy 😅

test_ericbhanson

@ericbhanson
Copy link

@SnowMB thanks - I had a feeling it was probably a typo on my part 😄 LG is "light green" and yes, BR is "brown"; I added those two to wv_colors.py directly (old Hondas use their own color naming convention, I guess); LG is #00ff00 if you want to add it. Believe it or not, that wiring diagram is actually slightly simplified from the original 😱

@ericbhanson
Copy link

ericbhanson commented Aug 4, 2020

@SnowMB I've been reorganizing my configuration file based on some suggestions from @formatc1702 and noticed that I get an error if I do not use every connector in the connections section of the file:


stdout, stderr:
 b'graph G {\n\tgraph [bb="0,0,852,2083",\n\t\tbgcolor=white,\n\t\tfontname=arial,\n\t\tnodesep=0.33,\n\t\trankdir=LR,\n\t\tranksep=2\n\t];\n\tnode [fillcolor=white,\n\t\tfontname=arial,\n\t\tlabel="\\N",\n\t\tshape=record,\n\t\tstyle=filled\n\t];\n\tedge [fontname=arial,\n\t\tstyle=bold\n\t];\n\tALT\t [height=2,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">ALT</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">Locking Housing</td><td balign="left">female</td><td balign="left">3-pin</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td>PK</td><td port="p1r">1</td></tr><tr><td>YE</td><td port="p2r">2</td></tr><tr><td>WH</td><td port="p3r">3</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">Alternator</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="100,219",\n\t\tshape=none,\n\t\twidth=2.7778];\n\t"W-BATTERY"\t [height=4.4167,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td colspan="2">W-BATTERY</td></tr><tr><td balign="left">9x</td><td balign="left">16 AWG</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td><table border="0" cellspacing="0" cellborder="0"><tr><td>ALT:1</td><td>BK</td><td>REG-REC:1</td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6"></td></tr><tr><td><!-- 2_in --></td><td>BK</td><td><!-- 2_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6"></td></tr><tr><td><!-- 3_in --></td><td>GN</td><td><!-- 3_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6"></td></tr><tr><td><!-- 4_in --></td><td>GY</td><td><!-- 4_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6"></td></tr><tr><td><!-- 5_in --></td><td>PK</td><td><!-- 5_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6"></td></tr><tr><td><!-- 6_in --></td><td>RD</td><td><!-- 6_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w6" height="6"></td></tr><tr><td><!-- 7_in --></td><td>RD</td><td><!-- 7_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w7" height="6"></td></tr><tr><td><!-- 8_in --></td><td>YERD</td><td><!-- 8_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w8" height="6"></td></tr><tr><td><!-- 9_in --></td><td>YEWH</td><td><!-- 9_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w9" height="6"></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="426,159",\n\t\tshape=box,\n\t\tstyle="",\n\t\twidth=2.2778];\n\tALT:p1r -- "W-BATTERY":w1\t [pos="200,231 264,231 280,231 344,231",\n\t\twv_color=BK,\n\t\twv_wire=0,\n\t\twv_wire_spline=0];\n\t"BL-SW-M"\t [height=0.5,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">BL-SW-M</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">Bullet</td><td balign="left">female</td><td balign="left">1-pin</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="100,333",\n\t\tshape=none,\n\t\twidth=0.83902];\n\t"REG-REC"\t [height=2.3333,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">REG-REC</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">Locking Housing</td><td balign="left">female</td><td balign="left">4-pin</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td port="p1l">1</td><td>GN</td></tr><tr><td port="p2l">2</td><td>PK</td></tr><tr><td port="p3l">3</td><td>RD</td></tr><tr><td port="p4l">4</td><td>YEWH</td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td balign="left">Regulator Rectifier</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="752,207",\n\t\tshape=none,\n\t\twidth=2.7778];\n\t"W-BATTERY":w1 -- "REG-REC":p1l\t [pos="508,231 572,231 588,231 652,231",\n\t\twv_wire=0,\n\t\twv_wire_spline=1];\n\t"W-ENGINE"\t [height=2.6111,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td colspan="2">W-ENGINE</td></tr><tr><td balign="left">4x</td><td balign="left">16 AWG</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td><table border="0" cellspacing="0" cellborder="0"><tr><td><!-- 1_in --></td><td>PK</td><td><!-- 1_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6"></td></tr><tr><td><!-- 2_in --></td><td>RDLG</td><td><!-- 2_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6"></td></tr><tr><td><!-- 3_in --></td><td>WH</td><td><!-- 3_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6"></td></tr><tr><td><!-- 4_in --></td><td>YE</td><td><!-- 4_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6"></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="100,469",\n\t\tshape=box,\n\t\tstyle="",\n\t\twidth=1.125];\n\t"W-FRONT"\t [height=12.361,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td colspan="2">W-FRONT</td></tr><tr><td balign="left">31x</td><td balign="left">16 AWG</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td><table border="0" cellspacing="0" cellborder="0"><tr><td><!-- 1_in --></td><td>BK</td><td><!-- 1_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6"></td></tr><tr><td><!-- 2_in --></td><td>BK</td><td><!-- 2_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6"></td></tr><tr><td><!-- 3_in --></td><td>BK</td><td><!-- 3_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6"></td></tr><tr><td><!-- 4_in --></td><td>BK</td><td><!-- 4_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6"></td></tr><tr><td><!-- 5_in --></td><td>BKRD</td><td><!-- 5_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6"></td></tr><tr><td><!-- 6_in --></td><td>BKRD</td><td><!-- 6_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w6" height="6"></td></tr><tr><td><!-- 7_in --></td><td>BKWH</td><td><!-- 7_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w7" height="6"></td></tr><tr><td><!-- 8_in --></td><td>BL</td><td><!-- 8_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w8" height="6"></td></tr><tr><td><!-- 9_in --></td><td>BNWH</td><td><!-- 9_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w9" height="6"></td></tr><tr><td><!-- 10_in --></td><td>BU</td><td><!-- 10_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w10" height="6"></td></tr><tr><td><!-- 11_in --></td><td>BU</td><td><!-- 11_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w11" height="6"></td></tr><tr><td><!-- 12_in --></td><td>BU</td><td><!-- 12_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w12" height="6"></td></tr><tr><td><!-- 13_in --></td><td>GN</td><td><!-- 13_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w13" height="6"></td></tr><tr><td><!-- 14_in --></td><td>GN</td><td><!-- 14_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w14" height="6"></td></tr><tr><td><!-- 15_in --></td><td>GN</td><td><!-- 15_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w15" height="6"></td></tr><tr><td><!-- 16_in --></td><td>GN</td><td><!-- 16_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w16" height="6"></td></tr><tr><td><!-- 17_in --></td><td>GR</td><td><!-- 17_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w17" height="6"></td></tr><tr><td><!-- 18_in --></td><td>GR</td><td><!-- 18_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w18" height="6"></td></tr><tr><td><!-- 19_in --></td><td>GY</td><td><!-- 19_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w19" height="6"></td></tr><tr><td><!-- 20_in --></td><td>LB</td><td><!-- 20_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w20" height="6"></td></tr><tr><td><!-- 21_in --></td><td>LB</td><td><!-- 21_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w21" height="6"></td></tr><tr><td><!-- 22_in --></td><td>LGRD</td><td><!-- 22_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w22" height="6"></td></tr><tr><td><!-- 23_in --></td><td>OG</td><td><!-- 23_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w23" height="6"></td></tr><tr><td><!-- 24_in --></td><td>OG</td><td><!-- 24_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w24" height="6"></td></tr><tr><td><!-- 25_in --></td><td>OG</td><td><!-- 25_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w25" height="6"></td></tr><tr><td><!-- 26_in --></td><td>RD</td><td><!-- 26_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w26" height="6"></td></tr><tr><td><!-- 27_in --></td><td>WH</td><td><!-- 27_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w27" height="6"></td></tr><tr><td><!-- 28_in --></td><td>WH</td><td><!-- 28_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w28" height="6"></td></tr><tr><td><!-- 29_in --></td><td>YE</td><td><!-- 29_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w29" height="6"></td></tr><tr><td><!-- 30_in --></td><td>YEGR</td><td><!-- 30_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w30" height="6"></td></tr><tr><td><!-- 31_in --></td><td>YERD</td><td><!-- 31_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w31" height="6"></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="100,1032",\n\t\tshape=box,\n\t\tstyle="",\n\t\twidth=1.2361];\n\t"W-IGNITION"\t [height=4.4167,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td colspan="2">W-IGNITION</td></tr><tr><td balign="left">9x</td><td balign="left">16 AWG</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td><table border="0" cellspacing="0" cellborder="0"><tr><td><!-- 1_in --></td><td>BK</td><td><!-- 1_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6"></td></tr><tr><td><!-- 2_in --></td><td>BK</td><td><!-- 2_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6"></td></tr><tr><td><!-- 3_in --></td><td>BKWH</td><td><!-- 3_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6"></td></tr><tr><td><!-- 4_in --></td><td>BKWH</td><td><!-- 4_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6"></td></tr><tr><td><!-- 5_in --></td><td>BKWH</td><td><!-- 5_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6"></td></tr><tr><td><!-- 6_in --></td><td>BKWH</td><td><!-- 6_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w6" height="6"></td></tr><tr><td><!-- 7_in --></td><td>BRWH</td><td><!-- 7_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w7" height="6"></td></tr><tr><td><!-- 8_in --></td><td>GN</td><td><!-- 8_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w8" height="6"></td></tr><tr><td><!-- 9_in --></td><td>RD</td><td><!-- 9_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w9" height="6"></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="100,1660",\n\t\tshape=box,\n\t\tstyle="",\n\t\twidth=1.2083];\n\t"W-REAR"\t [height=3.3333,\n\t\tlabel=<<table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td colspan="2">W-REAR</td></tr><tr><td balign="left">6x</td><td balign="left">16 AWG</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td><table border="0" cellspacing="0" cellborder="0"><tr><td><!-- 1_in --></td><td>BL</td><td><!-- 1_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6"></td></tr><tr><td><!-- 2_in --></td><td>GN</td><td><!-- 2_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6"></td></tr><tr><td><!-- 3_in --></td><td>GR</td><td><!-- 3_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6"></td></tr><tr><td><!-- 4_in --></td><td>GR</td><td><!-- 4_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6"></td></tr><tr><td><!-- 5_in --></td><td>OG</td><td><!-- 5_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6"></td></tr><tr><td><!-- 6_in --></td><td>YEGN</td><td><!-- 6_out --></td></tr><tr><td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w6" height="6"></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table>>,\n\t\tmargin=0,\n\t\tpos="100,1963",\n\t\tshape=box,\n\t\tstyle="",\n\t\twidth=1.125];\n}\n'
b'Error: syntax error in line 1 \n... <tr></tr> ...\nin label of node BL-SW-M\n'

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/bin/wireviz", line 11, in <module>
    load_entry_point('wireviz', 'console_scripts', 'wireviz')()
  File "/Users/eric/Downloads/WireViz/src/wireviz/wireviz.py", line 248, in main
    parse(yaml_input, file_out=file_out)
  File "/Users/eric/Downloads/WireViz/src/wireviz/wireviz.py", line 178, in parse
    harness.output(filename=file_out, fmt=('png', 'svg'), view=False)
  File "/Users/eric/Downloads/WireViz/src/wireviz/Harness.py", line 430, in output
    graph = self.create_graph()
  File "/Users/eric/Downloads/WireViz/src/wireviz/Harness.py", line 392, in create_graph
    g = graph_from_dot_data(dot.create_dot(prog="dot", f="dot").decode('utf-8'))[0]
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pydot.py", line 1722, in new_method
    return self.create(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pydot.py", line 1945, in create
    assert process.returncode == 0, process.returncode
AssertionError: 1

I suspect this might be why I'm getting an error when I attempt to use templates as well.

@SnowMB
Copy link
Contributor Author

SnowMB commented Aug 5, 2020

Yeah the cable node is created but there seems to be a bug in the way the wires inside the cable are generated when they have no connection. Wireviz seems to generate empty rows there (<tr></tr> without <td>)

I'm not sure if I introduced a bug or if this is a general problem. I can't check this right now but maybe you can tell me if this works in the dev branch?

Here is the bugged section:

"BL-SW-M"	 [height=0.5,
		label=<<table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
          <table border="0" cellspacing="0" cellpadding="3" cellborder="1">
            <tr>
              <td balign="left">BL-SW-M</td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table border="0" cellspacing="0" cellpadding="3" cellborder="1">
            <tr>
              <td balign="left">Bullet</td>
              <td balign="left">female</td>
              <td balign="left">1-pin</td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table border="0" cellspacing="0" cellpadding="3" cellborder="1">
            <tr>
            </tr>
          </table>
        </td>
      </tr>
    </table>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants