EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Sequencer.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_SEQUENCER_SEQUENCER_HPP_
2 #define ORG_EEROS_SEQUENCER_SEQUENCER_HPP_
3 
4 #include <string>
5 #include <atomic>
6 #include <vector>
7 #include <mutex>
8 #include <condition_variable>
9 #include <eeros/core/Thread.hpp>
10 
11 namespace eeros {
12  namespace sequencer {
13 
14  namespace state {
16  }
17 
18  namespace mode {
19  enum type { automatic, stepping };
20  }
21 
22  // Forward declarations
23  template < typename Treturn, typename ... Targs >
24  class Sequence;
25 
26  class Sequencer : public Thread {
27  public:
28 
29  Sequencer();
30 
31  virtual bool start();
32  virtual bool start(Sequence<void>* sequence);
33  virtual bool start(unsigned int cmdSequenceIndex);
34  virtual void shutdown();
35 
36  virtual void stepMode(bool on = true);
37  virtual void toggleMode();
38 
39  virtual std::string getName() const;
40  virtual state::type getState() const;
41  virtual mode::type getMode() const;
42 
43  virtual void yield();
44  virtual void proceed();
45  virtual void abort();
46 
47  virtual void addCmdSequence(Sequence<void>* seq);
48  virtual const std::vector<Sequence<void>*>& getListOfCmdSequences();
49 
50  protected:
51  virtual void run();
52 
53  private:
54  std::vector<Sequence<void>*> cmdSequences;
55  std::atomic<Sequence<void>*> currentSequence;
56  unsigned int id;
57  std::atomic<state::type> state;
58  std::atomic<mode::type> mode;
59  std::atomic<bool> abortSequence;
60  std::mutex mtx;
61  std::condition_variable cv;
62  bool go;
63 
64  static int instanceCounter;
65 
66  }; // class Sequencer
67  }; // namespace sequencer
68 }; // namespace eeros
69 
70 #endif // ORG_EEROS_SEQUENCER_SEQUENCE_HPP_
virtual void toggleMode()
Definition: Sequencer.cpp:98
virtual void stepMode(bool on=true)
Definition: Sequencer.cpp:87
type
Definition: Sequencer.hpp:19
Definition: Sequencer.hpp:15
virtual void addCmdSequence(Sequence< void > *seq)
Definition: Sequencer.cpp:152
virtual std::string getName() const
Definition: Sequencer.cpp:146
virtual void run()
Definition: Sequencer.cpp:17
virtual void shutdown()
Definition: Sequencer.cpp:83
Definition: Sequencer.hpp:15
virtual const std::vector< Sequence< void > * > & getListOfCmdSequences()
Definition: Sequencer.cpp:156
Definition: Sequencer.hpp:19
Definition: Sequencer.hpp:26
virtual void abort()
Definition: Sequencer.cpp:130
type
Definition: Sequencer.hpp:15
Definition: Thread.hpp:13
virtual bool start()
Definition: Sequencer.cpp:56
virtual void yield()
Definition: Sequencer.cpp:110
Definition: Sequencer.hpp:15
Definition: Sequencer.hpp:19
virtual state::type getState() const
Definition: Sequencer.cpp:138
virtual mode::type getMode() const
Definition: Sequencer.cpp:142
Sequencer()
Definition: Sequencer.cpp:11
Definition: Sequencer.hpp:15
virtual void proceed()
Definition: Sequencer.cpp:124
Definition: Sequencer.hpp:15
Definition: Sequence.hpp:106