lingua-franca icon indicating copy to clipboard operation
lingua-franca copied to clipboard

Direction of reactions in the diagrams

Open cmnrd opened this issue 1 year ago • 3 comments

The adjustable port side feature implemented in https://github.com/lf-lang/lingua-franca/pull/1807 is a great addition to LF. However, I find it a bit challenging to use in conjunction with reactions. For instance, I would like to have the dataflow for requests to go from left to right, and the dataflow for responses to go from right to left in this reactor:

ClientMethodTransactor

Would it be possible to add an annotation that changes the direction of reactions?

cmnrd avatar Aug 09 '23 16:08 cmnrd

Can you please add a model to your ticket such that I can try out different layout algorithm with it?

soerendomroes avatar Aug 14 '23 09:08 soerendomroes

Sure. Here is the code used to produce the diagram from above.

target Python

reactor ClientMethodTransactor {
  @side("west")
  input request
  @side("west")
  output response

  physical action p
  logical action l

  @label("send request")
  reaction(request) {==}

  @label("receive response")
  @side("west")
  reaction(p) -> l {==}

  @label("forward response")
  reaction(l) -> response {==}
}

cmnrd avatar Aug 14 '23 12:08 cmnrd

The manual adjustment of port sides was and is an experimental feature. Nothing else in the diagram synthesis was adjusted to account for ports disregarding the left-to-right direction. That means reactions still have fixed port sides and a respective shape. Yes, it would be possible to extend the synthesis to support both directions for the LF elements but this will require a bigger rework because some elements would only be turned around due to the layout and not an explicit annotation, and hence require a post-processing outside the synthesis.

a-sr avatar Aug 24 '23 10:08 a-sr