Example with Nonblocking Sequence
The following example all have a main sequence which calls a few steps and a another sequence. This second sequence is a nonblocking sequence. That means that the main sequence runs in parallel to the second sequence. A timeout monitor either supervises the main sequence or the second sequence.
Main Sequence Calls Nonblocking Sequence
In the EEROS library you will find a directory with examples. For this example see SequencerTest30.cpp.
Open a shell in the build directory of your EEROS library and run
$ ./examples/sequencer/sequencerTest30
The main sequences starts with three Step A
after which the Sequence B
is called. Sequence B
is nonblocking, that means both sequences run in parallel. The main sequence will do three more Step A
before finishing.
Please note the method action of the main sequence.
int action() { for (int i = 0; i < 3; i++) { stepA(1); } seqS(); for (int i = 0; i < 3; i++) { stepA(1); } seqS.wait(); return 0; }
At the end of the method you have to wait for the subsequence as it runs in its own thread.
Main Sequence Has Timeout Monitor
The next example is SequencerTest31.cpp. It demonstrates what happens if the main sequence is interrupted by a monitor while a subsequence is called. Run
$ examples/sequencer/sequencerTest31
The main sequence does three steps and starts the second sequence. The timeout monitor of the main sequence fires while the second sequence still runs. The monitor causes an exception sequence to run. After that the main sequence terminates immediately as the timeout behavior is set to abort
. The subsequence continues running in its own thread.
Main Sequence Has Timeout Monitor With Resume
The next example is SequencerTest32.cpp. It demonstrates what happens if the main sequence is interrupted by a monitor while a subsequence is called. Run
$ examples/sequencer/sequencerTest32
The main sequence does three steps and starts the second sequence. The timeout monitor of the main sequence fires while the second sequence still runs. The monitor causes an exception sequence to run. After that the main sequence continues where it was interrupted as the timeout behavior is set to resume
. The subsequence continues running in its own thread.
Main Sequence Has Timeout Monitor With Restart
The next example is SequencerTest33.cpp. It demonstrates what happens if the main sequence is interrupted by a monitor while a subsequence is called. Run
$ examples/sequencer/sequencerTest33
The main sequence does three steps and starts the second sequence. The timeout monitor of the main sequence fires while the second sequence still runs. The monitor causes an exception sequence to run. After that the main sequence starts again as the timeout behavior is set to restart
. The subsequence continues running in its own thread. The main sequence will again call the subsequence and the same procedure will follow. This would continue endlessly if the behavior would not change to abort
after three runs.
Subsequence Has Timeout Monitor
The next example is SequencerTest34.cpp. It demonstrates what happens if the subsequence is interrupted by a monitor while being called from the main sequence. Run
$ examples/sequencer/sequencerTest34
The main sequence does three steps and starts the second sequence. The timeout monitor of the subsequence fires. The monitor causes an exception sequence to run. After that the subsequence terminates immediately as the timeout behavior is set to abort
. The main sequence continues running in its own thread.
Subsequence Has Timeout Monitor With Resume
The next example is SequencerTest35.cpp. It demonstrates what happens if the subsequence is interrupted by a monitor while being called from the main sequence. Run
$ examples/sequencer/sequencerTest35
The main sequence does three steps and starts the second sequence. The timeout monitor of the subsequence fires. The monitor causes an exception sequence to run. After that the subsequence continues from where it was interrupted as the timeout behavior is set to resume
. The main sequence continues running in its own thread.
Subsequence Has Timeout Monitor With Restart
The next example is SequencerTest36.cpp. It demonstrates what happens if the subsequence is interrupted by a monitor while being called from the main sequence. Run
$ examples/sequencer/sequencerTest36
The main sequence does three steps and starts the second sequence. The timeout monitor of the subsequence fires. The monitor causes an exception sequence to run. After that the subsequence restarts as the timeout behavior is set to restart
. The main sequence continues running in its own thread. The subsequence would restart again and again while the main sequence would have to wait for it. After three restarts the timeout behavior is set to abort
and subsequence and main sequence terminate.