lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
235 stars 63 forks source link

Ports on the north or south side are not rotated in the diagram #1944

Open cmnrd opened 1 year ago

cmnrd commented 1 year ago

The following program

target Python
reactor Src {
    physical action a
    @side("north")
    output out1
    @side("east")
    output out2
    reaction(a) -> out1, out2 {==}
}

produced this diagram: ReactorEBA

This looks a bit odd, as I would expect the ports to point up or down.

cmnrd commented 1 year ago

For some reason I cannot assign @soerendomroes, so I am pinging ;)

soerendomroes commented 1 year ago

This should be the case since KLighD defines the port rendering to look this way for output ports, which does not seem to consider NORTH or SOUTH ports.

@a-sr Could you point to the part in the synthesis where this is handled?

cmnrd commented 1 year ago

I also just noticed that the layout looks suboptimal in the following example. It would be nice to draw the two reactors centered on top of each other in this case.

target Python

reactor Src {
    @side("south")
    output out
}

reactor Sink {
    @side("north")
    input inp
}

main reactor {
    src = new Src()
    sink = new Sink()
    src.out -> sink.inp
}

Main

soerendomroes commented 1 year ago

Yes, it would but this is not possible if the layout direction is RIGHT.

What exactly do you want to achieve? Maybe you could do a quick sketch what you want LF programs to look like and I could suggest layout options to achieve the desired layout?

I find it rather unproductive to comment on every small change you make regarding NORTH and SOUTH ports. I would rather show you the different available options and their consequences in a short meeting.

cmnrd commented 1 year ago

I am trying to reproduce this figure (ignore the blue dashed errors, they represent asynchronous communication outside the reactor model and would need to be edited in later). eba

Generally, I am working on some figures for my dissertation and opened an issue whenever I found something that didn't work as expected. The issues have accumulated a bit, and yes perhaps it's best we have a short meeting. I'll ping you on zulip.

a-sr commented 1 year ago

While north and south works with the layout, I did not implement the orientation for the port figure in those cases because I did not expect that it will be used. You can find the code here: https://github.com/lf-lang/lingua-franca/blob/master/core/src/main/java/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java#L1648