API
 
Loading...
Searching...
No Matches
stateCodes.hpp
Go to the documentation of this file.
1/** \file stateCodes.hpp
2 * \brief MagAO-X Application States
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * History:
6 * - 2018-01-20 created by JRM
7 *
8 * \ingroup app_files
9 */
10
11#ifndef app_stateCodes_hpp
12#define app_stateCodes_hpp
13
14#include <string>
15
16namespace MagAOX
17{
18namespace app
19{
20
21/// Scoping struct for application state codes.
22/** We do not use the enum class feature since it does not have automatic integer conversion,
23 * and it's nice to have static member functions associated.
24 *
25 * \todo this ought to be renamed stateCode (no s)
26 *
27 * \ingroup magaoxapp
28 */
30{
31
32 /// The type of the state code.
33 /**
34 */
35 typedef int16_t stateCodeT;
36
37
38 /// The numeric codes descrbing an application's state
39 /** \ingroup magaoxapp
40 *
41 */
42 enum : stateCodeT { FAILURE=-20, ///< The application has failed, should be used when m_shutdown is set for an error.
43 ERROR=-10, ///< The application has encountered an error, from which it is recovering (with or without intervention)
44 UNINITIALIZED = 0, ///< The application is unitialized, the default
45 INITIALIZED = 1, ///< The application has been initialized, set just before calling appStartup().
46 NODEVICE = 2, ///< No device exists for the application to control.
47 POWEROFF = 4, ///< The device power is off.
48 POWERON = 6, ///< The device power is on.
49 NOTCONNECTED = 8, ///< The application is not connected to the device or service.
50 CONNECTED = 10, ///< The application has connected to the device or service.
51 LOGGEDIN = 15, ///< The application has logged into the device or service
52 CONFIGURING = 20, ///< The application is configuring the device.
53 NOTHOMED = 24, ///< The device has not been homed.
54 HOMING = 25, ///< The device is homing.
55 OPERATING = 30, ///< The device is operating, other than homing.
56 READY = 35, ///< The device is ready for operation, but is not operating.
57 SHUTDOWN = 10000 ///< The application has shutdown, set just after calling appShutdown().
58 };
59
60
61 /// Get an ASCII string corresponding to an application stateCode.
62 /**
63 * \returns a string with the text name of the stateCode
64 *
65 * \todo rename this to code2str
66 */
67 static std::string codeText( const stateCodeT & stateCode /**<[in] the stateCode for which the name is desired*/);
68
69 /// Get the stateCode corresponding to an ASCII string.
70 /**
71 * \returns the stateCodeT which matches the string
72 *
73 */
74 static stateCodeT str2Code( const std::string & stateStr /**< [in] the string represenation of a state code */ );
75
76 /// Get the stateCode corresponding to an ASCII string with minimal checks.
77 /** This matches based on the first character and, if necessary, one more unique character.
78 * Other than length checks when necessary, this does minimal validation, so you should only use it
79 * if you trust the source of \p stateStr. For example, any string that starts with `'L'` will return
80 * stateCodes::LOGGEDIN regardless of the value of `stateStr[1]`.
81 *
82 * \returns the stateCodeT which matches the string
83 *
84 */
85 static stateCodeT str2CodeFast( const std::string & stateStr /**< [in] the string represenation of a state code */ );
86
87}; //struct stateCodes
88
89
90
91} //namespace app
92} //namespace MagAOX
93
94#endif //app_stateCodes_hpp
@ 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
Scoping struct for application state codes.
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.