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
57stateCodes::stateCodeT stateCodes::str2Code( const std::string & stateStr )
58{
59
60 if(stateStr == "FAILURE")
61 {
63 }
64 else if(stateStr == "ERROR")
65 {
66 return stateCodes::ERROR;
67 }
68 else if(stateStr == "UNINITIALIZED")
69 {
71 }
72 else if(stateStr == "INITIALIZED" )
73 {
75 }
76 else if(stateStr == "NODEVICE" )
77 {
79 }
80 else if(stateStr == "POWEROFF")
81 {
83 }
84 else if(stateStr == "POWERON")
85 {
87 }
88 else if(stateStr == "NOTCONNECTED")
89 {
91 }
92 else if(stateStr == "CONNECTED")
93 {
95 }
96 else if(stateStr == "LOGGEDIN")
97 {
99 }
100 else if(stateStr == "CONFIGURING")
101 {
103 }
104 else if(stateStr == "NOTHOMED")
105 {
107 }
108 else if(stateStr == "HOMING")
109 {
110 return stateCodes::HOMING;
111 }
112 else if(stateStr == "OPERATING")
113 {
115 }
116 else if(stateStr == "READY")
117 {
118 return stateCodes::READY;
119 }
120 else if(stateStr == "SHUTDOWN")
121 {
123 }
124 else
125 {
126 return -999;
127 }
128
129}
130
132{
133 switch(stateStr[0])
134 {
135 case 'C':
136 if(stateStr.size() < 4)
137 {
138 return -999;
139 }
140
141 if( stateStr[3] == 'F')
142 {
144 }
145 else if( stateStr[3] == 'N')
146 {
148 }
149 else
150 {
151 return -999;
152 }
153 case 'E':
154 return stateCodes::ERROR;
155 case 'F':
156 return stateCodes::FAILURE;
157 case 'H':
158 return stateCodes::HOMING;
159 case 'I':
160 return INITIALIZED;
161 case 'L':
162 return LOGGEDIN;
163 case 'N':
164 if(size(stateStr) < 4)
165 {
166 return -999;
167 }
168 if(stateStr[2] == 'D')
169 {
171 }
172 else if(stateStr[3] == 'C')
173 {
175 }
176 else if(stateStr[3] == 'H')
177 {
179 }
180 else
181 {
182 return -999;
183 }
184 case 'O':
186 case 'P':
187 if(stateStr.size() < 7)
188 {
189 return -999;
190 }
191
192 if(stateStr[6] == 'F')
193 {
195 }
196 else if(stateStr[6] == 'N')
197 {
198 return stateCodes::POWERON;
199 }
200 else
201 {
202 return -999;
203 }
204 case 'R':
205 return stateCodes::READY;
206 case 'S':
208 case 'U':
210 default:
211 return -999;
212 }
213}
214
215} //namespace app
216} //namespace MagAOX
217
@ 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:28
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.