42 if( action ==
"passive" )
46 else if( action ==
"threshOff" )
50 else if( action ==
"active" )
96 ingr::instGraphXML *parentGraph
104 virtual void device(
const std::string &dev );
134 virtual void fsmElName(
const std::string &en );
146 const std::string &
fsmKey()
const;
169 void loadConfig( mx::app::appConfigurator &config
191 const pcf::IndiProperty &ipRecv );
205 std::string msg =
"fsmNode::device attempt to change device name from " +
m_device +
" to " + dev;
206 msg +=
" in " +
name();
209 msg +=
" " + std::to_string( __LINE__ );
210 throw std::runtime_error( msg );
215 std::string msg =
"fsmNode::device attempt to set empty device name in " +
name();
218 msg +=
" " + std::to_string( __LINE__ );
219 throw std::runtime_error( msg );
237 std::string msg =
"fsmNode::fsmPropName attempt to change fsmPropName name from " +
m_fsmPropName +
" to " + pn;
238 msg +=
" in " +
name();
241 msg +=
" " + std::to_string( __LINE__ );
242 throw std::runtime_error( msg );
247 std::string msg =
"fsmNode::fsmPropName attempt to set propName after device already set " +
name();
250 msg +=
" " + std::to_string( __LINE__ );
251 throw std::runtime_error( msg );
256 std::string msg =
"fsmNode::fsmPropName attempt to set propName to empty " +
name();
259 msg +=
" " + std::to_string( __LINE__ );
260 throw std::runtime_error( msg );
275 std::string msg =
"fsmNode::fsmElName attempt to set elName to empty " +
name();
278 msg +=
" " + std::to_string( __LINE__ );
279 throw std::runtime_error( msg );
314 std::string msg =
"fsmNode::loadConfig: parent graph is null";
317 msg +=
" " + std::to_string( __LINE__ );
318 throw std::runtime_error( msg );
322 config.configUnused( type, mx::app::iniFile::makeKey(
name(),
"type" ) );
326 std::string msg =
"fsmNode::loadConfig: node type is not fsmNode";
329 msg +=
" " + std::to_string( __LINE__ );
330 throw std::runtime_error( msg );
340 config.configUnused( propName, mx::app::iniFile::makeKey(
name(),
"fsmPropName" ) );
343 std::string dev =
name();
344 config.configUnused( dev, mx::app::iniFile::makeKey(
name(),
"device" ) );
348 config.configUnused( elName, mx::app::iniFile::makeKey(
name(),
"fsmElName" ) );
352 config.configUnused( action, mx::app::iniFile::makeKey(
name(),
"fsmAction" ) );
357 std::string msg =
XIGN_EXCEPTION(
"fsmNode::loadConfig",
"fsmAction is unknown" );
358 throw std::runtime_error( msg );
362 config.configUnused(
targetStates, mx::app::iniFile::makeKey(
name(),
"targetStates" ) );
383 if( ipRecv.createUniqueKey() !=
m_fsmKey )
408 bool stateOnTarget =
false;
414 stateOnTarget =
true;
Implementation of an instGraph node interface for a MagAO-X Finite State Machine (FSM)
const std::string & device() const
Get the device name.
virtual int handleSetProperty(const pcf::IndiProperty &ipRecv)
INDI SetProperty callback.
const std::string & fsmPropName() const
Get the fsm property name.
const std::string & fsmElName() const
Get the fsm element name.
std::vector< stateCodeT > m_targetStates
const std::vector< stateCodeT > & targetStates() const
Get the target states.
fsmNodeActionT m_fsmAction
stateCodeT m_state
The numerical code of the current state.
std::string m_device
The INDI device name. Defaults to the node name set on construction.
bool m_stateOnTarget
Flag indicating if the current state matches any of the target states.
MagAOX::app::stateCodes::stateCodeT stateCodeT
std::string m_fsmKey
The unique INDI key, <device>.<fsmPropName>, for the FSM state INDI property.
std::string m_fsmPropName
The INDI property name for the FSM, normally "fsm".
std::string m_fsmElName
The INDI property element name for the FSM, normally "state".
std::string m_stateStr
The string name of the current state.
fsmNodeActionT fsmAction() const
Get the action.
void loadConfig(mx::app::appConfigurator &config)
Load this specific node's settings from an application configuration.
void loadConfigDerived(mx::app::appConfigurator &config)
Load this specific node's settings from an application configuration of a derived class.
const std::string & fsmKey() const
Get the FSM unique key.
fsmNode(const std::string &name, ingr::instGraphXML *parentGraph)
Constructor.
Implementation of basic instGraph node interface for MagAO-X.
void key(const std::string &nkey)
Add a key to the set.
ingr::instNode * m_node
The underlying instGraph node.
virtual void togglePutsOn()
Change the state of all inputs and all outputs to on.
int m_changes
Counter that can be incremented when changes are detected. Set to 0 when graph is updated.
ingr::instGraphXML * m_parentGraph
The parent instGraph that this node is a part of.
std::string name()
Get the name of this node.
virtual void togglePutsOff()
Change the state of all inputs and all outputs to off.
fsmNodeActionT fsmNodeActionTFromString(const std::string &action)
std::string fsmNodeActionT2String(fsmNodeActionT action)
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.
The base MagAO-X instGraph node header file.
#define XIGN_EXCEPTION(src, expl)