cumbia-tango 1.x
C++ multi threaded library based on cumbia and the Tango control system
|
an activity to periodically read from Tango. Implements CuContinuousActivity More...
#include <cupollingactivity.h>
Public Types | |
enum | Type { CuPollingActivityType = CuActivity::UserAType + 3 } |
defines the Type of the activity, returned by getType More... | |
Public Member Functions | |
CuPollingActivity (const TSource &tsrc, CuDeviceFactory_I *df, const CuData &options, const CuData &tag, int dataupdpo, int interval) | |
the class constructor that sets up a Tango polling activity More... | |
~CuPollingActivity () | |
the class destructor More... | |
void | setArgins (const CuVariant &argins) |
set the input arguments if the poller is used to "read" Tango commands and they require argins More... | |
size_t | actionsCount () const |
size_t | srcCount () const |
void | setSlowDownRate (const std::map< int, int > &sr_millis) |
set a custom slow down rate to decrease polling period after consecutive read failures. More... | |
const std::map< int, int > & | slowDownRate () const |
returns the currently employed slow down rate policy in case of read errors More... | |
void | decreasePolling () |
int | successfulExecCnt () const |
CuPollingActivity::successfulExecCnt count the number of succesful executions. More... | |
int | consecutiveErrCnt () const |
CuPollingActivity::consecutiveErrCnt count the consecutive errors during execution. More... | |
bool | matches (const CuData &token) const |
returns true if the passed token's device activity and period values matche this activity token's device and activity and period values. More... | |
void | event (CuActivityEvent *e) |
Receive events from the main thread to the CuActivity thread. More... | |
int | getType () const |
returns the type of the polling activity More... | |
int | repeat () const |
returns the polling period, in milliseconds More... | |
Protected Member Functions | |
void | init () |
the implementation of the CuActivity::init hook More... | |
void | execute () |
the implementation of the CuActivity::execute hook More... | |
void | onExit () |
the implementation of the CuActivity::onExit hook More... | |
an activity to periodically read from Tango. Implements CuContinuousActivity
Implementing CuActivity, the work is done in the background by the three methods
They are called from a separate thread. In cumbia-tango, threads are grouped by device.
Apart from the three execution hooks listed above, some other methods have been written to comply with the CuActivityInterface:
CuADeleteOnExit is left to true in order to let the activity be deleted by CuThread after onExit.
This combination of the flags guarantees the availability of the CuPollingActivity when CuTReader::stop is called (activity will be either executing the polling loop or suspended) and lets CuTReader not worry about the activity deletion.
CuPollingActivity::CuPollingActivity | ( | const TSource & | tsrc, |
CuDeviceFactory_I * | df, | ||
const CuData & | options, | ||
const CuData & | tag, | ||
int | dataupdpo, | ||
int | interval | ||
) |
the class constructor that sets up a Tango polling activity
token | a CuData that will describe this activity |
df | a pointer to a CuDeviceFactoryService that is used by init and onExit to create/obtain and later get rid of a Tango device, respectively |
argins | input arguments that can optionally be passed to Tango commands as argins |
CuPollingActivity::~CuPollingActivity | ( | ) |
the class destructor
deletes the internal data
size_t CuPollingActivity::actionsCount | ( | ) | const |
int CuPollingActivity::consecutiveErrCnt | ( | ) | const |
CuPollingActivity::consecutiveErrCnt count the consecutive errors during execution.
void CuPollingActivity::decreasePolling | ( | ) |
Referenced by execute().
void CuPollingActivity::event | ( | CuActivityEvent * | e | ) |
Receive events from the main thread to the CuActivity thread.
e | the event. Do not delete e after use. Cumbia will delete it after this method invocation. |
References CuAddPollActionEvent::AddPollAction, CuArgsChangeEvent::ArgsChangeEvent, and CuRemovePollActionEvent::RemovePollAction.
|
protected |
the implementation of the CuActivity::execute hook
This is repeatedly called in the CuActivity's thread of execution, according to the period chosen for the reader.
If the reader's source is a command, the first time execute is run CuTangoWorld::get_command_info is called, so that the data type and format of the command output argument is detected.
Either command_inout (through CuTangoWorld::cmd_inout) or read_attribute (CuTangoWorld::read_att) are then invoked. They interpret the result and place it in a CuData that is finally delivered to the main thread by means of publishResult.
References CuTangoWorld::cmd_inout(), decreasePolling(), CmdData::din, CuTangoWorld::get_command_info(), TSource::getArgs(), CmdData::getCmdInfoRef(), CuTangoWorld::getLastMessage(), TSource::getName(), TSource::getPoint(), CmdData::is_empty, CuTangoWorld::read_atts(), and CuTangoWorld::toDeviceData().
int CuPollingActivity::getType | ( | ) | const |
returns the type of the polling activity
References CuPollingActivityType.
|
protected |
the implementation of the CuActivity::init hook
This is called in the CuActivity's thread of execution.
References CuTThread::CuTThreadType.
bool CuPollingActivity::matches | ( | const CuData & | token | ) | const |
returns true if the passed token's device activity and period values matche this activity token's device and activity and period values.
token | a CuData containg key/value pairs of another activity's token |
Two CuPollingActivity match if they refer to the same device and have the same period.
|
protected |
the implementation of the CuActivity::onExit hook
This is called in the CuActivity's thread of execution.
See also CuActivity::onExit
int CuPollingActivity::repeat | ( | ) | const |
returns the polling period, in milliseconds
void CuPollingActivity::setArgins | ( | const CuVariant & | argins | ) |
void CuPollingActivity::setSlowDownRate | ( | const std::map< int, int > & | sr_millis | ) |
set a custom slow down rate to decrease polling period after consecutive read failures.
The default slow down rate policy decreases the read timer to:
The default polling period is restored after a successful reading
a | map defining how to decrease the polling period after read failures |
behaves as described in the list above if we deal with a default polling period of one second.
const std::map< int, int > & CuPollingActivity::slowDownRate | ( | ) | const |
returns the currently employed slow down rate policy in case of read errors
Refer to setSlowDownRate for further details
size_t CuPollingActivity::srcCount | ( | ) | const |
int CuPollingActivity::successfulExecCnt | ( | ) | const |
CuPollingActivity::successfulExecCnt count the number of succesful executions.