API
 
Loading...
Searching...
No Matches
stateCodes.cpp
Go to the documentation of this file.
1/** \file stateCodes.cpp
2 * \brief MagAO-X Application States
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 *
6 * \ingroup app_files
7 */
8
9#include "stateCodes.hpp"
10
11namespace MagAOX
12{
13namespace app
14{
15
16std::string stateCodes::codeText( const stateCodeT & stateCode )
17{
18 switch(stateCode)
19 {
21 return "FAILURE";
23 return "ERROR";
25 return "UNINITIALIZED";
27 return "INITIALIZED";
29 return "NODEVICE";
31 return "POWEROFF";
33 return "POWERON";
35 return "NOTCONNECTED";
37 return "CONNECTED";
39 return "LOGGEDIN";
41 return "CONFIGURING";
43 return "NOTHOMED";
45 return "HOMING";
47 return "OPERATING";
49 return "READY";
51 return "SHUTDOWN";
52 default:
53 return "UNKNOWN";
54 }
55
56 return "UNKNOWN";
57}
58
59stateCodes::stateCodeT stateCodes::str2Code( const std::string & stateStr )
60{
61
62 if(stateStr == "FAILURE")
63 {
65 }
66 else if(stateStr == "ERROR")
67 {
68 return stateCodes::ERROR;
69 }
70 else if(stateStr == "UNINITIALIZED")
71 {
73 }
74 else if(stateStr == "INITIALIZED" )
75 {
77 }
78 else if(stateStr == "NODEVICE" )
79 {
81 }
82 else if(stateStr == "POWEROFF")
83 {
85 }
86 else if(stateStr == "POWERON")
87 {
89 }
90 else if(stateStr == "NOTCONNECTED")
91 {
93 }
94 else if(stateStr == "CONNECTED")
95 {
97 }
98 else if(stateStr == "LOGGEDIN")
99 {
101 }
102 else if(stateStr == "CONFIGURING")
103 {
105 }
106 else if(stateStr == "NOTHOMED")
107 {
109 }
110 else if(stateStr == "HOMING")
111 {
112 return stateCodes::HOMING;
113 }
114 else if(stateStr == "OPERATING")
115 {
117 }
118 else if(stateStr == "READY")
119 {
120 return stateCodes::READY;
121 }
122 else if(stateStr == "SHUTDOWN")
123 {
125 }
126 else
127 {
128 return -999;
129 }
130
131}
132
134{
135 switch(stateStr[0])
136 {
137 case 'C':
138 if(stateStr.size() < 4)
139 {
140 return -999;
141 }
142
143 if( stateStr[3] == 'F')
144 {
146 }
147 else if( stateStr[3] == 'N')
148 {
150 }
151 else
152 {
153 return -999;
154 }
155 case 'E':
156 return stateCodes::ERROR;
157 case 'F':
158 return stateCodes::FAILURE;
159 case 'H':
160 return stateCodes::HOMING;
161 case 'I':
162 return INITIALIZED;
163 case 'L':
164 return LOGGEDIN;
165 case 'N':
166 if(size(stateStr) < 4)
167 {
168 return -999;
169 }
170 if(stateStr[2] == 'D')
171 {
173 }
174 else if(stateStr[3] == 'C')
175 {
177 }
178 else if(stateStr[3] == 'H')
179 {
181 }
182 else
183 {
184 return -999;
185 }
186 case 'O':
188 case 'P':
189 if(stateStr.size() < 7)
190 {
191 return -999;
192 }
193
194 if(stateStr[6] == 'F')
195 {
197 }
198 else if(stateStr[6] == 'N')
199 {
200 return stateCodes::POWERON;
201 }
202 else
203 {
204 return -999;
205 }
206 case 'R':
207 return stateCodes::READY;
208 case 'S':
210 case 'U':
212 default:
213 return -999;
214 }
215}
216
217} //namespace app
218} //namespace MagAOX
219
@ OPERATING
The device is operating, other than homing.
@ POWEROFF
The device power is off.
@ NODEVICE
No device exists for the application to control.
@ SHUTDOWN
The application has shutdown, set just after calling appShutdown().
@ NOTHOMED
The device has not been homed.
@ HOMING
The device is homing.
@ FAILURE
The application has failed, should be used when m_shutdown is set for an error.
@ CONFIGURING
The application is configuring the device.
@ ERROR
The application has encountered an error, from which it is recovering (with or without intervention)
@ READY
The device is ready for operation, but is not operating.
@ LOGGEDIN
The application has logged into the device or service.
@ CONNECTED
The application has connected to the device or service.
@ UNINITIALIZED
The application is unitialized, the default.
@ INITIALIZED
The application has been initialized, set just before calling appStartup().
@ NOTCONNECTED
The application is not connected to the device or service.
@ POWERON
The device power is on.
Definition dm.hpp:24
MagAO-X Application States.
static stateCodeT str2CodeFast(const std::string &stateStr)
Get the stateCode corresponding to an ASCII string with minimal checks.
int16_t stateCodeT
The type of the state code.
static stateCodeT str2Code(const std::string &stateStr)
Get the stateCode corresponding to an ASCII string.
static std::string codeText(const stateCodeT &stateCode)
Get an ASCII string corresponding to an application stateCode.