10#include <instGraph/instGraphXML.hpp>
13#include "../../libMagAOX/libMagAOX.hpp"
14#include "../../magaox_git_version.h"
135 config.add(
"graph.file",
143 "name of input graph drawio file, including extension, in the config directory" );
145 config.add(
"graph.outputPath",
153 "path to the output graph .drawio file" );
191 bool isNode = config.isSetUnused( mx::app::iniFile::makeKey(
sections[
i],
"type" ) );
199 _config.configUnused( type, mx::app::iniFile::makeKey(
sections[
i],
"type" ) );
205 if( type ==
"indiProp" )
212 catch(
const std::exception &
e )
214 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
217 throw std::runtime_error(
msg );
222 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"failed to allocate node" );
223 throw std::runtime_error(
msg );
230 catch(
const std::exception &
e )
232 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
235 throw std::runtime_error(
msg );
240 else if( type ==
"pwrOnOff" )
248 catch(
const std::exception &
e )
250 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
253 throw std::runtime_error(
msg );
258 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"failed to allocate node" );
259 throw std::runtime_error(
msg );
266 catch(
const std::exception &
e )
268 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
271 throw std::runtime_error(
msg );
276 else if( type ==
"fsm" )
284 catch(
const std::exception &
e )
286 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
289 throw std::runtime_error(
msg );
294 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"failed to allocate node" );
295 throw std::runtime_error(
msg );
302 catch(
const std::exception &
e )
304 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
307 throw std::runtime_error(
msg );
312 else if( type ==
"stdMotion" )
320 catch(
const std::exception &
e )
322 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
325 throw std::runtime_error(
msg );
330 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"failed to allocate node" );
331 throw std::runtime_error(
msg );
338 catch(
const std::exception &
e )
340 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
343 throw std::runtime_error(
msg );
348 else if( type ==
"static" )
356 catch(
const std::exception &
e )
358 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
361 throw std::runtime_error(
msg );
366 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"failed to allocate node" );
367 throw std::runtime_error(
msg );
374 catch(
const std::exception &
e )
376 std::string
msg =
XIGN_EXCEPTION(
"indiGraph::loadConfigImpl",
"exception caught" );
379 throw std::runtime_error(
msg );
391 catch(
const std::exception &
e )
393 std::string
msg =
e.what();
394 msg +=
"\ncaught at ";
397 throw std::runtime_error(
msg );
419 size_t dot = key.find(
'.' );
421 if(
dot == std::string::npos )
426 return key.substr( 0,
dot );
431 size_t dot = key.find(
'.' );
432 if(
dot == std::string::npos )
437 return key.substr(
dot + 1 );
444 for(
auto kit =
it->second->keys().begin();
kit !=
it->second->keys().end(); ++
kit )
465 pcf::IndiProperty *p =
new pcf::IndiProperty;
480 {
__FILE__,
__LINE__,
"failed to insert INDI property: " + p->createUniqueKey() } );
484 catch( std::exception &
e )
509 std::filesystem::remove(
m_graph.outputPath());
516 if(
igapp ==
nullptr )
526 std::cerr <<
ipRecv.createUniqueKey() <<
'\n';
533 std::cerr <<
it->second->name() <<
'\n';
545 catch( std::exception &
e )
The base-class for XWCTk applications.
void handleSetProperty(const pcf::IndiProperty &ipRecv)
Handler for the set INDI property request.
stateCodes::stateCodeT state()
Get the current state code.
int m_shutdown
Flag to signal it's time to shutdown. When not 0, the main loop exits.
std::pair< std::string, indiCallBack > callBackValueType
Value type of the indiCallBack map.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
std::string m_configDir
The path to configuration files for MagAOX.
std::pair< callBackIterator, bool > callBackInsertResult
Return type of insert on the indiCallBack map.
std::unordered_map< std::string, indiCallBack > m_indiSetCallBacks
Map to hold the SetProperty indiCallBacks for this App, with fast lookup by property name.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
std::vector< pcf::IndiProperty * > m_nodeProps
The node INDI properties to register for SetProperty.
ingr::instGraphXML m_graph
virtual int appStartup()
Startup function.
int igHandleSetProperty(const pcf::IndiProperty &ipRecv)
virtual void setupConfig()
std::multimap< std::string, xigNode * > m_nodeHandleSets
static int st_igHandleSetProperty(void *igapp, const pcf::IndiProperty &ipRecv)
virtual int appShutdown()
Shutdown the app.
virtual void loadConfig()
friend class xInstGraph_test::xInstGraph
virtual int appLogic()
Implementation of the FSM for xInstGraph.
~xInstGraph() noexcept
D'tor.
std::map< std::string, xigNode * > m_nodes
Implementation of an instGraph node interface for a MagAO-X Finite State Machine (FSM)
An instGraph node which tracks a specific INDI property and element of that property.
An instGraph node which is static, with status set at config time and not changing.
Implementation of basic instGraph node interface for MagAO-X.
The MagAO-X Instrument Graph fsmNode header file.
@ READY
The device is ready for operation, but is not operating.
The MagAO-X Instrument Graph indiPropNode header file.
const pcf::IndiProperty & ipRecv
std::string deviceFromKey(const std::string &key)
std::string nameFromKey(const std::string &key)
The MagAO-X Instrument Graph pwrOnOffNode header file.
The MagAO-X Instrument Graph staticNode header file.
The MagAO-X Instrument Graph stdMotionNode header file.
#define XIGN_EXCEPTION(src, expl)