User Tools

Site Tools


eeros_architecture:sequencer:define_sequence

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
eeros_architecture:sequencer:define_sequence [2019/03/14 10:30] – [Returning Values] grafeeros_architecture:sequencer:define_sequence [2019/03/20 11:49] – [Waiting in Sequences or Steps] graf
Line 109: Line 109:
  
 ===== Waiting in Sequences or Steps ===== ===== Waiting in Sequences or Steps =====
-As mentioned before you should never wait by using //sleep// in a action method. However, quite often it is desirable to wait for some time to pass when running sequences. How to do properly? Study the following example: +As mentioned before you should never wait by using //sleep// in a action method. However, quite often it is desirable to wait for some time to pass when running sequences. How to do properly? Use the predefined step ''Wait''Study the examples in [[getting_started:tutorials:start|]]
-<code cpp> + 
-class StepA public Step { +Contrary to a simple //sleep// it does not block the sequencer and the checking of monitors of this step or sequence continues unhindered.
-public+
-  StepA(std::string name, Sequencer& seq, BaseSequence* caller) : Step(name, seq, caller) { } +
-  int action() {time = std::chrono::steady_clock::now();+
-  bool checkExitCondition() { +
-    return ((std::chrono::duration<double>)(std::chrono::steady_clock::now() - time)).count() > 3.2; +
-  } +
-private: +
-  std::chrono::time_point<std::chrono::steady_clock> time; +
-}; +
-</code> +
-This step simply takes a time stamp when running its action method. Its exit condition becomes ''true'' as soon as a waiting time of 3.2s has elapsed. However, contrary to a simple //sleep// it does not block the sequencer and the checking of monitors of this step or sequence continues unhindered.+
  
 ===== Returning Values ===== ===== Returning Values =====
 A step or blocking sequence can return a value of type ''int''. This can be useful to hand back basic information to the calling sequence. A step or blocking sequence can return a value of type ''int''. This can be useful to hand back basic information to the calling sequence.
eeros_architecture/sequencer/define_sequence.txt · Last modified: 2023/02/26 00:25 by ursgraf