cumbia-tango 1.x
C++ multi threaded library based on cumbia and the Tango control system
|
Low level class to read tango attributes and commands with output arguments. More...
#include <cutreader.h>
Public Types | |
enum | RefreshMode { PolledRefresh = 0x01 , ChangeEventRefresh =0x02 , ArchiveEventRefresh =0x04 , PeriodicEventRefresh =0x08 , Manual =0x10 } |
The reader refresh mode. More... | |
Public Types inherited from CuTangoActionI | |
enum | Type { ActionUnknown = -1 , Reader = 0 , Writer , ReaderConfig , WriterConfig , TaDb } |
list of types of actions More... | |
Public Member Functions | |
CuTReader (const TSource &src, CumbiaTango *ct, const CuData &op=CuData(), const CuData &tag=CuData()) | |
~CuTReader () | |
void | onProgress (int step, int total, const CuData &data) |
progress notification callback More... | |
void | onResult (const CuData &data) |
receives on the main thread the result of a task executed in background. More... | |
void | onResult (const std::vector< CuData > &datalist) |
CuData | getToken () const |
returns the CuData storing the token that identifies this action More... | |
TSource | getSource () const |
CuTangoActionI::Type | getType () const |
returns the type of CuTangoActionI implemented More... | |
void | sendData (const CuData &data) |
Send data with parameters to configure the reader. More... | |
void | getData (CuData &inout) const |
Get parameters from the reader. More... | |
void | setRefreshMode (RefreshMode rm, int period=-1) |
set or change the reader's refresh mode More... | |
std::string | refreshModeStr () const |
RefreshMode | refreshMode () const |
bool | isEventRefresh (RefreshMode rm) const |
returns true if the parameter is an event driven RefreshMode, false otherwise. More... | |
int | period () const |
void | setPeriod (int millis) |
void | setOptions (const CuData &options) |
CuTReader::setOptions sets the options on the reader. More... | |
void | setTag (const CuData &tag) |
void | start () |
the method where activities are created and registered More... | |
void | stop () |
the method where activities are unregistered from Cumbia More... | |
void | addDataListener (CuDataListener *l) |
insert a CuDataListener to the list of listeners of data updates More... | |
void | removeDataListener (CuDataListener *l) |
remove a CuDataListener from the list of listeners of data updates More... | |
size_t | dataListenersCount () |
return the number of registered data listeners More... | |
Public Member Functions inherited from CuTangoActionI | |
virtual | ~CuTangoActionI () |
virtual destructor, to make compilers happy More... | |
virtual TSource | getSource () const =0 |
return a TSource object that stores information about the Tango source More... | |
virtual Type | getType () const =0 |
returns the type of CuTangoActionI implemented More... | |
virtual void | addDataListener (CuDataListener *l)=0 |
insert a CuDataListener to the list of listeners of data updates More... | |
virtual void | removeDataListener (CuDataListener *l)=0 |
remove a CuDataListener from the list of listeners of data updates More... | |
virtual size_t | dataListenersCount ()=0 |
return the number of registered data listeners More... | |
virtual void | start ()=0 |
the method where activities are created and registered More... | |
virtual void | stop ()=0 |
the method where activities are unregistered from Cumbia More... | |
virtual void | sendData (const CuData &data)=0 |
subclasses will implement the necessary code to set data on themselves or to the activities More... | |
virtual void | getData (CuData &d_inout) const =0 |
subclasses will implement the necessary code to analyze the request stored in the input argument and fill it in with output data More... | |
Low level class to read tango attributes and commands with output arguments.
This class implements the CuTangoActionI interface, which in turn implements CuThreadListener.
Programmers of graphical interfaces should employ cumbia-tango-controls CuTControlsReader higher level class to create and communicate with CuTReader.
The reader refresh mode.
Each refresh mode reflects the way a tango attribute can be read. Commands are always polled with a given period (default: 1000ms). The preferred read mode for attributes is by events (ChangeEventRefresh). If they are not available, the second choice mode is PolledRefresh.
Manual mode starts (or switches to) a polling activity that is immediately paused. A specific argument must be specified to sendData to trigger a manual reading.
Enumerator | |
---|---|
PolledRefresh | |
ChangeEventRefresh | |
ArchiveEventRefresh | |
PeriodicEventRefresh | |
Manual |
CuTReader::CuTReader | ( | const TSource & | src, |
CumbiaTango * | ct, | ||
const CuData & | op = CuData() , |
||
const CuData & | tag = CuData() |
||
) |
References setOptions().
CuTReader::~CuTReader | ( | ) |
|
virtual |
insert a CuDataListener to the list of listeners of data updates
l | a CuDataListener that receives notifications when data is ready, through CuDataListener::onUpdate |
Implements CuTangoActionI.
|
virtual |
return the number of registered data listeners
Implements CuTangoActionI.
|
virtual |
Get parameters from the reader.
d_inout | a reference to a CuData bundle containing the parameter names as keys. getData will associate the values to the keys. Unrecognized keys are ignored. |
Implements CuTangoActionI.
References refreshModeStr().
|
virtual |
returns the tango source (TSource)
Implements CuTangoActionI.
CuData CuTReader::getToken | ( | ) | const |
returns the CuData storing the token that identifies this action
Referenced by sendData().
|
virtual |
returns the type of CuTangoActionI implemented
Implements CuTangoActionI.
References CuTangoActionI::Reader.
bool CuTReader::isEventRefresh | ( | CuTReader::RefreshMode | rm | ) | const |
returns true if the parameter is an event driven RefreshMode, false otherwise.
rm | a value picked from CuTReader::RefreshMode enumeration |
References ArchiveEventRefresh, ChangeEventRefresh, and PeriodicEventRefresh.
Referenced by sendData(), and setRefreshMode().
void CuTReader::onProgress | ( | int | step, |
int | total, | ||
const CuData & | data | ||
) |
progress notification callback
step | the completed steps in the background |
total | the total number of steps |
data | CuData with data from the background activity |
The current implementation does nothing
void CuTReader::onResult | ( | const CuData & | data | ) |
receives on the main thread the result of a task executed in background.
See md_lib_cudata_for_tango
If the error flag is set by the CuEventActivity because subscribe_event failed, the poller is started and the error is not notified to the listener(s)
void CuTReader::onResult | ( | const std::vector< CuData > & | datalist | ) |
int CuTReader::period | ( | ) | const |
Referenced by sendData(), and setRefreshMode().
CuTReader::RefreshMode CuTReader::refreshMode | ( | ) | const |
string CuTReader::refreshModeStr | ( | ) | const |
References ArchiveEventRefresh, ChangeEventRefresh, Manual, PeriodicEventRefresh, and PolledRefresh.
Referenced by getData().
|
virtual |
remove a CuDataListener from the list of listeners of data updates
l | a CuDataListener that will be removed from the list of listeners |
Implements CuTangoActionI.
References stop().
|
virtual |
Send data with parameters to configure the reader.
data | a CuData bundle with the settings to apply to the reader. |
Implements CuTangoActionI.
References CuPollingService::CuPollingServiceType, CuPollingService::getPoller(), getToken(), isEventRefresh(), Manual, CuPoller::period(), period(), PolledRefresh, and setRefreshMode().
void CuTReader::setOptions | ( | const CuData & | options | ) |
CuTReader::setOptions sets the options on the reader.
options | CuData key/value bundle |
References Manual, PolledRefresh, setPeriod(), and setRefreshMode().
Referenced by CuTReader().
void CuTReader::setPeriod | ( | int | millis | ) |
Referenced by setOptions().
void CuTReader::setRefreshMode | ( | CuTReader::RefreshMode | rm, |
int | period = -1 |
||
) |
set or change the reader's refresh mode
If the reading activity hasn't been started yet, the mode is saved for later. If an activity is already running and the requested mode is different, the current activity is unregistered and a new one is started.
rm | a value chosen from CuTReader::RefreshMode. |
References CuPollingService::actionRegistered(), CuPollingService::CuPollingServiceType, isEventRefresh(), Manual, period(), and PolledRefresh.
Referenced by sendData(), and setOptions().
void CuTReader::setTag | ( | const CuData & | tag | ) |
|
virtual |
the method where activities are created and registered
This is the place where activities are created and registered to Cumbia through the method Cumbia::registerActivity.
Implements CuTangoActionI.
References ChangeEventRefresh.
|
virtual |
the method where activities are unregistered from Cumbia
This is the place where activities are unregistered from Cumbia by the Cumbia::unregisterActivity method
Implements CuTangoActionI.
Referenced by removeDataListener().