User Tools

Site Tools


eeros_architecture:sequencer:sequencer

Sequencer

The sequencer is responsible to run the main sequence. There is a single instance of the sequencer and therefore only one main sequence. Further, the sequencer contains a list with all sequences. Whenever you define a sequence it will automatically be added to this list. The list helps to retrieve a reference to a given sequence. This can be helpful is you wish to pass information into this sequence.
First, get the instance of the sequencer.

  auto& sequencer = Sequencer::instance();               // get instance

The next step is to define a meaningfull sequence (see Sequence) and add it to the sequencer. After this you can start the sequence with start(). The main program may terminate when the main sequencer has terminated. For this purpose it has to wait for the sequence thread.

  MainSequence mainSequence("Main Sequence", sequencer); // define main sequence
  sequencer.addSequence(mainSequence);                   // add it to the sequencer
  mainSequence.start();                                  // start it
  ...                                                    // do other things such as starting the executor
  sequencer.wait();                                      // wait for the sequencer to finish its sequence

Forcing the Sequencer to Stop Immediately

For a system under development you often want to abort a running system. This case must be handled carefully. As described in Shutting down a System Properly you may want to install an appropriate signal handler which shuts down the safety system. This action finally stops the executor. Further, you have to stop any running sequence. For this purpose every sequence includes a monitor with an associated abort condition. By calling

void signalHandler(int signum) {
  SafetySystem::exitHandler();
  Sequencer::instance().abort();
}

not only the safety system will gracefully shutdown but the sequencer running any set of sequences will abort as well. Please make sure that your program waits for those sequences to abort before your main program stops. This can be accomplished as follows:

  ...                                                  
  sequencer.wait();                                      // wait for any running sequence to abort
  ...
eeros_architecture/sequencer/sequencer.txt · Last modified: 2018/08/07 12:35 (external edit)