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

An instGraph node which tracks a specific INDI property and element of that property. More...

#include <indiPropNode.hpp>

Inheritance diagram for indiPropNode:
Inheritance graph
Collaboration diagram for indiPropNode:
Collaboration graph

Public Member Functions

 indiPropNode (const std::string &name, ingr::instGraphXML *parentGraph)
 Only c'tor. Must be constructed with node name and a parent graph.
 
void propKey (const std::string &pk)
 Set the unique key of the INDI property to track.
 
const std::string & propKey () const
 Get the unique key of the INDI property to track.
 
void propEl (const std::string &pe)
 Set the element of the INDI property to track.
 
const std::string & propEl () const
 Get the element of the INDI property to track.
 
void propValStr (const std::string &pv)
 Set the target value of the INDI element.
 
const std::string & propValStr () const
 Get the target value of the INDI element.
 
const double & propValNum () const
 Get the target value of the INDI element if it's a number.
 
const pcf::IndiElement::SwitchStateType & propValSw ()
 Get the target value of the INDI element if it's a switch.
 
const pcf::IndiProperty::Type & type () const
 Get the type of the INDI property being tracked.
 
const double & tol () const
 Get the tolerance used for numeric comparison.
 
const bool & state () const
 Get the current value of the comparison.
 
virtual int handleSetProperty (const pcf::IndiProperty &ipRecv)
 INDI SetProperty callback.
 
virtual void toggleOn ()
 Toggle all puts on.
 
virtual void toggleOff ()
 Toggle all puts off.
 
void loadConfig (mx::app::appConfigurator &config)
 Configure this node form an appConfigurator.
 
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.
 
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

virtual int firstSetProperty (const pcf::IndiProperty &ipRecv)
 On first call to handleSetProperty we find the property type and convert the target value.
 
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_propKey
 unique key, device.name, of the property tp track
 
std::string m_propEl
 the element of the property to track
 
std::string m_propValStr
 the target value of the element. This is always set.
 
double m_propValNum { std::numeric_limits<double>::lowest() }
 
pcf::IndiElement::SwitchStateType m_propValSw { pcf::IndiElement::SwitchStateType::UnknownSwitchState }
 
pcf::IndiProperty::Type m_type { pcf::IndiProperty::Unknown }
 The property type. Discovered introspectively on first call to handleSetProperty.
 
double m_tol { 1e-7 }
 The tolerance for floating point comparison. Default is 1e-7.
 
bool m_state { false }
 The current state of the comparison.
 
bool m_first { true }
 Flag indicating if it's the first call to handleSetProperty.
 
std::string m_onStr {"ON"}
 
std::string m_offStr {"OFF"}
 
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
 
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

An instGraph node which tracks a specific INDI property and element of that property.

When the element matches the target value all puts are turned on. All puts are off otherwise.

Definition at line 16 of file indiPropNode.hpp.

Member Typedef Documentation

◆ stateCodeT

Definition at line 71 of file fsmNode.hpp.

Constructor & Destructor Documentation

◆ indiPropNode()

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

Only c'tor. Must be constructed with node name and a parent graph.

Parameters
[in]parentGraphthe name of this node [in] the graph which this node belongs to

Definition at line 129 of file indiPropNode.hpp.

References xigNode::m_node, and xigNode::m_parentGraph.

Member Function Documentation

◆ device() [1/2]

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

Get the device name.

Returns
the current value of m_device

Definition at line 228 of file fsmNode.hpp.

References fsmNode::m_device.

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

◆ device() [2/2]

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

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(), fsmNode::m_device, fsmNode::m_fsmKey, fsmNode::m_fsmPropName, and xigNode::name().

Referenced by SCENARIO().

◆ firstSetProperty()

int indiPropNode::firstSetProperty ( const pcf::IndiProperty &  ipRecv)
inlineprotectedvirtual

On first call to handleSetProperty we find the property type and convert the target value.

Parameters
[in]ipRecvthe received INDI property

Definition at line 194 of file indiPropNode.hpp.

References m_propValNum, m_propValStr, m_propValSw, m_type, and XIGN_EXCEPTION.

Referenced by handleSetProperty().

◆ fsmAction() [1/2]

fsmNodeActionT fsmNode::fsmAction ( ) const
inherited

Get the action.

Returns
the current value of m_fsmAction

Definition at line 295 of file fsmNode.hpp.

References fsmNode::m_fsmAction.

Referenced by SCENARIO().

◆ fsmAction() [2/2]

void fsmNode::fsmAction ( fsmNodeActionT  act)
inherited

Set the action.

Definition at line 300 of file fsmNode.hpp.

References fsmNode::m_fsmAction.

◆ fsmElName() [1/2]

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

Get the fsm element name.

Returns
the current value of m_fsmElName

Definition at line 285 of file fsmNode.hpp.

References fsmNode::m_fsmElName.

Referenced by fsmNode::loadConfigDerived().

◆ fsmElName() [2/2]

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

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 fsmNode::m_fsmElName, and xigNode::name().

◆ fsmKey()

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

Get the FSM unique key.

Returns
the current value of m_fsmKey

Definition at line 290 of file fsmNode.hpp.

References fsmNode::m_fsmKey.

Referenced by SCENARIO().

◆ fsmPropName() [1/2]

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

Get the fsm property name.

Returns
the current value of m_fsmPropName

Definition at line 266 of file fsmNode.hpp.

References fsmNode::m_fsmPropName.

Referenced by fsmNode::loadConfigDerived().

◆ fsmPropName() [2/2]

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

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 fsmNode::m_device, fsmNode::m_fsmPropName, and xigNode::name().

◆ handleSetProperty() [1/2]

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

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, fsmNode::m_fsmAction, fsmNode::m_fsmElName, fsmNode::m_fsmKey, xigNode::m_node, xigNode::m_parentGraph, fsmNode::m_state, fsmNode::m_stateOnTarget, fsmNode::m_stateStr, fsmNode::m_targetStates, MagAOX::app::stateCodes::str2CodeFast(), threshOff, xigNode::togglePutsOff(), and xigNode::togglePutsOn().

◆ handleSetProperty() [2/2]

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

INDI SetProperty callback.

Parameters
[in]ipRecvthe received INDI property to handle

Reimplemented from fsmNode.

Definition at line 258 of file indiPropNode.hpp.

References firstSetProperty(), fsmNode::handleSetProperty(), xigNode::m_changes, m_first, xigNode::m_node, m_offStr, m_onStr, xigNode::m_parentGraph, m_propEl, m_propKey, m_propValNum, m_propValStr, m_propValSw, m_state, m_tol, m_type, toggleOff(), toggleOn(), and XIGN_EXCEPTION.

Referenced by SCENARIO().

◆ 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 indiPropNode::loadConfig ( mx::app::appConfigurator &  config)
inline

Configure this node form an appConfigurator.

Parameters
[in]configthe loaded configuration

Definition at line 382 of file indiPropNode.hpp.

References fsmNode::loadConfigDerived(), m_offStr, m_onStr, xigNode::m_parentGraph, m_propEl, m_propValStr, m_tol, xigNode::name(), propKey(), type(), and XIGN_EXCEPTION.

Referenced by SCENARIO().

◆ loadConfigDerived()

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

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 fsmNode::device(), fsmNode::fsmElName(), fsmNodeActionT2String(), fsmNodeActionTFromString(), fsmNode::fsmPropName(), fsmNode::m_fsmAction, xigNode::m_node, xigNode::m_parentGraph, fsmNode::m_targetStates, xigNode::name(), MagAOX::app::stateCodes::str2Code(), fsmNode::targetStates(), unknown, and XIGN_EXCEPTION.

Referenced by fsmNode::loadConfig(), and 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().

◆ propEl() [1/2]

const std::string & indiPropNode::propEl ( ) const

Get the element of the INDI property to track.

Returns
the value of m_propEl

Definition at line 154 of file indiPropNode.hpp.

References m_propEl.

◆ propEl() [2/2]

void indiPropNode::propEl ( const std::string &  pe)
inline

Set the element of the INDI property to track.

Parameters
[in]pe

Definition at line 149 of file indiPropNode.hpp.

References m_propEl.

Referenced by SCENARIO().

◆ propKey() [1/2]

const std::string & indiPropNode::propKey ( ) const

Get the unique key of the INDI property to track.

Returns
the value of m_propKey

Definition at line 144 of file indiPropNode.hpp.

References m_propKey.

Referenced by loadConfig().

◆ propKey() [2/2]

void indiPropNode::propKey ( const std::string &  pk)
inline

Set the unique key of the INDI property to track.

Parameters
[in]pk

Definition at line 137 of file indiPropNode.hpp.

References xigNode::key(), and m_propKey.

Referenced by SCENARIO().

◆ propValNum()

const double & indiPropNode::propValNum ( ) const

Get the target value of the INDI element if it's a number.

Returns
the value of m_propValNum

Definition at line 169 of file indiPropNode.hpp.

References m_propValNum.

Referenced by SCENARIO().

◆ propValStr() [1/2]

const std::string & indiPropNode::propValStr ( ) const

Get the target value of the INDI element.

Returns
the value of m_propValStr

Definition at line 164 of file indiPropNode.hpp.

References m_propValStr.

◆ propValStr() [2/2]

void indiPropNode::propValStr ( const std::string &  pv)
inline

Set the target value of the INDI element.

Always set in its string form and converted as needed

Parameters
[in]pv

Definition at line 159 of file indiPropNode.hpp.

References m_propValStr.

Referenced by SCENARIO().

◆ propValSw()

const pcf::IndiElement::SwitchStateType & indiPropNode::propValSw ( )

Get the target value of the INDI element if it's a switch.

Returns
the value of m_propValSw

Definition at line 174 of file indiPropNode.hpp.

References m_propValSw.

Referenced by SCENARIO().

◆ state()

const bool & indiPropNode::state ( ) const

Get the current value of the comparison.

Returns
the value of m_state

Definition at line 189 of file indiPropNode.hpp.

References m_state.

Referenced by SCENARIO().

◆ targetStates()

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

Get the target states.

Returns
the current value of m_targetStates

Definition at line 305 of file fsmNode.hpp.

References fsmNode::m_targetStates.

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

◆ toggleOff()

void indiPropNode::toggleOff ( )
inlinevirtual

Toggle all puts off.

Definition at line 377 of file indiPropNode.hpp.

References xigNode::togglePutsOff().

Referenced by handleSetProperty().

◆ toggleOn()

void indiPropNode::toggleOn ( )
inlinevirtual

Toggle all puts on.

Definition at line 372 of file indiPropNode.hpp.

References xigNode::togglePutsOn().

Referenced by handleSetProperty().

◆ 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 fsmNode::handleSetProperty(), 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 fsmNode::handleSetProperty(), toggleOn(), pwrOnOffNode::toggleOn(), and stdMotionNode::togglePutsOn().

◆ tol()

const double & indiPropNode::tol ( ) const

Get the tolerance used for numeric comparison.

Returns
the value of m_tol

Definition at line 184 of file indiPropNode.hpp.

References m_tol.

Referenced by SCENARIO().

◆ type()

const pcf::IndiProperty::Type & indiPropNode::type ( ) const

Get the type of the INDI property being tracked.

Returns
the value of m_type

Definition at line 179 of file indiPropNode.hpp.

References m_type.

Referenced by loadConfig(), and SCENARIO().

◆ updateGUI()

void fsmNode::updateGUI ( )
inlinevirtualinherited

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 fsmNode::handleSetProperty(), handleSetProperty(), and stdMotionNode::handleSetProperty().

◆ m_device

std::string fsmNode::m_device
protectedinherited

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

Definition at line 74 of file fsmNode.hpp.

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

◆ m_first

bool indiPropNode::m_first { true }
protected

Flag indicating if it's the first call to handleSetProperty.

Definition at line 41 of file indiPropNode.hpp.

Referenced by handleSetProperty().

◆ m_fsmAction

fsmNodeActionT fsmNode::m_fsmAction { fsmNodeActionT::passive }
protectedinherited

◆ m_fsmElName

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

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

Definition at line 76 of file fsmNode.hpp.

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

◆ m_fsmKey

std::string fsmNode::m_fsmKey
protectedinherited

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

Definition at line 78 of file fsmNode.hpp.

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

◆ m_fsmPropName

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

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

Definition at line 75 of file fsmNode.hpp.

Referenced by fsmNode::device(), fsmNode::fsmPropName(), and fsmNode::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_offStr

std::string indiPropNode::m_offStr {"OFF"}
protected

Definition at line 44 of file indiPropNode.hpp.

Referenced by handleSetProperty(), and loadConfig().

◆ m_onStr

std::string indiPropNode::m_onStr {"ON"}
protected

Definition at line 43 of file indiPropNode.hpp.

Referenced by handleSetProperty(), and loadConfig().

◆ m_parentGraph

◆ m_propEl

std::string indiPropNode::m_propEl
protected

the element of the property to track

Definition at line 21 of file indiPropNode.hpp.

Referenced by handleSetProperty(), loadConfig(), propEl(), and propEl().

◆ m_propKey

std::string indiPropNode::m_propKey
protected

unique key, device.name, of the property tp track

Definition at line 20 of file indiPropNode.hpp.

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

◆ m_propValNum

double indiPropNode::m_propValNum { std::numeric_limits<double>::lowest() }
protected

the numeric target value, set from m_propValStr if the property is a number.

Definition at line 25 of file indiPropNode.hpp.

Referenced by firstSetProperty(), handleSetProperty(), and propValNum().

◆ m_propValStr

std::string indiPropNode::m_propValStr
protected

the target value of the element. This is always set.

Definition at line 23 of file indiPropNode.hpp.

Referenced by firstSetProperty(), handleSetProperty(), loadConfig(), propValStr(), and propValStr().

◆ m_propValSw

pcf::IndiElement::SwitchStateType indiPropNode::m_propValSw { pcf::IndiElement::SwitchStateType::UnknownSwitchState }
protected

The switch target value, set from m_propValStr if the property is a switch. In this case m_propValStr can have values On or Off. The comparison is made insensitive to case (ON and off are valid).

Definition at line 32 of file indiPropNode.hpp.

Referenced by firstSetProperty(), handleSetProperty(), and propValSw().

◆ m_state

bool indiPropNode::m_state { false }
protected

The current state of the comparison.

Definition at line 39 of file indiPropNode.hpp.

Referenced by handleSetProperty(), and state().

◆ m_stateOnTarget

bool fsmNode::m_stateOnTarget { false }
protectedinherited

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

Definition at line 87 of file fsmNode.hpp.

Referenced by fsmNode::handleSetProperty().

◆ m_stateStr

std::string fsmNode::m_stateStr
protectedinherited

The string name of the current state.

Definition at line 85 of file fsmNode.hpp.

Referenced by fsmNode::handleSetProperty().

◆ m_targetStates

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

◆ m_tol

double indiPropNode::m_tol { 1e-7 }
protected

The tolerance for floating point comparison. Default is 1e-7.

Definition at line 37 of file indiPropNode.hpp.

Referenced by handleSetProperty(), loadConfig(), and tol().

◆ m_type

pcf::IndiProperty::Type indiPropNode::m_type { pcf::IndiProperty::Unknown }
protected

The property type. Discovered introspectively on first call to handleSetProperty.

Definition at line 35 of file indiPropNode.hpp.

Referenced by firstSetProperty(), handleSetProperty(), and type().


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