9 #ifndef acronameUsbHub_hpp
10 #define acronameUsbHub_hpp
13 #include "../../libMagAOX/libMagAOX.hpp"
14 #include "../../magaox_git_version.h"
16 #include "BrainStem2/BrainStem-all.h"
145 config.add(
"device.serialNumber",
"",
"device.serialNumber", argType::Required,
"device",
"serialNumber",
false,
"uint32",
"The identifying serial number of the hub.");
219 sys.getModel(&model);
220 std::string modelName = aDefs_GetModelName(model);
223 sys.getVersion(&version);
224 char versionStr[256];
225 aVersion_ParseString(version, versionStr,
sizeof(versionStr));
228 sys.getSerialNumber(&serial);
230 log<text_log>(
"Connected to " + modelName +
" #" + std::to_string(serial) +
" w/fimrware version " + versionStr,
logPrio::LOG_INFO);
239 if(!
m_hub.isConnected() )
303 aErr err =
m_hub.usb.getPortState(outletNum, &
state);
307 if(err == aErrTimeout)
311 if(err == aErrConnection)
313 return log<
software_error,-1>({__FILE__, __LINE__,
"loss of connection detected when enabling port"});
332 aErr err =
m_hub.usb.setPortEnable(outletNum);
336 if(err == aErrTimeout)
340 if(err == aErrConnection)
342 return log<
software_error,-1>({__FILE__, __LINE__,
"loss of connection detected when enabling port"});
352 aErr err =
m_hub.usb.setPortDisable(outletNum);
356 if(err == aErrTimeout)
360 if(err == aErrConnection)
362 return log<
software_error,-1>({__FILE__, __LINE__,
"loss of connection detected when disabling port"});
Internal class to manage setuid privilege escalation with RAII.
The base-class for MagAO-X applications.
void updateIfChanged(pcf::IndiProperty &p, const std::string &el, const T &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI property element value if it has changed.
stateCodes::stateCodeT state()
Get the current state code.
int stateLogged()
Updates and returns the value of m_stateLogged. Will be 0 on first call after a state change,...
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
std::mutex m_indiMutex
Mutex for locking INDI communications.
virtual int onPowerOff()
Implementation of the on-power-off FSM logic.
int updateOutletState(int outletNum)
Get the state of the outlet from the device.
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
uint32_t m_serialNumber
The Acroname device serial number.
virtual int appLogic()
Implementation of the FSM for the Siglent SDG.
int turnOutletOn(int outletNum)
Turn an outlet on.
virtual int appStartup()
Startup functions.
bool m_connected
Whether or not the hub is currently connected.
int turnOutletOff(int outletNum)
Turn an outlet off.
virtual int whilePowerOff()
Implementation of the while-powered-off FSM.
virtual int appShutdown()
Do any needed shutdown tasks. Currently nothing in this app.
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
~acronameUsbHub() noexcept
Destructor.
acronameUsbHub()
Default c'tor.
aUSBHub3p m_hub
BrainStem library handle.
@ READY
The device is ready for operation, but is not operating.
@ CONNECTED
The application has connected to the device or service.
@ NOTCONNECTED
The application is not connected to the device or service.
@ POWERON
The device power is on.
constexpr static logPrioT LOG_CRITICAL
The process can not continue and will shut down (fatal)
constexpr static logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
constexpr static logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
A generic outlet controller.
int updateINDI()
Update the INDI properties for this device controller.
std::unordered_map< std::string, channelSpec > m_channels
The map of channel specifications, which can be accessed by their names.
int loadConfig(mx::app::appConfigurator &config)
Load the [channel] sections from an application configurator.
int setupConfig(mx::app::appConfigurator &config)
Setup an application configurator for an outletController.
virtual int updateOutletStates()
Get the states of all outlets from the device.
int setNumberOfOutlets(int numOuts)
Sets the number of outlets. This should be called by the derived class constructor.
std::vector< int > m_outletStates
The current states of each outlet. These MUST be updated by derived classes in the overridden updated...
A simple text log, a string-type log.