StateEnum.cpp
Go to the documentation of this file.
1 // rokubimini
3 
4 namespace rokubimini
5 {
6 namespace fsm
7 {
8 #define ROKUBIMINI_STATE_ID_CALIBRATE (0)
9 #define ROKUBIMINI_STATE_ID_DEVICE_MISSING (1)
10 #define ROKUBIMINI_STATE_ID_ERROR (2)
11 #define ROKUBIMINI_STATE_ID_FATAL (3)
12 #define ROKUBIMINI_STATE_ID_OPERATIONAL (4)
13 #define ROKUBIMINI_STATE_ID_NA (5)
14 #define ROKUBIMINI_STATE_ID_STANDBY (6)
15 
16 uint16_t stateEnumToId(const StateEnum stateEnum)
17 {
18  if (stateEnum == StateEnum::CALIBRATE)
19  {
21  }
22  if (stateEnum == StateEnum::DEVICE_MISSING)
23  {
25  }
26  if (stateEnum == StateEnum::ERROR)
27  {
29  }
30  if (stateEnum == StateEnum::FATAL)
31  {
33  }
34  if (stateEnum == StateEnum::OPERATIONAL)
35  {
37  }
38  if (stateEnum == StateEnum::STANDBY)
39  {
41  }
43 }
44 
45 StateEnum stateIdToEnum(uint16_t stateId)
46 {
47  if (stateId == ROKUBIMINI_STATE_ID_CALIBRATE)
48  {
49  return StateEnum::CALIBRATE;
50  }
52  {
54  }
55  if (stateId == ROKUBIMINI_STATE_ID_ERROR)
56  {
57  return StateEnum::ERROR;
58  }
59  if (stateId == ROKUBIMINI_STATE_ID_FATAL)
60  {
61  return StateEnum::FATAL;
62  }
63  if (stateId == ROKUBIMINI_STATE_ID_OPERATIONAL)
64  {
66  }
67  if (stateId == ROKUBIMINI_STATE_ID_STANDBY)
68  {
69  return StateEnum::STANDBY;
70  }
71  return StateEnum::NA;
72 }
73 
74 std::string stateEnumToName(const StateEnum stateEnum)
75 {
76  if (stateEnum == StateEnum::CALIBRATE)
77  {
79  }
80  if (stateEnum == StateEnum::DEVICE_MISSING)
81  {
83  }
84  if (stateEnum == StateEnum::ERROR)
85  {
87  }
88  if (stateEnum == StateEnum::FATAL)
89  {
91  }
92  if (stateEnum == StateEnum::OPERATIONAL)
93  {
95  }
96  if (stateEnum == StateEnum::STANDBY)
97  {
99  }
101 }
102 
103 StateEnum stateNameToEnum(const std::string& string)
104 {
105  if (string == ROKUBIMINI_STATE_NAME_CALIBRATE)
106  {
107  return StateEnum::CALIBRATE;
108  }
110  {
112  }
113  if (string == ROKUBIMINI_STATE_NAME_ERROR)
114  {
115  return StateEnum::ERROR;
116  }
117  if (string == ROKUBIMINI_STATE_NAME_FATAL)
118  {
119  return StateEnum::FATAL;
120  }
121  if (string == ROKUBIMINI_STATE_NAME_OPERATIONAL)
122  {
123  return StateEnum::OPERATIONAL;
124  }
125  if (string == ROKUBIMINI_STATE_NAME_STANDBY)
126  {
127  return StateEnum::STANDBY;
128  }
129  return StateEnum::NA;
130 }
131 
132 std::ostream& operator<<(std::ostream& out, const StateEnum stateEnum)
133 {
134  return out << stateEnumToName(stateEnum);
135 }
136 
137 } // namespace fsm
138 } // namespace rokubimini
#define ROKUBIMINI_STATE_ID_NA
Definition: StateEnum.cpp:13
#define ROKUBIMINI_STATE_ID_STANDBY
Definition: StateEnum.cpp:14
StateEnum stateNameToEnum(const std::string &string)
Gets a state enumeration matching the state name.
Definition: StateEnum.cpp:103
#define ROKUBIMINI_STATE_NAME_FATAL
Definition: StateEnum.hpp:27
#define ROKUBIMINI_STATE_ID_ERROR
Definition: StateEnum.cpp:10
#define ROKUBIMINI_STATE_NAME_DEVICE_MISSING
Definition: StateEnum.hpp:25
#define ROKUBIMINI_STATE_NAME_NA
Definition: StateEnum.hpp:29
#define ROKUBIMINI_STATE_NAME_STANDBY
Definition: StateEnum.hpp:30
#define ROKUBIMINI_STATE_ID_FATAL
Definition: StateEnum.cpp:11
#define ROKUBIMINI_STATE_ID_DEVICE_MISSING
Definition: StateEnum.cpp:9
#define ROKUBIMINI_STATE_NAME_CALIBRATE
Definition: StateEnum.hpp:24
#define ROKUBIMINI_STATE_NAME_OPERATIONAL
Definition: StateEnum.hpp:28
#define ROKUBIMINI_STATE_NAME_ERROR
Definition: StateEnum.hpp:26
uint16_t stateEnumToId(const StateEnum stateEnum)
Gets an ID matching the state enumeration.
Definition: StateEnum.cpp:16
StateEnum stateIdToEnum(uint16_t stateId)
Gets a state enumeration matching the state ID.
Definition: StateEnum.cpp:45
std::ostream & operator<<(std::ostream &out, const StateEnum stateEnum)
Outputs the name of the state enumeration to an output stream.
Definition: StateEnum.cpp:132
#define ROKUBIMINI_STATE_ID_OPERATIONAL
Definition: StateEnum.cpp:12
#define ROKUBIMINI_STATE_ID_CALIBRATE
Definition: StateEnum.cpp:8
std::string stateEnumToName(const StateEnum stateEnum)
Gets a name matching the state enumeration.
Definition: StateEnum.cpp:74
Tests Configuration.


rokubimini
Author(s):
autogenerated on Wed Mar 3 2021 03:09:12