PLCgen: Collecting input for sequencing events in plcgen
In step 23 of the the plcgen
overview issue #397 (closed) we have planned to perform sequencing of the event transition functions. For this we need information from the CIF model about dependencies between these functions.
As there seems to exist lack of clarity in what exactly is needed,
Code generation is outlined in Section 4.5.2 page 68 in Reijnen2020.
- Each automaton is converted to a LEFA (an automaton with location pointer variable and one location (page 17)).
- LEFAs that share events are merged.
- Generate code for each LEFA, trying to perform a transition for each event that it has, looping around until no transitions can be done any more. Listing 4.1 at page 70 is an example.
- At the main program, read input, repeatedly try all LEFAs until none of them can perform a transition, and do output.
In the plcgen
program we merge all LEFAs into one (that is, all events are assumed to be shared), and "all LEFAs" in the 4th item above becomes 1 LEFA, at which point the "code for each LEFA" can be inlined into the main program as a single sequence of trying each possible event.
Note this also makes ordering LEFAs as discussed in Section 4.6.2 irrelevant.
For sequencing, the notion "event dependencies" are introduced in Section 4.6, page 73, Definition 20. It defines an event dependency. Event b
depends on event a
as:
"Event a
can be performed and event b
cannot be performed, and after performing event a
, event b
can be performed." (All this in terms of system state.)
The important thing to note here is that "can (or cannot) be performed" depends exclusively on edge guard values, while changing that notion is done by changing state variables (including location pointer variables). This definition thus directly links updates of event a
to guards of event b
.
Neither the current cif2dmm
code nor its older cousin cif2matrix
(see d8abefcf#0cd5d4197c8d327ac984abce4251703253d9f169) provides this information. They do collect usage of events, locations, and variables, but they don't keep data from guards and updates separately.
It seems reasonable to collect the above information while analyzing the CIF model in plcgen
.
Addresses #679