EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PeripheralInput.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CONTROL_PERIPHERALINPUT_HPP
2 #define ORG_EEROS_CONTROL_PERIPHERALINPUT_HPP
3 
5 #include <eeros/hal/HAL.hpp>
8 
9 namespace eeros {
10  namespace control {
11 
12  template < typename T = double >
13  class PeripheralInput : public Block1o<T> {
14 
15  public:
16  PeripheralInput(std::string id) : hal(hal::HAL::instance()) {
17  systemInput = dynamic_cast<eeros::hal::PeripheralInput<T>*>(hal.getPeripheralInput(id));
18  if(systemInput == nullptr) throw EEROSException("Peripheral input '" + id + "' not found!");
19  }
20 
21  virtual void run() {
22  this->out.getSignal().setValue(systemInput->get());
23  this->out.getSignal().setTimestamp(System::getTimeNs());
24  }
25 
26  private:
27  hal::HAL& hal;
28  hal::PeripheralInput<T>* systemInput;
29  };
30 
31  };
32 };
33 
34 #endif // ORG_EEROS_CONTROL_PERIPHERALINPUT_HPP
PeripheralInput(std::string id)
Definition: PeripheralInput.hpp:16
PeripheralInputInterface * getPeripheralInput(std::string name, bool exclusive=false)
Definition: HAL.cpp:63
Definition: PeripheralInput.hpp:15
Definition: HAL.hpp:13
Definition: EEROSException.hpp:9
Definition: Block1o.hpp:12
static uint64_t getTimeNs()
Definition: System_POSIX.cpp:30
Output< T > out
Definition: Block1o.hpp:21
virtual void run()
Definition: PeripheralInput.hpp:21
Definition: PeripheralInput.hpp:13