API
 
Loading...
Searching...
No Matches
fsmNode Class Reference

Implementation of an instGraph node interface for a MagAO-X Finite State Machine (FSM) More...

#include <fsmNode.hpp>

Inheritance diagram for fsmNode:
Inheritance graph
Collaboration diagram for fsmNode:
Collaboration graph

Public Member Functions

 fsmNode (const std::string &name, ingr::instGraphXML *parentGraph)
 Constructor.
 
virtual void device (const std::string &dev)
 Set the device name.
 
const std::string & device () const
 Get the device name.
 
virtual void fsmPropName (const std::string &pn)
 Set the fsm property name.
 
const std::string & fsmPropName () const
 Get the fsm property name.
 
virtual void fsmElName (const std::string &en)
 Set the fsm element name.
 
const std::string & fsmElName () const
 Get the fsm element name.
 
const std::string & fsmKey () const
 Get the FSM unique key.
 
fsmNodeActionT fsmAction () const
 Get the action.
 
void fsmAction (fsmNodeActionT act)
 Set the action.
 
const std::vector< stateCodeT > & targetStates () const
 Get the target states.
 
void loadConfig (mx::app::appConfigurator &config)
 Load this specific node's settings from an application configuration.
 
virtual int handleSetProperty (const pcf::IndiProperty &ipRecv)
 INDI SetProperty callback.
 
virtual int handleSetProperty (bool &actionTaken, const pcf::IndiProperty &ipRecv)
 INDI SetProperty callback with indication if action was taken.
 
virtual void updateGUI ()
 
std::string name ()
 Get the name of this node.
 
const std::set< std::string > & keys ()
 Get the set holding the INDI keys for this node.
 
void key (const std::string &nkey)
 Add a key to the set.
 
ingr::instNode * node ()
 Get the pointer to the underlying node.
 
virtual void togglePutsOn ()
 Change the state of all inputs and all outputs to on.
 
virtual void togglePutsOff ()
 Change the state of all inputs and all outputs to off.
 

Protected Member Functions

void loadConfigDerived (mx::app::appConfigurator &config)
 Load this specific node's settings from an application configuration of a derived class.
 

Protected Attributes

std::string m_device
 The INDI device name. Defaults to the node name set on construction.
 
std::string m_fsmPropName { "fsm" }
 The INDI property name for the FSM, normally "fsm".
 
std::string m_fsmElName { "state" }
 The INDI property element name for the FSM, normally "state".
 
std::string m_fsmKey
 The unique INDI key, <device>.<fsmPropName>, for the FSM state INDI property.
 
fsmNodeActionT m_fsmAction { fsmNodeActionT::passive }
 
std::vector< stateCodeTm_targetStates
 
stateCodeT m_state { -999 }
 The numerical code of the current state.
 
std::string m_stateStr
 The string name of the current state.
 
bool m_stateOnTarget { false }
 Flag indicating if the current state matches any of the target states.
 
std::set< std::string > m_keys
 The INDI keys (device.property) which this node subscribes to.
 
ingr::instGraphXML * m_parentGraph { nullptr }
 The parent instGraph that this node is a part of.
 
ingr::instNode * m_node { nullptr }
 The underlying instGraph node.
 
int m_changes { 0 }
 Counter that can be incremented when changes are detected. Set to 0 when graph is updated.
 

Private Types

typedef MagAOX::app::stateCodes::stateCodeT stateCodeT
 

Detailed Description

Implementation of an instGraph node interface for a MagAO-X Finite State Machine (FSM)

This class is interraces to a standard FSM. It tracks the FSM state INDI property and keeps its internal state updated.

Whether it impacts ioput status depends on the action specified.

Definition at line 68 of file fsmNode.hpp.

Member Typedef Documentation

◆ stateCodeT

Definition at line 71 of file fsmNode.hpp.

Constructor & Destructor Documentation

◆ fsmNode()

fsmNode::fsmNode ( const std::string &  name,
ingr::instGraphXML *  parentGraph 
)
inline

Constructor.

Default c'tor is deleted in base classs. Must supply both node name and a parentGraph with a node with the same name in it.

Parameters
[in]namethe name of the node
[in]parentGraphthe parent instGraph

Definition at line 197 of file fsmNode.hpp.

Member Function Documentation

◆ device() [1/2]

const std::string & fsmNode::device ( ) const
inline

Get the device name.

Returns
the current value of m_device

Definition at line 228 of file fsmNode.hpp.

References m_device.

Referenced by stdMotionNode::device(), and loadConfigDerived().

◆ device() [2/2]

void fsmNode::device ( const std::string &  dev)
inlinevirtual

Set the device name.

Derived classes may implement this to add extra logic. The device name defaults to the node name on construction.

Parameters
[in]devthe new device name

Reimplemented in stdMotionNode, and stdMotionNode.

Definition at line 201 of file fsmNode.hpp.

References xigNode::key(), m_device, m_fsmKey, m_fsmPropName, and xigNode::name().

Referenced by SCENARIO().

◆ fsmAction() [1/2]

fsmNodeActionT fsmNode::fsmAction ( ) const

Get the action.

Returns
the current value of m_fsmAction

Definition at line 295 of file fsmNode.hpp.

References m_fsmAction.

Referenced by SCENARIO().

◆ fsmAction() [2/2]

void fsmNode::fsmAction ( fsmNodeActionT  act)

Set the action.

Definition at line 300 of file fsmNode.hpp.

References m_fsmAction.

◆ fsmElName() [1/2]

const std::string & fsmNode::fsmElName ( ) const
inline

Get the fsm element name.

Returns
the current value of m_fsmElName

Definition at line 285 of file fsmNode.hpp.

References m_fsmElName.

Referenced by loadConfigDerived().

◆ fsmElName() [2/2]

void fsmNode::fsmElName ( const std::string &  en)
inlinevirtual

Set the fsm element name.

Derived classes may implement this to add extra logic. The fsm element name defaults to "state"

This can be called at any time

Parameters
[in]enthe new element name

Definition at line 271 of file fsmNode.hpp.

References m_fsmElName, and xigNode::name().

◆ fsmKey()

const std::string & fsmNode::fsmKey ( ) const

Get the FSM unique key.

Returns
the current value of m_fsmKey

Definition at line 290 of file fsmNode.hpp.

References m_fsmKey.

Referenced by SCENARIO().

◆ fsmPropName() [1/2]

const std::string & fsmNode::fsmPropName ( ) const
inline

Get the fsm property name.

Returns
the current value of m_fsmPropName

Definition at line 266 of file fsmNode.hpp.

References m_fsmPropName.

Referenced by loadConfigDerived().

◆ fsmPropName() [2/2]

void fsmNode::fsmPropName ( const std::string &  pn)
inlinevirtual

Set the fsm property name.

Derived classes may implement this to add extra logic. The fsm property name defaults to "fsm"

This can only be called before device is set

Parameters
[in]pnthe new property name

Definition at line 233 of file fsmNode.hpp.

References m_device, m_fsmPropName, and xigNode::name().

◆ handleSetProperty() [1/2]

int fsmNode::handleSetProperty ( bool &  actionTaken,
const pcf::IndiProperty &  ipRecv 
)
inlinevirtual

INDI SetProperty callback with indication if action was taken.

The possible actions are determined by m_fsmAction. If the action was taken then the caller should return without further processing.

Parameters
ipRecv< [out] indicates if action taken (true). [in] the received INDI property to handle

Definition at line 381 of file fsmNode.hpp.

References active, xigNode::m_changes, m_fsmAction, m_fsmElName, m_fsmKey, xigNode::m_node, xigNode::m_parentGraph, m_state, m_stateOnTarget, m_stateStr, m_targetStates, MagAOX::app::stateCodes::str2CodeFast(), threshOff, xigNode::togglePutsOff(), and xigNode::togglePutsOn().

◆ handleSetProperty() [2/2]

int fsmNode::handleSetProperty ( const pcf::IndiProperty &  ipRecv)
inlinevirtual

INDI SetProperty callback.

Parameters
[in]ipRecvthe received INDI property to handle

Implements xigNode.

Reimplemented in indiPropNode, and stdMotionNode.

Definition at line 375 of file fsmNode.hpp.

References handleSetProperty().

Referenced by handleSetProperty(), indiPropNode::handleSetProperty(), and stdMotionNode::handleSetProperty().

◆ key()

void xigNode::key ( const std::string &  nkey)
inlineinherited

◆ keys()

const std::set< std::string > & xigNode::keys ( )
inlineinherited

Get the set holding the INDI keys for this node.

Returns
a const reference to m_keys

Definition at line 111 of file xigNode.hpp.

References xigNode::m_keys.

Referenced by SCENARIO().

◆ loadConfig()

void fsmNode::loadConfig ( mx::app::appConfigurator &  config)
inline

Load this specific node's settings from an application configuration.

Verifies that the named node is an fsmNode.

Exceptions
std::runtime_errorif m_parentGraph is nullptr or the config is not for an fsmNode.
Parameters
[in]configthe application configurator loaded with this node's options

Definition at line 310 of file fsmNode.hpp.

References loadConfigDerived(), xigNode::m_parentGraph, and xigNode::name().

Referenced by SCENARIO().

◆ loadConfigDerived()

void fsmNode::loadConfigDerived ( mx::app::appConfigurator &  config)
inlineprotected

Load this specific node's settings from an application configuration of a derived class.

Does not cerifies that the named node is an fsmNode.

Parameters
[in]configthe application configurator loaded with this node's options

Definition at line 336 of file fsmNode.hpp.

References device(), fsmElName(), fsmNodeActionT2String(), fsmNodeActionTFromString(), fsmPropName(), m_fsmAction, xigNode::m_node, xigNode::m_parentGraph, m_targetStates, xigNode::name(), MagAOX::app::stateCodes::str2Code(), targetStates(), unknown, and XIGN_EXCEPTION.

Referenced by loadConfig(), and indiPropNode::loadConfig().

◆ name()

◆ node()

ingr::instNode * xigNode::node ( )
inlineinherited

Get the pointer to the underlying node.

Returns
the node pointer, which can not be nullptr after construction

Definition at line 121 of file xigNode.hpp.

References xigNode::m_node.

Referenced by SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), TEST_CASE(), and TEST_CASE().

◆ targetStates()

const std::vector< fsmNode::stateCodeT > & fsmNode::targetStates ( ) const

Get the target states.

Returns
the current value of m_targetStates

Definition at line 305 of file fsmNode.hpp.

References m_targetStates.

Referenced by loadConfigDerived(), and SCENARIO().

◆ togglePutsOff()

void xigNode::togglePutsOff ( )
inlinevirtualinherited

Change the state of all inputs and all outputs to off.

Reimplemented in staticNode, and stdMotionNode.

Definition at line 141 of file xigNode.hpp.

References xigNode::m_node.

Referenced by handleSetProperty(), indiPropNode::toggleOff(), and pwrOnOffNode::toggleOff().

◆ togglePutsOn()

void xigNode::togglePutsOn ( )
inlinevirtualinherited

Change the state of all inputs and all outputs to on.

Reimplemented in staticNode, and stdMotionNode.

Definition at line 126 of file xigNode.hpp.

References xigNode::m_node.

Referenced by handleSetProperty(), indiPropNode::toggleOn(), pwrOnOffNode::toggleOn(), and stdMotionNode::togglePutsOn().

◆ updateGUI()

void fsmNode::updateGUI ( )
inlinevirtual

Definition at line 456 of file fsmNode.hpp.

Member Data Documentation

◆ m_changes

int xigNode::m_changes { 0 }
protectedinherited

Counter that can be incremented when changes are detected. Set to 0 when graph is updated.

Definition at line 39 of file xigNode.hpp.

Referenced by handleSetProperty(), indiPropNode::handleSetProperty(), and stdMotionNode::handleSetProperty().

◆ m_device

std::string fsmNode::m_device
protected

The INDI device name. Defaults to the node name set on construction.

Definition at line 74 of file fsmNode.hpp.

Referenced by device(), device(), stdMotionNode::device(), fsmPropName(), and stdMotionNode::presetPrefix().

◆ m_fsmAction

fsmNodeActionT fsmNode::m_fsmAction { fsmNodeActionT::passive }
protected

Definition at line 80 of file fsmNode.hpp.

Referenced by fsmAction(), fsmAction(), handleSetProperty(), and loadConfigDerived().

◆ m_fsmElName

std::string fsmNode::m_fsmElName { "state" }
protected

The INDI property element name for the FSM, normally "state".

Definition at line 76 of file fsmNode.hpp.

Referenced by fsmElName(), fsmElName(), and handleSetProperty().

◆ m_fsmKey

std::string fsmNode::m_fsmKey
protected

The unique INDI key, <device>.<fsmPropName>, for the FSM state INDI property.

Definition at line 78 of file fsmNode.hpp.

Referenced by device(), fsmKey(), and handleSetProperty().

◆ m_fsmPropName

std::string fsmNode::m_fsmPropName { "fsm" }
protected

The INDI property name for the FSM, normally "fsm".

Definition at line 75 of file fsmNode.hpp.

Referenced by device(), fsmPropName(), and fsmPropName().

◆ m_keys

std::set<std::string> xigNode::m_keys
protectedinherited

The INDI keys (device.property) which this node subscribes to.

Definition at line 33 of file xigNode.hpp.

Referenced by xigNode::key(), and xigNode::keys().

◆ m_node

◆ m_parentGraph

◆ m_state

stateCodeT fsmNode::m_state { -999 }
protected

The numerical code of the current state.

Definition at line 84 of file fsmNode.hpp.

Referenced by handleSetProperty(), stdMotionNode::handleSetProperty(), and stdMotionNode::togglePutsOn().

◆ m_stateOnTarget

bool fsmNode::m_stateOnTarget { false }
protected

Flag indicating if the current state matches any of the target states.

Definition at line 87 of file fsmNode.hpp.

Referenced by handleSetProperty().

◆ m_stateStr

std::string fsmNode::m_stateStr
protected

The string name of the current state.

Definition at line 85 of file fsmNode.hpp.

Referenced by handleSetProperty().

◆ m_targetStates

std::vector<stateCodeT> fsmNode::m_targetStates
protected

Definition at line 82 of file fsmNode.hpp.

Referenced by handleSetProperty(), loadConfigDerived(), and targetStates().


The documentation for this class was generated from the following file: