User Tools

Site Tools


getting_started:tutorials:sequencer3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:tutorials:sequencer3 [2020/12/03 17:46] ursgrafgetting_started:tutorials:sequencer3 [2021/03/31 15:39] (current) – [Subsequence Has Timeout Monitor With Restart] ursgraf
Line 1: Line 1:
 ====== Example with Nonblocking Sequence ====== ====== 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. 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 [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest30.cpp|SequencerTest30.cpp]].
 +
 +Open a shell in the build directory of your EEROS library and run 
 +<code>
 +$ ./examples/sequencer/sequencerTest30
 +</code>
 +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.
 +[{{ :getting_started:tutorials:sequencetest30.png?250 | //Calling a nonblocking sequence// }}]
 +\\
 +Please note the method //action// of the main sequence.
 +<code cpp>
 +  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;
 +  }
 +</code>
 +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 ===== ===== Main Sequence 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 +The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest31.cpp|SequencerTest31.cpp]]. It demonstrates what happens if the main sequence is interrupted by a monitor while a subsequence is called. Run 
 <code> <code>
-./examples/sequencer/sequencerTest20+$ examples/sequencer/sequencerTest31
 </code> </code>
-The main sequences starts with three ''Step A'' after which the ''Sequence B'' is called''Sequence B'' is blocking, that means, that the main sequence pauses while it runs. The main sequence will subsequently do three more ''Step A'' before finishing+ 
-[{{ :getting_started:tutorials:sequencetest20.png?250 | //Calling a blocking sequence// }}]+The main sequence does three steps and starts the second sequenceThe 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. 
 + 
 +[{{ :getting_started:tutorials:sequencetest31.png?500 | //Aborting the main sequence// }}]
 \\ \\
  
 +===== Main Sequence Has Timeout Monitor With Resume =====
  
-====== Example with several Monitors ======+The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest32.cpp|SequencerTest32.cpp]]. It demonstrates what happens if the main sequence is interrupted by a monitor while a subsequence is called. Run  
 +<code> 
 +$ examples/sequencer/sequencerTest32 
 +</code>
  
-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.+The main sequence does three steps and starts the second sequenceThe timeout monitor of the main sequence fires while the second sequence still runs. The monitor causes an exception sequence to runAfter 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.
  
-[{{ .:sequencerexample2.png?550 | //Flow of SequencerTest2// }}]+[{{ :getting_started:tutorials:sequencetest32.png?500 | //Resuming the main sequence// }}] 
 +\\
  
-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. +===== Main Sequence Has Timeout Monitor With Restart ===== 
-Please note the method //action// of the main sequence+ 
-<code cpp+The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest33.cpp|SequencerTest33.cpp]]It demonstrates what happens if the main sequence is interrupted by a monitor while a subsequence is calledRun  
-int action() { +<code> 
-  for (int i = 0; i < 3; i++) stepA(2); +$ examples/sequencer/sequencerTest33
-  seqB(); +
-  for (int i = 0; i < 5; i++) stepA(2); +
-  seqB.waitAndTerminate(); +
-}+
 </code> </code>
-At the end of the method you have to wait for the sequence B as it runs in its own thread. 
  
-===== Sequence with two Monitors =====+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.
  
-In the EEROS library you will find a directory with examplesOpen a shell in the build directory of your EEROS library and run ''examples/sequencer/SequencerTest4''+[{{ :getting_started:tutorials:sequencetest33.png?500 | //Resuming the main sequence// }}] 
 +\\
  
-[{{ .:sequencerexample4.png?450 | //Flow of SequencerTest4// }}]+===== Subsequence Has Timeout Monitor =====
  
-This example shows a sequence with two associated monitorsThe ''Main Sequence'' tries to run several steps called ''Step A''After each step counter is incrementedA monitor checks for this count to reach a given level (''MyMonitor'')As soon as this happens an exception sequence is started. After termination of the exception sequence the original sequence resumes because the monitor property is set to ''resume''. The ''Main Sequence'' continues and is soon interrupted by its timeout monitor because its timeout limit has expiredThe timeout monitor has no exception sequence assigned to it and immediately aborts the ''Main Sequence'' and with it the application because its monitor property is set to //abort//.+The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest34.cpp|SequencerTest34.cpp]]It demonstrates what happens if the subsequence is interrupted by monitor while being called from the main sequenceRun  
 +<code> 
 +$ examples/sequencer/sequencerTest34 
 +</code>
  
-==== Altering the Monitor Behavior ==== +The main sequence does three steps and starts the second sequence. The timeout monitor of the subsequence firesThe 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.
-Change the behavior of ''My Monitor'' to ''restart'', recompile, and observe what happens. After the exception sequence the ''Main Sequence'' restartsThis causes the counter to start with 0 and the timeout will be reset as well. Hence, the timeout monitor will never fire.\\ +
-If you change the behavior of the timeout monitor to ''restart'', things get more complicated''MyMonitor'' will fire, the exception sequence will run, the ''Main Sequence'' will resume, and the timeout monitor will fire. This monitor has no exception sequence but will simply restart the whole procedure+
  
-===== Monitor Checking two Sequences =====+[{{ :getting_started:tutorials:sequencetest34.png?500 | //Aborting the subsequence// }}] 
 +\\
  
-A next example demonstrates what happens if the same monitor checks two sequences. It can be found in ''examples/sequencer/SequencerTest5''+===== Subsequence Has Timeout Monitor With Resume =====
  
-[{{ .:sequencerexample5.png?550 | //Flow of SequencerTest5// }}]+The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest35.cpp|SequencerTest35.cpp]]. It demonstrates what happens if the subsequence is interrupted by a monitor while being called from the main sequence. Run  
 +<code> 
 +$ examples/sequencer/sequencerTest35 
 +</code> 
 + 
 +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. 
 + 
 +[{{ :getting_started:tutorials:sequencetest35.png?500 | //Resuming the subsequence// }}] 
 +\\ 
 + 
 +===== Subsequence Has Timeout Monitor With Restart ===== 
 + 
 +The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest36.cpp|SequencerTest36.cpp]]. It demonstrates what happens if the subsequence is interrupted by a monitor while being called from the main sequence. Run  
 +<code> 
 +$ examples/sequencer/sequencerTest36 
 +</code> 
 + 
 +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. 
 + 
 +[{{ :getting_started:tutorials:sequencetest36.png?500 | //Aborting the subsequence// }}] 
 +\\
  
-The ''Main Sequence'' and ''Sequence B'' have the same monitor. The ''Main Sequence'' tries to run several steps called ''Step A''. After each step a counter is incremented. A monitor checks for this count to reach a given level (''MyMonitor''). The same monitor also checks ''Sequence B'', which runs in parallel. As soon as the monitor condition is met, both sequences will abort because the monitor property is set to //abort// 
  
getting_started/tutorials/sequencer3.1607013996.txt.gz · Last modified: 2020/12/03 17:46 by ursgraf