EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
inputActions.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_SAFETY_INPUTACTIONS_HPP_
2 #define ORG_EEROS_SAFETY_INPUTACTIONS_HPP_
3 
6 
7 namespace eeros {
8  namespace safety {
9 
10  template <typename T>
11  class IgnoreInputAction : public InputAction {
12  public:
14  virtual ~IgnoreInputAction() { }
15  virtual bool check(SafetyContext* context) { return false; }
16 
17  private:
19  };
20 
21  template <typename T>
22  class CheckInputAction : public InputAction {
23  public:
24  CheckInputAction(eeros::hal::PeripheralInput<T>& input, T value, uint32_t event) : InputAction(input), input(input), value(value), event(event) { }
25  virtual ~CheckInputAction() { }
26  virtual bool check(SafetyContext* context) {
27  if(input.get() != value) {
28  context->triggerEvent(event);
29  return true;
30  }
31  return false;
32  }
33 
34  private:
36  T value;
37  uint32_t event;
38  };
39 
40  template <typename T>
42  public:
43  CheckRangeInputAction(eeros::hal::PeripheralInput<T>& input, T min, T max, uint32_t event) : InputAction(input), input(input), min(min), max(max), event(event) { }
44  virtual ~CheckRangeInputAction() { }
45  virtual bool check(SafetyContext* context) {
46  T value = input.get();
47  if (value < min || value > max) {
48  context->triggerEvent(event);
49  return true;
50  }
51  return false;
52  }
53 
54  private:
56  T min;
57  T max;
58  uint32_t event;
59  };
60 
61  template <typename T>
63  return new IgnoreInputAction<T>(input);
64  }
65 
66  template <typename T>
68  return new IgnoreInputAction<T>(*input);
69  }
70 
71  template <typename T>
72  CheckInputAction<T>* check(eeros::hal::PeripheralInput<T>& input, T value, uint32_t event) {
73  return new CheckInputAction<T>(input, value, event);
74  }
75 
76  template <typename T>
77  CheckInputAction<T>* check(eeros::hal::PeripheralInput<T>* input, T value, uint32_t event) {
78  return new CheckInputAction<T>(*input, value, event);
79  }
80 
81  template <typename T>
82  CheckRangeInputAction<T>* range(eeros::hal::PeripheralInput<T>& input, T min, T max, uint32_t event) {
83  return new CheckRangeInputAction<T>(input, min, max, event);
84  }
85 
86  template <typename T>
87  CheckRangeInputAction<T>* range(eeros::hal::PeripheralInput<T>* input, T min, T max, uint32_t event) {
88  return new CheckRangeInputAction<T>(*input, min, max, event);
89  }
90 
91  };
92 };
93 
94 #endif // ORG_EEROS_SAFETY_INPUTACTIONS_HPP_
Definition: PeripheralInput.hpp:15
CheckInputAction(eeros::hal::PeripheralInput< T > &input, T value, uint32_t event)
Definition: inputActions.hpp:24
IgnoreInputAction< T > * ignore(eeros::hal::PeripheralInput< T > &input)
Definition: inputActions.hpp:62
Definition: inputActions.hpp:22
CheckRangeInputAction< T > * range(eeros::hal::PeripheralInput< T > &input, T min, T max, uint32_t event)
Definition: inputActions.hpp:82
void triggerEvent(int32_t event)
Definition: SafetyContext.cpp:11
CheckRangeInputAction(eeros::hal::PeripheralInput< T > &input, T min, T max, uint32_t event)
Definition: inputActions.hpp:43
virtual bool check(SafetyContext *context)
Definition: inputActions.hpp:15
CheckInputAction< T > * check(eeros::hal::PeripheralInput< T > &input, T value, uint32_t event)
Definition: inputActions.hpp:72
IgnoreInputAction(eeros::hal::PeripheralInput< T > &input)
Definition: inputActions.hpp:13
Definition: SafetyContext.hpp:11
Definition: InputAction.hpp:12
virtual bool check(SafetyContext *context)
Definition: inputActions.hpp:45
virtual ~CheckRangeInputAction()
Definition: inputActions.hpp:44
virtual bool check(SafetyContext *context)
Definition: inputActions.hpp:26
Definition: inputActions.hpp:41
virtual ~CheckInputAction()
Definition: inputActions.hpp:25
Definition: inputActions.hpp:11
virtual ~IgnoreInputAction()
Definition: inputActions.hpp:14