Multiline transition reactions sintax trouble

17 views
Skip to first unread message

Eduardo Blotta

unread,
May 19, 2022, 7:40:49 PM5/19/22
to YAKINDU User
Hi,
I would like to know if it is possible to have multiple lines associated to the same trigger inside a state, for example,
==========================================================
every 1 s / vTimeOut--
[sSW1] / vCook_Min++; vTimeOut=10 [vCook_Min==60] / vCook_Min=0
[sSW2] / vCook_Seg++; vTimeOut=10 [vCook_Seg==60] / vCook_Seg=0
===========================================================
In the upper lines I would expect that "every 1s" affects the three lines,
1) vTimeOut-- , without condition,
2) [sSW1] / vCook_Min++; vTimeOut=10 [vCook_Min==60] / vCook_Min=0,  having the sSW1 event condition , and 
3) [sSW2] / vCook_Seg++; vTimeOut=10 [vCook_Seg==60] / vCook_Seg=0, ,  having the sSW2 event condition.

By analising the generated code I don´t get what I wish because lines 2 and 3 are not linked to "every 1s" trigger. 
Now, If I re-write the code as follows,
==========================================================
every 1 s / vTimeOut--
every 1 s  [sSW1] / vCook_Min++; vTimeOut=10 [vCook_Min==60] / vCook_Min=0
every 1 s  [sSW2] / vCook_Seg++; vTimeOut=10 [vCook_Seg==60] / vCook_Seg=0
===========================================================
Here, seen the generated code again, I have obtained 3 differents events by each line, what is not exactly what I wish.

Any suggestions?

Thanks in advance,

Eduardo

Thomas Kutz

unread,
Jul 7, 2022, 7:16:59 AM7/7/22
to YAKINDU User
Hi Eduardo,

sorry for the late answer!

You are right in your observation that lines 2 and 3 are not linked to the time event. The time event is only linked to the reaction statement where it is used, so you would have to put all the desired actions into line 1. As you have different conditions this is hard to express because there is no if-else statement in the language. Instead there is a ternary operator ('?' and ':'), but this will result in a badly readable statement.

Another possibility is to use an internal event, let's call it "tick", then your reactions would look like this:
every 1 s / raise tick
tick / vTimeOut--
tick [sSW1] / ...
tick [sSW2] / ...

Best regards,
Thomas

Eduardo Blotta

unread,
Jul 7, 2022, 11:40:18 AM7/7/22
to YAKINDU User
Hi Thomas,

Thank you for your answer!

In a future language update it might be useful to add "curly brackets", (for example), to associate several lines to the same time event like,
every 1 s {  sentence_1
[sSW1] / sentence_2
[sSW2] / sentence_3
...
}

Best regards,
Eduardo
Reply all
Reply to author
Forward
0 new messages