dynamic_graph_manager
periodic-call.hh
Go to the documentation of this file.
1 
10 #ifndef PERIODICCALL_HH
11 #define PERIODICCALL_HH
12 
13 #include <dynamic-graph/entity.h>
14 #include <dynamic-graph/signal-base.h>
15 #include <dynamic-graph/python/interpreter.hh>
16 
17 #include <list>
18 #include <map>
19 #include <string>
20 
21 namespace dynamic_graph
22 {
27 {
28 protected:
29  struct SignalToCall
30  {
31  dynamicgraph::SignalBase<int>* signal_;
32  unsigned int down_sampling_factor_;
33 
34  SignalToCall()
35  {
36  signal_ = NULL;
37  down_sampling_factor_ = 1;
38  }
39 
40  SignalToCall(dynamicgraph::SignalBase<int>* s, unsigned int df = 1)
41  {
42  signal_ = s;
43  down_sampling_factor_ = df;
44  }
45  };
46 
47  typedef std::map<std::string, SignalToCall> SignalMapType;
48  SignalMapType signal_map_;
49 
50  typedef std::list<std::string> CmdListType;
51  CmdListType cmd_list_;
52 
53  int inner_time_;
54  dynamicgraph::python::Interpreter* py_interpreter_;
55 
56  /* --- FUNCTIONS
57  * ------------------------------------------------------------ */
58 public:
59  PeriodicCall(void);
60  virtual ~PeriodicCall(void)
61  {
62  }
63 
64  void addDownsampledSignal(const std::string& name,
65  dynamicgraph::SignalBase<int>& sig,
66  const unsigned int& downsamplingFactor);
67  void addDownsampledSignal(const std::string& sigpath,
68  const unsigned int& downsamplingFactor);
69 
70  void addSignal(const std::string& name, dynamicgraph::SignalBase<int>& sig);
71  void addSignal(const std::string& args);
72  void rmSignal(const std::string& name);
73 
74  void addCmd(const std::string& args);
75  void rmCmd(const std::string& args);
76 
77  void runSignals(const int& t);
78  void runCmds(void);
79  void run(const int& t);
80 
81  void clear(void)
82  {
83  signal_map_.clear();
84  cmd_list_.clear();
85  }
86 
87  void display(std::ostream& os) const;
88  bool commandLine(const std::string& cmdLine,
89  std::istringstream& cmdArgs,
90  std::ostream& os);
91  void addSpecificCommands(dynamicgraph::Entity& ent,
92  dynamicgraph::Entity::CommandMap_t& commap,
93  const std::string& prefix = "");
94 
95  void setPyInterpreter(dynamicgraph::python::Interpreter* py_interpreter)
96  {
97  py_interpreter_ = py_interpreter;
98  }
99 };
100 
101 } // namespace dynamic_graph
102 
103 #endif // #ifndef PERIODICCALL_HH
Definition: periodic-call.hh:26
this is this package namespace in order to avoid naming conflict
Definition: device.hh:22
Definition: periodic-call.hh:29