API
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 descrbing an application's state. More...
 
typedef int16_t stateCodeT
 The type of the state code. More...
 

Static Public Member Functions

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

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 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.

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

◆ 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 59 of file stateCodes.cpp.

Referenced by 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 133 of file stateCodes.cpp.

Referenced by SCENARIO().


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