StateEnum.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // std
4 #include <cstdint>
5 #include <iostream>
6 #include <string>
7 
8 namespace rokubimini
9 {
10 namespace fsm
11 {
12 // FSM state IDs.
13 // NOTE: This mapping must be equal to the mapping in the firmware.
14 // For now I'm using random numbers
15 #define ROKUBIMINI_STATE_ID_CALIBRATE (0)
16 #define ROKUBIMINI_STATE_ID_DEVICE_MISSING (1)
17 #define ROKUBIMINI_STATE_ID_ERROR (2)
18 #define ROKUBIMINI_STATE_ID_FATAL (3)
19 #define ROKUBIMINI_STATE_ID_OPERATIONAL (4)
20 #define ROKUBIMINI_STATE_ID_NA (5)
21 #define ROKUBIMINI_STATE_ID_STANDBY (6)
22 
23 // FSM state names.
24 #define ROKUBIMINI_STATE_NAME_CALIBRATE ("Calibrate")
25 #define ROKUBIMINI_STATE_NAME_DEVICE_MISSING ("DeviceMissing")
26 #define ROKUBIMINI_STATE_NAME_ERROR ("Error")
27 #define ROKUBIMINI_STATE_NAME_FATAL ("Fatal")
28 #define ROKUBIMINI_STATE_NAME_OPERATIONAL ("Operational")
29 #define ROKUBIMINI_STATE_NAME_NA ("N/A")
30 #define ROKUBIMINI_STATE_NAME_STANDBY ("Standby")
31 
36 enum class StateEnum
37 {
38  CALIBRATE,
40  ERROR,
41  FATAL,
43  NA,
44  STANDBY,
45 };
46 
54 uint16_t stateEnumToId(const StateEnum stateEnum);
55 
63 StateEnum stateIdToEnum(uint16_t stateId);
64 
72 std::string stateEnumToName(const StateEnum stateEnum);
73 
81 StateEnum stateNameToEnum(const std::string& string);
82 
91 std::ostream& operator<<(std::ostream& out, const StateEnum stateEnum);
92 
93 } // namespace fsm
94 } // namespace rokubimini
StateEnum stateNameToEnum(const std::string &string)
Gets a state enumeration matching the state name.
Definition: StateEnum.cpp:103
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
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