API
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 
16 namespace MagAOX
17 {
18 namespace 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  */
29 struct stateCodes
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.
Definition: stateCodes.hpp:55
@ POWEROFF
The device power is off.
Definition: stateCodes.hpp:47
@ NODEVICE
No device exists for the application to control.
Definition: stateCodes.hpp:46
@ SHUTDOWN
The application has shutdown, set just after calling appShutdown().
Definition: stateCodes.hpp:57
@ NOTHOMED
The device has not been homed.
Definition: stateCodes.hpp:53
@ HOMING
The device is homing.
Definition: stateCodes.hpp:54
@ FAILURE
The application has failed, should be used when m_shutdown is set for an error.
Definition: stateCodes.hpp:42
@ CONFIGURING
The application is configuring the device.
Definition: stateCodes.hpp:52
@ ERROR
The application has encountered an error, from which it is recovering (with or without intervention)
Definition: stateCodes.hpp:43
@ READY
The device is ready for operation, but is not operating.
Definition: stateCodes.hpp:56
@ LOGGEDIN
The application has logged into the device or service.
Definition: stateCodes.hpp:51
@ CONNECTED
The application has connected to the device or service.
Definition: stateCodes.hpp:50
@ UNINITIALIZED
The application is unitialized, the default.
Definition: stateCodes.hpp:44
@ INITIALIZED
The application has been initialized, set just before calling appStartup().
Definition: stateCodes.hpp:45
@ NOTCONNECTED
The application is not connected to the device or service.
Definition: stateCodes.hpp:49
@ POWERON
The device power is on.
Definition: stateCodes.hpp:48
Definition: dm.hpp:24
Scoping struct for application state codes.
Definition: stateCodes.hpp:30
static stateCodeT str2CodeFast(const std::string &stateStr)
Get the stateCode corresponding to an ASCII string with minimal checks.
Definition: stateCodes.cpp:133
int16_t stateCodeT
The type of the state code.
Definition: stateCodes.hpp:35
static stateCodeT str2Code(const std::string &stateStr)
Get the stateCode corresponding to an ASCII string.
Definition: stateCodes.cpp:59
static std::string codeText(const stateCodeT &stateCode)
Get an ASCII string corresponding to an application stateCode.
Definition: stateCodes.cpp:16