7#ifndef stdMotionNode_hpp
8#define stdMotionNode_hpp
75 ingr::instGraphXML *parentGraph );
81 virtual void device(
const std::string &dev );
127 mx::app::appConfigurator &config );
154 "stdMotionNode::presetPrefix: attempt to change preset prefix from " +
m_presetPrefix +
" to " + pp;
157 msg +=
" " + std::to_string( __LINE__ );
158 throw std::runtime_error( msg );
310 bool nothingIsOn =
true;
311 for(
auto &&it : ipRecv.getElements() )
313 if( it.second.getSwitchState() == pcf::IndiElement::On )
407 ingr::instIOPut *pptr;
413 pptr =
m_node->inputs().begin()->second;
421 pptr->enabled(
true );
422 pptr->state( ingr::putState::on );
424 ingr::putState inst = pptr->state();
425 if( inst != ingr::putState::on )
427 inst = ingr::putState::waiting;
435 pptr =
m_node->output( s );
444 pptr->enabled(
true );
449 pptr->state( ingr::putState::off );
453 pptr->enabled(
false );
460 ingr::instIOPut *pptr;
466 pptr =
m_node->outputs().begin()->second;
474 pptr->enabled(
true );
475 pptr->state( ingr::putState::on );
482 pptr =
m_node->input( s );
491 pptr->enabled(
true );
492 pptr->state( ingr::putState::on );
496 pptr->state( ingr::putState::off );
500 pptr->enabled(
false );
545 for(
auto &&iput :
m_node->inputs() )
547 if(
m_alwaysOn.count( iput.second->name() ) > 0 )
553 iput.second->state( ingr::putState::off );
556 for(
auto &&oput :
m_node->outputs() )
558 if(
m_alwaysOn.count( oput.second->name() ) > 0 )
563 oput.second->state( ingr::putState::off );
565 if(
m_noAutoOn.count( oput.second->name() ) == 1 )
567 oput.second->enabled(
false );
576 std::string msg =
XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"parent graph is null" );
577 throw std::runtime_error( msg );
581 config.configUnused( type, mx::app::iniFile::makeKey(
name(),
"type" ) );
583 if( type !=
"stdMotion" )
585 std::string msg =
XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"node type is not stdMotion" );
586 throw std::runtime_error( msg );
589 std::string dev =
name();
590 config.configUnused( dev, mx::app::iniFile::makeKey(
name(),
"device" ) );
592 std::string prePrefix =
"preset";
593 config.configUnused( prePrefix, mx::app::iniFile::makeKey(
name(),
"presetPrefix" ) );
595 std::string preDir =
"output";
596 config.configUnused( preDir, mx::app::iniFile::makeKey(
name(),
"presetDir" ) );
598 if( preDir ==
"input" )
602 else if( preDir ==
"output" )
608 std::string msg =
XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"invalid presetDir (must be input or output)" );
609 throw std::runtime_error( msg );
612 std::vector<std::string> prePutName( {
"out" } );
613 config.configUnused( prePutName, mx::app::iniFile::makeKey(
name(),
"presetPutName" ) );
614 if( prePutName.size() == 0 )
616 std::string msg =
XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"presetPutName can't be empty" );
617 throw std::runtime_error( msg );
620 std::vector<std::string> alwaysOn;
621 config.configUnused( alwaysOn, mx::app::iniFile::makeKey(
name(),
"alwaysOn" ) );
624 for(
auto &ao : alwaysOn )
629 catch(
const std::exception &e )
631 std::string msg =
XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"exception from insert in m_alwaysOn" );
634 throw std::runtime_error( msg );
637 std::vector<std::string> noAutoOn;
638 config.configUnused( noAutoOn, mx::app::iniFile::makeKey(
name(),
"noAutoOn" ) );
641 for(
auto &ao : noAutoOn )
646 catch(
const std::exception &e )
648 std::string msg =
XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"exception from insert in m_noAutoOn" );
651 throw std::runtime_error( msg );
654 std::string trackReqKey;
655 config.configUnused( trackReqKey, mx::app::iniFile::makeKey(
name(),
"trackingReqKey" ) );
657 std::string trackReqEl;
658 config.configUnused( trackReqEl, mx::app::iniFile::makeKey(
name(),
"trackingReqElement" ) );
661 if( ( trackReqKey ==
"" && trackReqEl !=
"" ) || ( trackReqKey !=
"" && trackReqEl ==
"" ) )
664 "trackingReqKey and trackingReqElement must both be provided" );
665 throw std::runtime_error( msg );
668 std::string trackKey;
669 config.configUnused( trackKey, mx::app::iniFile::makeKey(
name(),
"trackerKey" ) );
672 config.configUnused( trackEl, mx::app::iniFile::makeKey(
name(),
"trackerElement" ) );
675 if( ( trackKey ==
"" && trackEl !=
"" ) || ( trackKey !=
"" && trackEl ==
"" ) )
678 XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"trackingKey and trackingElement must both be provided" );
679 throw std::runtime_error( msg );
683 if( ( trackKey ==
"" && trackReqKey !=
"" ) || ( trackKey !=
"" && trackReqKey ==
"" ) )
686 XIGN_EXCEPTION(
"stdMotionNode::loadConfig",
"trackingReqKey and trackerKey must both be provided" );
687 throw std::runtime_error( msg );
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.
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.
std::string m_trackerKey
The INDI key (device.property) for the switch denoting that this stage is tracking.
virtual void togglePutsOn()
Change the state of all inputs and all outputs to on.
std::string m_trackingReqElement
The element of the INDI property denoted by m_trackingReqKey to follow.
std::set< std::string > m_noAutoOn
Contains the names of any puts which are not automatically turned on if they are off.
const std::string & device() const
Get the device name.
const std::string & presetPrefix()
std::string m_curVal
The current value of the preset property. Corresponds to the element name of the selected preset.
const std::string & trackingReqElement()
const std::string & trackerElement()
bool m_trackingReq
Flag indicating if the stage should be (true) or should not be (false, default) tracking.
bool m_tracking
Flag indicating whether or not the stage is currently tracking (default false).
ingr::ioDir m_presetDir
This sets whether the multi-put selector is on the input or the output (default)
std::string m_presetKey
The INDI key (device.property) for the presets. This is, say, fwpupil.filterName. It is set automatic...
std::set< std::string > m_alwaysOn
Contains the names of any puts which are always on if any are on.
const std::string & trackingReqKey()
std::vector< std::string > m_presetPutName
std::string m_curLabel
The current value of the put label.
std::string m_trackingReqKey
The INDI key (device.property) for the switch denoting that this stage should be or should not be tra...
virtual int handleSetProperty(const pcf::IndiProperty &ipRecv)
INDI SetProperty callback.
void loadConfig(mx::app::appConfigurator &config)
std::string m_trackerElement
The element of the INDI property denoted by m_trackerKey to follow.
const std::string & curLabel()
Get the current label text.
stdMotionNode(const std::string &name, ingr::instGraphXML *parentGraph)
Only c'tor. Must be constructed with node name and a parent graph.
const std::vector< std::string > & presetPutName()
const std::string & trackerKey()
std::string m_presetPrefix
The prefix for preset naes. Usually either "preset" or "filter", to which "Name" is appended.
virtual void togglePutsOff()
Change the state of all inputs and all outputs to off.
const ingr::ioDir & presetDir()
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.
The MagAO-X Instrument Graph fsmNode header file.
@ OPERATING
The device is operating, other than homing.
@ READY
The device is ready for operation, but is not operating.
#define XIGN_EXCEPTION(src, expl)