API
 
Loading...
Searching...
No Matches
MagAOX::app::stateCodes Struct Reference

Scoping struct for application state codes. More...

#include <stateCodes.hpp>

Collaboration diagram for MagAOX::app::stateCodes:
Collaboration graph

Public Types

enum  : stateCodeT {
  FAILURE =-20 , ERROR =-10 , UNINITIALIZED = 0 , INITIALIZED = 1 ,
  NODEVICE = 2 , POWEROFF = 4 , POWERON = 6 , NOTCONNECTED = 8 ,
  CONNECTED = 10 , LOGGEDIN = 15 , CONFIGURING = 20 , NOTHOMED = 24 ,
  HOMING = 25 , OPERATING = 30 , READY = 35 , SHUTDOWN = 10000
}
 The numeric codes describing an application's state. More...
 
typedef int16_t stateCodeT
 The type of the state code.
 

Static Public Member Functions

static std::string codeText (const stateCodeT &stateCode)
 Get an ASCII string corresponding to an application stateCode.
 
static stateCodeT str2Code (const std::string &stateStr)
 Get the stateCode corresponding to an ASCII string.
 
static stateCodeT str2CodeFast (const std::string &stateStr)
 Get the stateCode corresponding to an ASCII string with minimal checks.
 

Detailed Description

Scoping struct for application state codes.

We do not use the enum class feature since it does not have automatic integer conversion, and it's nice to have static member functions associated.

Todo:
this ought to be renamed stateCode (no s)

Definition at line 29 of file stateCodes.hpp.

Member Typedef Documentation

◆ stateCodeT

The type of the state code.

Definition at line 35 of file stateCodes.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : stateCodeT

The numeric codes describing an application's state.

Enumerator
FAILURE 

The application has failed, should be used when m_shutdown is set for an error.

ERROR 

The application has encountered an error, from which it is recovering (with or without intervention)

UNINITIALIZED 

The application is unitialized, the default.

INITIALIZED 

The application has been initialized, set just before calling appStartup().

NODEVICE 

No device exists for the application to control.

POWEROFF 

The device power is off.

POWERON 

The device power is on.

NOTCONNECTED 

The application is not connected to the device or service.

CONNECTED 

The application has connected to the device or service.

LOGGEDIN 

The application has logged into the device or service.

CONFIGURING 

The application is configuring the device.

NOTHOMED 

The device has not been homed.

HOMING 

The device is homing.

OPERATING 

The device is operating, other than homing.

READY 

The device is ready for operation, but is not operating.

SHUTDOWN 

The application has shutdown, set just after calling appShutdown().

Definition at line 42 of file stateCodes.hpp.

Member Function Documentation

◆ codeText()

std::string MagAOX::app::stateCodes::codeText ( const stateCodeT stateCode)
static

Get an ASCII string corresponding to an application stateCode.

Returns
a string with the text name of the stateCode
Todo:
rename this to code2str
Parameters
[in]stateCodethe stateCode for which the name is desired

Definition at line 16 of file stateCodes.cpp.

References CONFIGURING, CONNECTED, ERROR, FAILURE, HOMING, INITIALIZED, LOGGEDIN, NODEVICE, NOTCONNECTED, NOTHOMED, OPERATING, POWEROFF, POWERON, READY, SHUTDOWN, and UNINITIALIZED.

Referenced by MagAOX::app::siglentSDG::appLogic(), MagAOX::logger::state_change::from(), MagAOX::logger::state_change::msgString(), SCENARIO(), and MagAOX::logger::state_change::to().

◆ str2Code()

stateCodes::stateCodeT MagAOX::app::stateCodes::str2Code ( const std::string &  stateStr)
static

Get the stateCode corresponding to an ASCII string.

Returns
the stateCodeT which matches the string
Parameters
[in]stateStrthe string represenation of a state code

Definition at line 57 of file stateCodes.cpp.

References CONFIGURING, CONNECTED, ERROR, FAILURE, HOMING, INITIALIZED, LOGGEDIN, NODEVICE, NOTCONNECTED, NOTHOMED, OPERATING, POWEROFF, POWERON, READY, SHUTDOWN, and UNINITIALIZED.

Referenced by fsmNode::loadConfigDerived(), and SCENARIO().

◆ str2CodeFast()

stateCodes::stateCodeT MagAOX::app::stateCodes::str2CodeFast ( const std::string &  stateStr)
static

Get the stateCode corresponding to an ASCII string with minimal checks.

This matches based on the first character and, if necessary, one more unique character. Other than length checks when necessary, this does minimal validation, so you should only use it if you trust the source of stateStr. For example, any string that starts with ‘'L’will return stateCodes::LOGGEDIN regardless of the value ofstateStr[1]`.

Returns
the stateCodeT which matches the string
Parameters
[in]stateStrthe string represenation of a state code

Definition at line 131 of file stateCodes.cpp.

References CONFIGURING, CONNECTED, ERROR, FAILURE, HOMING, INITIALIZED, LOGGEDIN, NODEVICE, NOTCONNECTED, NOTHOMED, OPERATING, POWEROFF, POWERON, READY, SHUTDOWN, and UNINITIALIZED.

Referenced by fsmNode::handleSetProperty(), MagAOX::app::INDI_SETCALLBACK_DEFN(), and SCENARIO().


The documentation for this struct was generated from the following files: