User Tools

Site Tools


Example with Several Sequences

Nonblocking Subsequence Has Timeout Monitor

In the EEROS library you will find a directory with examples. Open a shell in the build directory of your EEROS library and run examples/sequencer/SequencerTest2.

Flow of SequencerTest2

The main sequences starts with three Step A after which the Sequence B is called. Sequence B is nonblocking, that means, it will run in parallel. Step A and Step B will be called in parallel, though their waiting time is different. Sequence B has its timeout condition set to 2.5s. This causes its associated timeout monitor to interrupt the sequence and jump to an exception sequence. In the meantime the main sequence continues unhindered. After the exception sequence Sequence B is aborted, because its monitor behavior is set to abort. The program stops after the main sequences has finished running its steps. Please note the method action of the main sequence.

int action() {
  for (int i = 0; i < 3; i++) stepA(2);
  for (int i = 0; i < 5; i++) stepA(2);

At the end of the method you have to wait for the sequence B as it runs in its own thread.

Blocking Subsequence Has Timeout Monitor

A next example demonstrates what happens if the caller of a sequence is interrupted by a monitor. Run examples/sequencer/SequencerTest3.

Flow of SequencerTest3

The main sequence simply starts Sequence A which is called blocking. Sequence A has its timeout set to 3.5s. It does two Step A (each of them waits for a second) and then calls Sequence B which itself does several Step B. After Sequence B has started Sequence A times out. Its timeout monitor has no associated exception sequence. Hence, as the monitor has its sequence property set to abort, Sequence A will stop immediately. Sequence B will obviously stop as well. The main sequence has no further work to do and will reach its end.

Restarting Sequence A

Change the timeout behavior of the monitor to restart, recompile, and rerun the application. This time you will note, that Sequence A is interrupted after 2.5s together with Sequence B. However, Sequence A will restart and the whole procedure will repeat. You could change the action method of Sequence B to

while (getRunningState() == SequenceState::running) stepB(1);

The behavior does not change, because Sequence B never reaches more than one step.

Resuming Sequence A

For the last experiment change the timeout behavior of the monitor to resume. As soon as the timeout monitor fires, Sequence A resumes. The monitor would immediately fire again, as the timeout is not automatically reset for resume. In order for the example to make sense, you have to enable the exception sequence with


This in turn will reset the timeout and increase its value to allow Sequence A and Sequence B to finish.

getting_started/tutorials/sequencer2.txt · Last modified: 2019/04/04 18:23 by graf