EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
SafetyLevel.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_SAFETY_SAFETYLEVEL_HPP_
2 #define ORG_EEROS_SAFETY_SAFETYLEVEL_HPP_
3 
4 #include <stdint.h>
5 #include <string>
6 #include <vector>
7 #include <sstream>
8 #include <map>
9 #include <functional>
12 
13 namespace eeros {
14  namespace safety {
15 
16  class SafetyContext;
17  class SafetySystem;
18 
20 
21  class SafetyEvent {
22  friend class SafetyLevel;
23  public:
24  SafetyEvent(std::string description);
25  virtual ~SafetyEvent();
26  std::string getDescription();
27  private:
28  std::string description;
29  uint32_t id;
30  };
31 
32 
33  class SafetyLevel {
34  friend class SafetySystem;
35  friend class SafetyProperties;
36  public:
37  SafetyLevel(std::string description);
38  virtual ~SafetyLevel();
39  std::string getDescription();
40  uint32_t getLevelId();
41  uint32_t getNofActivations();
42  SafetyLevel* getDestLevelForEvent(SafetyEvent event, bool privateEventOk = false);
43  void addEvent(SafetyEvent event, SafetyLevel& nextLevel, EventType type = kPrivateEvent);
44  void setInputAction(InputAction* action); // TODO rename to add...
45  void setInputActions(std::vector<InputAction*> actionList);
46  void setOutputAction(OutputAction* action); // TODO rename to add...
47  void setOutputActions(std::vector<OutputAction*> actionList);
48  void setLevelAction(std::function<void (SafetyContext* context)> action);
49  bool operator<(const SafetyLevel& level);
50  bool operator<=(const SafetyLevel& level);
51  bool operator>(const SafetyLevel& level);
52  bool operator>=(const SafetyLevel& level);
53  bool operator==(const SafetyLevel& level);
54  bool operator!=(const SafetyLevel& level);
55  private:
56  std::function<void (SafetyContext*)> action;
57  int32_t id;
58  uint32_t nofActivations;
59  std::string description;
60  std::map<uint32_t, std::pair<SafetyLevel*, EventType>> transitions;
61  std::vector<InputAction*> inputAction;
62  std::vector<OutputAction*> outputAction;
63  };
64 
65  /********** Print functions **********/
66  std::ostream& operator<<(std::ostream& os, eeros::safety::SafetyEvent& event);
67  std::ostream& operator<<(std::ostream& os, eeros::safety::SafetyEvent* event);
68  std::ostream& operator<<(std::ostream& os, eeros::safety::SafetyLevel& level);
69  std::ostream& operator<<(std::ostream& os, eeros::safety::SafetyLevel* level);
70 
71  }
72 }
73 #endif // ORG_EEROS_SAFETY_SAFETYLEVEL_HPP_
Safety system.
Definition: SafetySystem.hpp:19
SafetyEvent(std::string description)
Definition: SafetyLevel.cpp:6
friend class SafetyLevel
Definition: SafetyLevel.hpp:22
Definition: SafetyLevel.hpp:33
Definition: SafetyLevel.hpp:19
EventType
Definition: SafetyLevel.hpp:19
Definition: Config.hpp:14
Definition: OutputAction.hpp:12
Definition: SafetyContext.hpp:12
Definition: InputAction.hpp:14
std::string getDescription()
Definition: SafetyLevel.cpp:14
Definition: SafetyLevel.hpp:19
std::ostream & operator<<(std::ostream &os, eeros::safety::SafetyEvent &event)
Definition: SafetyLevel.cpp:96
Definition: SafetyProperties.hpp:15
virtual ~SafetyEvent()
Definition: SafetyLevel.cpp:11
Definition: SafetyLevel.hpp:21