EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
Mux.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CONTROL_MUX_HPP_
2 #define ORG_EEROS_CONTROL_MUX_HPP_
3 
5 #include <eeros/math/Matrix.hpp>
8 
9 namespace eeros {
10  namespace control {
11 
12  template < uint32_t N, typename T = double, typename C = eeros::math::Matrix<N,1,T> >
13  class Mux: public Block {
14 
15  public:
16  Mux() {
17  for(uint8_t i = 0; i < N; i++) in[i].setOwner(this);
18  }
19 
20  virtual void run() {
21  C newValue;
22  for(int i = 0; i < N; i++) {
23  newValue(i) = in[i].getSignal().getValue();
24  }
25  out.getSignal().setValue(newValue);
26  out.getSignal().setTimestamp(in[0].getSignal().getTimestamp());
27  }
28 
29  virtual Input<T>& getIn(uint32_t index) {
30  return in[index];
31  }
32 
33  virtual Output<C>& getOut() {
34  return out;
35  }
36 
37  protected:
40  };
41 
42  };
43 };
44 
45 #endif /* ORG_EEROS_CONTROL_MUX_HPP_ */
Definition: Mux.hpp:13
virtual Signal< T > & getSignal()
Definition: Output.hpp:16
Mux()
Definition: Mux.hpp:16
virtual Input< T > & getIn(uint32_t index)
Definition: Mux.hpp:29
Definition: Config.hpp:14
Output< C > out
Definition: Mux.hpp:39
virtual void run()
Definition: Mux.hpp:20
Definition: Block.hpp:10
virtual void setValue(T newValue)
Definition: Signal.hpp:53
virtual Output< C > & getOut()
Definition: Mux.hpp:33
virtual void setTimestamp(timestamp_t newTimestamp)
Definition: Signal.hpp:66
Input< T > in[N]
Definition: Mux.hpp:38
Definition: Input.hpp:13