This (toy) example illustrates the use of a finite-state machine (implemented in the FSM domain) to get a modal Giotto model. The block diagram is given below:
This state machine has three states and starts in state Init. The transition from Init to State0 is always enabled and will be taken in the first firing of the state machine. The actions on the transition properly initialize the refinement of State0. The guards on the transitions between State0 and State1 cause the transitions to be taken each time the input to the state machine is a multiple of 4. The guards read:
in_isPresent && (in % 4 == 0)which is interpreted as follows. The variable
in_isPresent
has value true when the input in is present.
The variable in
is the value of the input.
The expression will be true when the input is a multiple of 4.
Each state refines to a separate instance of the following model: