Previous Up Next

3  Events

The current version of sf2lus has support for event broadcasts. This feature, however, is in a state of flux engendered by the implementation of inter-level transitions. Event broadcasting should not be used in conjunction with inter-level transitions (and are a bit ``buggy'' even with confluent events).

The intended uses of sf2lus are such that using event broadcasts is not recommended and charts should be transformed into ones which do not require broadcasting. This results in safer code (no unbounded behaviour), if sometimes much less readable charts.

3.1  Event broadcasting



Figure 2: A Stateflow chart requiring event broadcasts


Figure 2 shows a Stateflow chart (Events3.mdl) with two parallel states TOP1 and TOP2. Here, state TOP2 receives events from TOP1 but is executed before TOP1 according to the priorities in the chart. If we na´vely translate this chart and send event G to it we get:



State A has exited and state B has entered in subgraph TOP1 but subgraph TOP2 has not received event E and stayed in state C.

To enable event broadcasts we use the -ess <n> option where <n> is the depth of the event stack we require. For this chart we can set the event stack size to 2 and we get the following:



This time event E has been sent to state TOP2 resulting in emission of the local event F. Bear in mind that this mechanism is statically implemented in Lustre so each event broadcast results in duplication of the entire chart at that point, up to the event depth. This results in huge code and Lustre soon runs out of resources to implement the expansion. In practice, the -ess parameter should not be set to more than about 4. Charts which require event stacks deeper than this should be redesigned.

3.2  Event sending

Stateflow's send facility for targetting an event at a specific state is difficult to implement in Lustre. In an imperative environment such as Stateflow this can be implemented simply by calling a function which implements the behaviour of the state when sending the event. This does not work in Lustre since it may result in dependency cycles. A partial implementation has been achieved which behaves in a similar manner to Stateflow by turning events into integers.

An event of 0 is inactive, an event of 1 is broadcast and any other number refers to an event targetted at the state with that id. All events are then broadcast but only relevant states action the event (either the event is 1 or it or one of the states's parents has the same id as the event). The only problem here is that passive states during the send are not completely switched off (this would require inordinate numbers of guards in the code) so during actions get executed event if the state is not targetted by the send.


Figure 3: A chart requiring event sending


To trigger this mechanism use the -sends option. Figure 3 shows a chart which uses sends (Events5_docs.mdl), the resulting Luciole display is as follows:



Note that we now have to set the event E to 1 to indicate a broadcast4.


Previous Up Next