EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Constant.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CONTROL_CONSTANT_HPP_
2 #define ORG_EEROS_CONTROL_CONSTANT_HPP_
3 
4 #include <type_traits>
6 #include <eeros/core/System.hpp>
7 
8 namespace eeros {
9  namespace control {
10 
11  template < typename T = double >
12  class Constant : public Block1o<T> {
13  public:
15  _clear<T>();
16  }
17 
18  Constant(T v) {
19  value = v;
20  }
21 
22  virtual void run() {
23  this->out.getSignal().setValue(value);
24  this->out.getSignal().setTimestamp(System::getTimeNs());
25  }
26 
27  virtual void setValue(T newValue) {
28  value = newValue;
29  }
30 
31  protected:
32  T value;
33 
34  private:
35  template <typename S> typename std::enable_if<std::is_arithmetic<S>::value>::type _clear() {
36  value = 0;
37  }
38 
39  template <typename S> typename std::enable_if<!std::is_arithmetic<S>::value>::type _clear() {
40  value.fill(0);
41  }
42  };
43  };
44 };
45 
46 #endif /* ORG_EEROS_CONTROL_CONSTANT_HPP_ */
Constant()
Definition: Constant.hpp:14
T value
Definition: Constant.hpp:32
int v
Definition: RingBufferTest.cpp:14
Definition: Block1o.hpp:12
static uint64_t getTimeNs()
Definition: System_POSIX.cpp:30
Definition: Constant.hpp:12
Output< T > out
Definition: Block1o.hpp:21
virtual void setValue(T newValue)
Definition: Constant.hpp:27
type
Definition: Sequencer.hpp:15
virtual void run()
Definition: Constant.hpp:22
Constant(T v)
Definition: Constant.hpp:18