User Tools

Site Tools


eeros_architecture:sequencer:sequence

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
eeros_architecture:sequencer:sequence [2018/08/07 12:41] – [Waiting for Sequences to Finish] grafeeros_architecture:sequencer:sequence [2024/12/01 11:50] (current) – [Waiting for Sequences to Finish] ursgraf
Line 5: Line 5:
 A main feature of a sequence is whether it blocks the flow of control during running through its steps or whether the steps run in parallel to the main flow of control. A main feature of a sequence is whether it blocks the flow of control during running through its steps or whether the steps run in parallel to the main flow of control.
 [{{ :eeros_architecture:sequencer:sequenceblocking.png?500 | //Sequence B is blocking, sequence C is nonblocking// }}] [{{ :eeros_architecture:sequencer:sequenceblocking.png?500 | //Sequence B is blocking, sequence C is nonblocking// }}]
-Sequence A runs. That is, all its steps run consecutively. After step 1 is done the sequence B is called. As B is blocking its two steps run while A is being blocked. Only after B finishes does the control return back to A where step 2 and step 3 are then executed. After this sequence C is called. As C is nonblocking its two steps run in parallel to the remaining steps of sequence A. A must wait for C to finish by calling //join//. \\+Sequence A runs. That is, all its steps run consecutively. After step 1 is done the sequence B is called. As B is blocking its two steps run while A is being blocked. Only after B finishes does the control return back to A where step 2 and step 3 are then executed. After this sequence C is called. As C is nonblocking its two steps run in parallel to the remaining steps of sequence A. A must wait for C to finish by calling //wait()//. \\
 A nonblocking sequence will run in its own thread of execution while a blocking sequence always runs in the same thread as the calling sequence. A nonblocking sequence will run in its own thread of execution while a blocking sequence always runs in the same thread as the calling sequence.
  
Line 29: Line 29:
 class Move : public Step { class Move : public Step {
 public: public:
-  Move(std::string name, Sequencer& seq, BaseSequence* caller, Robot& r) : Step(name, seq, this) { }+  Move(std::string name, Sequence* caller, Robot& r) : Step(name, this) { }
   int operator() (double x, double y) {xPos = x; yPos = y; return start();}   int operator() (double x, double y) {xPos = x; yPos = y; return start();}
   int action() {   int action() {
     robot.setValue(xPos, yPos);     robot.setValue(xPos, yPos);
 +    return 0;
   }   }
   bool checkExitCondition() {   bool checkExitCondition() {
Line 42: Line 43:
 class MoveSequence : public Sequence { class MoveSequence : public Sequence {
 public: public:
-  MoveSequence(std::string name, Sequencer& seq) : Sequence(name, seq), moveXY("step", seq, this) { }+  MoveSequence(std::string name, Sequencer& seq) : Sequence(name, seq), moveXY("step", this) { }
   int action() {   int action() {
     robot.moveXY(10, 10)     robot.moveXY(10, 10)
     robot.moveXY(15, 25);     robot.moveXY(15, 25);
     robot.moveXY(22, 35);     robot.moveXY(22, 35);
 +    return 0;
   }   }
 private: private:
Line 56: Line 58:
  
 ===== Waiting for Sequences to Finish ===== ===== Waiting for Sequences to Finish =====
-Usually at some stage in your program you have to wait for a given sequence to finish until the program should continue. There are to methods to accomplish this. +Usually at some stage in your program you have to wait for a given sequence to finish until the program should continue. Let's assume that a main sequence starts another nonblocking sequence and at some stage wants to wait until this second sequence has finishedFor this a sequence can be waited for with ''wait()''. \\ 
-<code cpp> +This method returns as soon as all the steps defined in the sequence have completed running. In order to get the return value of the sequence you can use ''getResult()''. 
-  wait() +
-</code>+
eeros_architecture/sequencer/sequence.1533638508.txt.gz · Last modified: 2018/08/07 12:41 by graf