A generic outlet controller. More...
#include <outletController.hpp>
Classes | |
struct | channelSpec |
Structure containing the specification of one channel. More... | |
Public Member Functions | |
int | setupConfig (mx::app::appConfigurator &config) |
Setup an application configurator for an outletController. More... | |
int | loadConfig (mx::app::appConfigurator &config) |
Load the [channel] sections from an application configurator. More... | |
int | setNumberOfOutlets (int numOuts) |
Sets the number of outlets. This should be called by the derived class constructor. More... | |
int | outletState (int outletNum) |
Get the currently stored outlet state, without updating from device. More... | |
virtual int | updateOutletState (int outletNum)=0 |
Get the state of the outlet from the device. More... | |
virtual int | updateOutletStates () |
Get the states of all outlets from the device. More... | |
virtual int | turnOutletOn (int outletNum)=0 |
Turn an outlet on. More... | |
virtual int | turnOutletOff (int outletNum)=0 |
Turn an outlet off. More... | |
size_t | numChannels () |
Get the number of channels. More... | |
std::vector< size_t > | channelOutlets (const std::string &channel) |
Get the vector of outlet indices for a channel. More... | |
std::vector< size_t > | channelOnOrder (const std::string &channel) |
Get the vector of outlet on orders for a channel. More... | |
std::vector< size_t > | channelOffOrder (const std::string &channel) |
Get the vector of outlet off orders for a channel. More... | |
std::vector< unsigned > | channelOnDelays (const std::string &channel) |
Get the vector of outlet on delays for a channel. More... | |
std::vector< unsigned > | channelOffDelays (const std::string &channel) |
Get the vector of outlet off delays for a channel. More... | |
int | channelState (const std::string &channel) |
Get the state of a channel. More... | |
int | turnChannelOn (const std::string &channel) |
Turn a channel on. More... | |
int | turnChannelOff (const std::string &channel) |
Turn a channel off. More... | |
Public Attributes | |
bool | m_firstOne {false} |
Flag is true if the first outlet is numbered 1, otherwise assumes starting at 0. More... | |
std::vector< int > | m_outletStates |
The current states of each outlet. These MUST be updated by derived classes in the overridden updatedOutletState. More... | |
pcf::IndiProperty | m_indiP_outletStates |
Indi Property to show individual outlet states. More... | |
std::unordered_map< std::string, channelSpec > | m_channels |
The map of channel specifications, which can be accessed by their names. More... | |
pcf::IndiProperty | m_indiP_chOutlets |
An INDI property which publishes the outlets associated with each channel. Useful for GUIs, etc. More... | |
pcf::IndiProperty | m_indiP_chOnDelays |
An INDI property which publishes the total on delay for each channel. Useful for GUIs, etc. More... | |
pcf::IndiProperty | m_indiP_chOffDelays |
An INDI property which publishes the total off delay for each channel. Useful for GUIs, etc. More... | |
Private Member Functions | |
derivedT & | derived () |
INDI Setup | |
int | newCallBack_channels (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. More... | |
int | setupINDI () |
Setup the INDI properties for this device controller. More... | |
int | updateINDI () |
Update the INDI properties for this device controller. More... | |
static int | st_newCallBack_channels (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for the channel properties. More... | |
A generic outlet controller.
Controls a set of outlets on a device, such as A/C power outlets or digital outputs. The outlets are organized into channels, which could be made up of multiple outlets.
derivedT must be a MagAOXApp, and additionally it must implement the functions
and optionally
Other requirements:
setNumberOfOutlets
in the derived class constructorderivedT | specifies a MagAOXApp parent base class which is accessed with a static_cast (downcast) to perform various methods. |
Definition at line 68 of file outletController.hpp.
struct MagAOX::app::dev::outletController::channelSpec |
Structure containing the specification of one channel.
A channel may include more than one outlet, may specify the order in which outlets are turned on and/or off, and may specify a delay between turning outlets on and/or off.
Definition at line 81 of file outletController.hpp.
std::vector< unsigned > MagAOX::app::dev::outletController< derivedT >::channelOffDelays | ( | const std::string & | channel | ) |
Get the vector of outlet off delays for a channel.
Mainly used for testing.
[in] | channel | the name of the channel |
Definition at line 472 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
std::vector< size_t > MagAOX::app::dev::outletController< derivedT >::channelOffOrder | ( | const std::string & | channel | ) |
Get the vector of outlet off orders for a channel.
Mainly used for testing.
[in] | channel | the name of the channel |
Definition at line 460 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
std::vector< unsigned > MagAOX::app::dev::outletController< derivedT >::channelOnDelays | ( | const std::string & | channel | ) |
Get the vector of outlet on delays for a channel.
Mainly used for testing.
[in] | channel | the name of the channel |
Definition at line 466 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
std::vector< size_t > MagAOX::app::dev::outletController< derivedT >::channelOnOrder | ( | const std::string & | channel | ) |
Get the vector of outlet on orders for a channel.
Mainly used for testing.
[in] | channel | the name of the channel |
Definition at line 454 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
std::vector< size_t > MagAOX::app::dev::outletController< derivedT >::channelOutlets | ( | const std::string & | channel | ) |
Get the vector of outlet indices for a channel.
Mainly used for testing.
[in] | channel | the name of the channel |
Definition at line 448 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
int MagAOX::app::dev::outletController< derivedT >::channelState | ( | const std::string & | channel | ) |
Get the state of a channel.
[in] | channel | the name of the channel |
Definition at line 478 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
|
inlineprivate |
Definition at line 294 of file outletController.hpp.
int MagAOX::app::dev::outletController< derivedT >::loadConfig | ( | mx::app::appConfigurator & | config | ) |
Load the [channel] sections from an application configurator.
Any "unused" section from the config parser is analyzed to determine if it is a channel specification. If it contains the outlet
or outlets
keyword, then it is considered a channel. outlet
and outlets
are equivalent, and specify the one or more device outlets included in this channel (i.e. this may be a vector value entry).
This function then looks for onOrder
and offOrder
keywords, which specify the order outlets are turned on or off by their indices in the vector specified by the outlet
/outlets
keyword (i.e not the outlet numbers).
Next it looks for onDelays
and offDelays
, which specify the delays between outlet operations in milliseconds. The first entry is always ignored, then the second entry specifies the delay between the first and second outlet operation, etc.
An example config file section is:
[sue] #this channel will be named sue outlets=4,5 #this channel uses outlets 4 and 5 onOrder=1,0 #outlet 5 will be turned on first offOrder=0,1 #Outlet 4 will be turned off first onDelays=0,150 #a 150 msec delay between outlet turn on offDelays=0,345 #a 345 msec delay between outlet turn off
[in] | config | an application configuration from which to load values |
Definition at line 309 of file outletController.hpp.
Referenced by MagAOX::app::acronameUsbHub::loadConfig(), MagAOX::app::trippLitePDU::loadConfig(), MagAOX::app::xt1121DCDU::loadConfig(), and outletController_tests::SCENARIO().
int MagAOX::app::dev::outletController< derivedT >::newCallBack_channels | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 642 of file outletController.hpp.
size_t MagAOX::app::dev::outletController< derivedT >::numChannels |
Get the number of channels.
Definition at line 442 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
int MagAOX::app::dev::outletController< derivedT >::outletState | ( | int | outletNum | ) |
Get the currently stored outlet state, without updating from device.
Definition at line 424 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
int MagAOX::app::dev::outletController< derivedT >::setNumberOfOutlets | ( | int | numOuts | ) |
Sets the number of outlets. This should be called by the derived class constructor.
[in] | numOuts | the number of outlets to allocate |
Definition at line 417 of file outletController.hpp.
int MagAOX::app::dev::outletController< derivedT >::setupConfig | ( | mx::app::appConfigurator & | config | ) |
Setup an application configurator for an outletController.
This is currently a no-op
[in] | config | an application configuration to setup |
Definition at line 301 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO(), MagAOX::app::acronameUsbHub::setupConfig(), MagAOX::app::trippLitePDU::setupConfig(), and MagAOX::app::xt1121DCDU::setupConfig().
int MagAOX::app::dev::outletController< derivedT >::setupINDI |
Setup the INDI properties for this device controller.
This should be called in the appStartup
function of the derived MagAOXApp.
Definition at line 687 of file outletController.hpp.
|
static |
The static callback function to be registered for the channel properties.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 634 of file outletController.hpp.
int MagAOX::app::dev::outletController< derivedT >::turnChannelOff | ( | const std::string & | channel | ) |
Turn a channel off.
This implements the outlet order and delay logic.
[in] | channel | the name of the channel to turn on |
Definition at line 564 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
int MagAOX::app::dev::outletController< derivedT >::turnChannelOn | ( | const std::string & | channel | ) |
Turn a channel on.
This implements the outlet order and delay logic.
[in] | channel | the name of the channel to turn on |
Definition at line 491 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().
|
pure virtual |
Turn an outlet off.
This will be implemented in derived classes to turn an outlet off.
[in] | outletNum | the outlet number to turn off |
Implemented in outletController_tests::outletControllerTest, MagAOX::app::xt1121DCDU, MagAOX::app::trippLitePDU, and MagAOX::app::acronameUsbHub.
|
pure virtual |
Turn an outlet on.
This will be implemented in derived classes to turn an outlet on.
[in] | outletNum | the outlet number to turn on |
Implemented in outletController_tests::outletControllerTest, MagAOX::app::xt1121DCDU, MagAOX::app::trippLitePDU, and MagAOX::app::acronameUsbHub.
int MagAOX::app::dev::outletController< derivedT >::updateINDI |
Update the INDI properties for this device controller.
You should call this after updating the outlet states. It is not called automatically.
Definition at line 804 of file outletController.hpp.
Referenced by MagAOX::app::acronameUsbHub::appLogic(), MagAOX::app::xt1121DCDU::appLogic(), MagAOX::app::acronameUsbHub::onPowerOff(), and MagAOX::app::trippLitePDU::updateOutletStates().
|
pure virtual |
Get the state of the outlet from the device.
This will be implemented in derived classes to update the outlet state.
[in] | outletNum | the outlet number to update |
Implemented in outletController_tests::outletControllerTest, MagAOX::app::xt1121DCDU, MagAOX::app::trippLitePDU, and MagAOX::app::acronameUsbHub.
|
virtual |
Get the states of all outlets from the device.
The default implementation for-loops through each outlet, calling updateOutletState. Can be re-implemented in derived classes to update the outlet states.
Reimplemented in MagAOX::app::trippLitePDU.
Definition at line 430 of file outletController.hpp.
Referenced by MagAOX::app::acronameUsbHub::appLogic().
std::unordered_map<std::string, channelSpec> MagAOX::app::dev::outletController< derivedT >::m_channels |
The map of channel specifications, which can be accessed by their names.
Definition at line 95 of file outletController.hpp.
bool MagAOX::app::dev::outletController< derivedT >::m_firstOne {false} |
Flag is true if the first outlet is numbered 1, otherwise assumes starting at 0.
Definition at line 70 of file outletController.hpp.
pcf::IndiProperty MagAOX::app::dev::outletController< derivedT >::m_indiP_chOffDelays |
An INDI property which publishes the total off delay for each channel. Useful for GUIs, etc.
Definition at line 104 of file outletController.hpp.
pcf::IndiProperty MagAOX::app::dev::outletController< derivedT >::m_indiP_chOnDelays |
An INDI property which publishes the total on delay for each channel. Useful for GUIs, etc.
Definition at line 101 of file outletController.hpp.
pcf::IndiProperty MagAOX::app::dev::outletController< derivedT >::m_indiP_chOutlets |
An INDI property which publishes the outlets associated with each channel. Useful for GUIs, etc.
Definition at line 98 of file outletController.hpp.
pcf::IndiProperty MagAOX::app::dev::outletController< derivedT >::m_indiP_outletStates |
Indi Property to show individual outlet states.
Definition at line 74 of file outletController.hpp.
std::vector<int> MagAOX::app::dev::outletController< derivedT >::m_outletStates |
The current states of each outlet. These MUST be updated by derived classes in the overridden updatedOutletState.
Definition at line 72 of file outletController.hpp.
Referenced by outletController_tests::SCENARIO().