EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OutputAction.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_SAFETY_OUTPUTACTION_HPP_
2 #define ORG_EEROS_SAFETY_OUTPUTACTION_HPP_
3 
4 #include <stdint.h>
5 #include <eeros/hal/HAL.hpp>
6 
7 namespace eeros {
8  namespace safety {
9 
10  class OutputAction {
11  public:
12  virtual ~OutputAction() { }
13  virtual void set() { }
14  };
15 
16  template < typename T >
18  public:
19  LeaveOutputAction(eeros::hal::PeripheralOutput<T>& output) : output(output) { }
20  virtual ~LeaveOutputAction() { }
21  virtual void set() { }
22  private:
24  };
25 
26  template < typename T >
27  class SetOutputAction : public OutputAction {
28  public:
29  SetOutputAction(eeros::hal::PeripheralOutput<T>& output, T value) : output(output), value(value) { }
30  virtual ~SetOutputAction() { }
31  virtual void set() {
32  output.set(value);
33  }
34  private:
36  T value;
37  };
38 
39  template < typename T >
41  public:
42  ToggleOutputAction(eeros::hal::PeripheralOutput<T>& output, T low, T high) : output(output), value(low), low(low), high(high) { }
43  virtual ~ToggleOutputAction() { }
44  virtual void set() {
45  output.set(value);
46  if (value == low)
47  value = high;
48  else
49  value = low;
50  }
51  private:
53  T value;
54  T low;
55  T high;
56  };
57 
58  template <typename T>
60  return new SetOutputAction<T>(output, value);
61  }
62 
63  template <typename T>
65  return new SetOutputAction<T>(*output, value);
66  }
67 
68  template <typename T>
70  return new LeaveOutputAction<T>(output);
71  }
72 
73  template <typename T>
75  return new LeaveOutputAction<T>(*output);
76  }
77 
78  template <typename T>
79  ToggleOutputAction<T>* toggle(eeros::hal::PeripheralOutput<T>* output, T low = false, T high = true) {
80  return new ToggleOutputAction<T>(*output, low, high );
81  }
82  };
83 };
84 
85 #endif // ORG_EEROS_SAFETY_OUTPUTACTION_HPP_
virtual ~LeaveOutputAction()
Definition: OutputAction.hpp:20
Definition: PeripheralOutput.hpp:17
virtual void set()
Definition: OutputAction.hpp:13
virtual void set()
Definition: OutputAction.hpp:44
SetOutputAction(eeros::hal::PeripheralOutput< T > &output, T value)
Definition: OutputAction.hpp:29
virtual ~OutputAction()
Definition: OutputAction.hpp:12
virtual void set(T value)=0
virtual ~ToggleOutputAction()
Definition: OutputAction.hpp:43
Definition: OutputAction.hpp:27
Definition: OutputAction.hpp:10
LeaveOutputAction< T > * leave(eeros::hal::PeripheralOutput< T > &output)
Definition: OutputAction.hpp:69
Definition: OutputAction.hpp:17
LeaveOutputAction(eeros::hal::PeripheralOutput< T > &output)
Definition: OutputAction.hpp:19
SetOutputAction< T > * set(eeros::hal::PeripheralOutput< T > &output, T value)
Definition: OutputAction.hpp:59
virtual void set()
Definition: OutputAction.hpp:31
ToggleOutputAction(eeros::hal::PeripheralOutput< T > &output, T low, T high)
Definition: OutputAction.hpp:42
Definition: OutputAction.hpp:40
ToggleOutputAction< T > * toggle(eeros::hal::PeripheralOutput< T > *output, T low=false, T high=true)
Definition: OutputAction.hpp:79
virtual ~SetOutputAction()
Definition: OutputAction.hpp:30
virtual void set()
Definition: OutputAction.hpp:21