eeros_architecture:sequencer:define_sequence
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
eeros_architecture:sequencer:define_sequence [2019/03/14 10:27] – [Waiting in Sequences or Steps] graf | eeros_architecture:sequencer:define_sequence [2020/09/30 08:06] – [Returning Values] ursgraf | ||
---|---|---|---|
Line 7: | Line 7: | ||
class MyStep : public Step { | class MyStep : public Step { | ||
public: | public: | ||
- | MyStep(std:: | + | MyStep(std:: |
... | ... | ||
}; | }; | ||
Line 13: | Line 13: | ||
class MySequence : public Sequence { | class MySequence : public Sequence { | ||
public: | public: | ||
- | MySequence(std:: | + | MySequence(std:: |
... | ... | ||
}; | }; | ||
</ | </ | ||
- | Your constructor usually includes a name for the sequence or step, a reference to the sequencer, and a reference to the caller of this object. The latter point is very important, because every step or sequence must know its caller or owner. \\ | + | Your constructor usually includes a name for the sequence or step, a reference to the caller of this object. The latter point is very important, because every step or sequence must know its caller or owner. \\ |
- | You then initialize the sequence in the initializer list by writing '' | + | You then initialize the sequence in the initializer list by writing '' |
In the body of your constructor you define the attributes of your sequence. This includes: | In the body of your constructor you define the attributes of your sequence. This includes: | ||
Line 28: | Line 28: | ||
class MySequence : public Sequence { | class MySequence : public Sequence { | ||
public: | public: | ||
- | MySequence(std:: | + | MySequence(std:: |
// this sequence will run in its own thread and concurrently to its caller | // this sequence will run in its own thread and concurrently to its caller | ||
setTimeoutTime(2.5); | setTimeoutTime(2.5); | ||
Line 37: | Line 37: | ||
</ | </ | ||
- | If you define a main sequence which has no calling sequence and which must be nonblocking per default, you can make use of a simpler | + | If you define a main sequence which has no calling sequence and which must be nonblocking per default, you can make use of another |
<code cpp> | <code cpp> | ||
class MainSequence : public Sequence { | class MainSequence : public Sequence { | ||
Line 53: | Line 53: | ||
step2(); | step2(); | ||
step3(); | step3(); | ||
+ | return 0; | ||
} | } | ||
</ | </ | ||
- | Its mandatory to implement this function. If not, no work is done and the step or sequence terminates immediately. \\ | + | Its mandatory to implement this function. If not, no work is done and the step or sequence terminates immediately. |
There might be sequences which should never stop. This must be done as shown below: | There might be sequences which should never stop. This must be done as shown below: | ||
<code cpp> | <code cpp> | ||
Line 62: | Line 63: | ||
while (Sequencer:: | while (Sequencer:: | ||
// while (true) step1(); | // while (true) step1(); | ||
+ | return 0; | ||
} | } | ||
</ | </ | ||
Line 109: | Line 111: | ||
===== 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? | + | 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? |
- | <code cpp> | + | |
- | class StepA : public Step { | + | |
- | public: | + | |
- | StepA(std:: | + | |
- | int action() {time = std:: | + | |
- | bool checkExitCondition() { | + | |
- | return ((std:: | + | |
- | } | + | |
- | private: | + | |
- | std:: | + | |
- | }; | + | |
- | </ | + | |
- | This step simply takes a time stamp when running its action method. Its exit condition becomes | + | |
- | ===== Returning Values ===== | ||
eeros_architecture/sequencer/define_sequence.txt · Last modified: 2023/02/26 00:25 by ursgraf