7 #ifndef stateRuleEngine_hpp
8 #define stateRuleEngine_hpp
11 #include "../../libMagAOX/libMagAOX.hpp"
12 #include "../../magaox_git_version.h"
98 const pcf::IndiProperty &
ipRecv
146 pcf::IndiProperty::Idle, pcf::IndiProperty::AnyOfMany,
nullptr) < 0)
152 pcf::IndiElement elem = pcf::IndiElement(
it->first, pcf::IndiElement::Off);
161 pcf::IndiProperty::Idle, pcf::IndiProperty::AnyOfMany,
nullptr) < 0)
167 pcf::IndiElement elem = pcf::IndiElement(
it->first, pcf::IndiElement::Off);
176 pcf::IndiProperty::Idle, pcf::IndiProperty::AnyOfMany,
nullptr) < 0)
182 pcf::IndiElement elem = pcf::IndiElement(
it->first, pcf::IndiElement::Off);
191 pcf::IndiProperty::Idle, pcf::IndiProperty::AnyOfMany,
nullptr) < 0)
197 pcf::IndiElement elem = pcf::IndiElement(
it->first, pcf::IndiElement::Off);
204 if(
it->second ==
nullptr)
continue;
206 std::string devName, propName;
211 log<software_error>({__FILE__, __LINE__, 0, rv,
"error parsing INDI key: " +
it->first});
231 bool val =
it->second->value();
233 pcf::IndiElement::SwitchStateType onoff = pcf::IndiElement::Off;
234 if(val) onoff = pcf::IndiElement::On;
254 catch(
const std::exception & e)
277 const pcf::IndiProperty &
ipRecv
289 std::string key =
ipRecv.createUniqueKey();
The base-class for MagAO-X applications.
std::string m_configName
The name of the configuration file (minus .conf).
stateCodes::stateCodeT state()
Get the current state code.
int registerIndiPropertyNew(pcf::IndiProperty &prop, int(*)(void *, const pcf::IndiProperty &))
Register an INDI property which is exposed for others to request a New Property for.
void updateSwitchIfChanged(pcf::IndiProperty &p, const std::string &el, const pcf::IndiElement::SwitchStateType &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI switch element value if it has changed.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
int registerIndiPropertySet(pcf::IndiProperty &prop, const std::string &devName, const std::string &propName, int(*)(void *, const pcf::IndiProperty &))
Register an INDI property which is monitored for updates from others.
The MagAO-X stateRuleEngine.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
friend class stateRuleEngine_test
pcf::IndiProperty m_indiP_warning
virtual int appStartup()
Startup function.
pcf::IndiProperty m_indiP_caution
virtual void loadConfig()
~stateRuleEngine() noexcept
D'tor, declared and defined for noexcept.
virtual int appShutdown()
Shutdown the app.
virtual void setupConfig()
pcf::IndiProperty m_indiP_info
static int st_newCallBack_ruleProp(void *app, const pcf::IndiProperty &ipRecv)
The static callback function to be registered for rule properties.
pcf::IndiProperty m_indiP_alert
stateRuleEngine()
Default c'tor.
int newCallBack_ruleProp(const pcf::IndiProperty &ipRecv)
Callback to process a NEW preset position request.
virtual int appLogic()
Implementation of the FSM for stateRuleEngine.
@ READY
The device is ready for operation, but is not operating.
Configuration of rules for the MagAO-X stateRuleEngine.
void loadRuleConfig(indiRuleMaps &maps, mx::app::appConfigurator &config)
Load the rule and properties maps for a rule engine from a configuration file.
@ caution
Caution – make sure you know what you're doing.
@ warning
Warning – something is probably wrong, you should check.
@ alert
Alert – something is definitely wrong, you should take action.
@ info
For information only.
int parseIndiKey(std::string &devName, std::string &propName, const std::string &key)
Parse an INDI key into the device and property names.
const pcf::IndiProperty & ipRecv
Software CRITICAL log entry.
Structure to provide management of the rule and property maps.