EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
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>
6 #include <eeros/core/Fault.hpp>
7 
8 namespace eeros {
9  namespace control {
10 
11  template < typename T = double >
12  class PeripheralInput : public Block1o<T> {
13 
14  public:
15  PeripheralInput(std::string id, bool exclusive = true) : hal(hal::HAL::instance()) {
16  systemInput = dynamic_cast<eeros::hal::Input<T>*>(hal.getInput(id, exclusive));
17  if(systemInput == nullptr) throw Fault("Peripheral input '" + id + "' not found!");
18  }
19 
20  virtual void run() {
21  this->out.getSignal().setValue(systemInput->get());
22 // this->out.getSignal().setTimestamp(System::getTimeNs());
23  this->out.getSignal().setTimestamp(systemInput->getTimestamp());
24  }
25 
26  template<typename ... ArgTypesIn>
27  void callInputFeature(std::string featureName, ArgTypesIn... args){
28  hal.callInputFeature(systemInput, featureName, args...);
29  }
30 
31  private:
32  hal::HAL& hal;
33  hal::Input<T>* systemInput;
34  };
35 
36  };
37 };
38 
39 #endif // ORG_EEROS_CONTROL_PERIPHERALINPUT_HPP
PeripheralInput(std::string id, bool exclusive=true)
Definition: PeripheralInput.hpp:15
InputInterface * getInput(std::string name, bool exclusive=true)
Definition: HAL.cpp:194
Definition: HAL.hpp:18
Definition: Input.hpp:17
Definition: Block1o.hpp:12
Definition: Config.hpp:14
Output< T > out
Definition: Block1o.hpp:23
void callInputFeature(InputInterface *obj, std::string featureName, ArgTypesIn...args)
Definition: HAL.hpp:48
Definition: Fault.hpp:9
virtual void run()
Definition: PeripheralInput.hpp:20
Definition: PeripheralInput.hpp:12
void callInputFeature(std::string featureName, ArgTypesIn...args)
Definition: PeripheralInput.hpp:27