cumbia-tango 1.x
C++ multi threaded library based on cumbia and the Tango control system
Public Member Functions | List of all members
CuTDbPropertyReader Class Reference

Read Tango device, attribute and class properties. More...

#include <cutdbpropertyreader.h>

Inheritance diagram for CuTDbPropertyReader:
Inheritance graph
[legend]

Public Member Functions

 CuTDbPropertyReader (const std::string &id, CumbiaTango *cumbia_t)
 The class constructor. More...
 
virtual ~CuTDbPropertyReader ()
 
void get (const std::vector< CuData > &in_data)
 Get a list of device, class or attribute properties from the Tango database. More...
 
void cancel ()
 CuTDbPropertyReader::cancel tries to unregister the activity and removes all listeners. More...
 
void addListener (CuDataListener *l)
 register a CuDataListener that will be notified when data is ready. More...
 
void removeListener (CuDataListener *l)
 CuTDbPropertyReader::removeListener removes the given listener. More...
 
void deleteLater ()
 CuTDbPropertyReader::deleteLater schedule object auto destruction. More...
 
void onProgress (int step, int total, const CuData &data)
 
void onResult (const CuData &data)
 
CuData getToken () const
 
void onResult (const std::vector< CuData > &datalist)
 

Detailed Description

Read Tango device, attribute and class properties.

CuTDbPropertyReader fetches properties from the Tango database and provides a notification through the CuThreadListener interface when data is available. Data is retrieved in a separate thread.

Object disposal
This must not be deleted directly. Auto deletion is possible if you call deleteLater. In this case, the object will auto delete itself either after onResult or immediately, if onResult has already been called.
Listener disposal
Do not delete the listener unless you've previously called either cancel or removeListener.
See also
CuTDbPropertyReader
get

Constructor & Destructor Documentation

◆ CuTDbPropertyReader()

CuTDbPropertyReader::CuTDbPropertyReader ( const std::string &  id,
CumbiaTango cumbia_t 
)

The class constructor.

Parameters
idany identifier as a std string
cumbia_tangoa reference to a CumbiaTango instance, necessary to configure the property reader activity with proper CuThreadsEventBridgeFactory_I and CuThreadFactoryImplI implementations.
See also
get
addListener

◆ ~CuTDbPropertyReader()

CuTDbPropertyReader::~CuTDbPropertyReader ( )
virtual

Member Function Documentation

◆ addListener()

void CuTDbPropertyReader::addListener ( CuDataListener *  l)

register a CuDataListener that will be notified when data is ready.

◆ cancel()

void CuTDbPropertyReader::cancel ( )

CuTDbPropertyReader::cancel tries to unregister the activity and removes all listeners.

Listeners can be deleted after cancel is called, since onUpdate will not be invoked after. Nonetheless, cancel is not enough to ensure this object can be safely deleted. If you intend to cancel and delete the CuTDbPropertyReader, call deleteLater after cancel.

◆ deleteLater()

void CuTDbPropertyReader::deleteLater ( )

CuTDbPropertyReader::deleteLater schedule object auto destruction.

If the result has already been delivered, the object is immediately deleted. This object will be deleted right after result delivery otherwise.

Warnings
  1. Do not delete the listener set with addListener without previously calling either removeListener or cancel.
  2. Do not directly delete a CuTDbPropertyReader unless you are really sure that onResult has been called.
See also
cancel

◆ get()

void CuTDbPropertyReader::get ( const std::vector< CuData > &  in_data)

Get a list of device, class or attribute properties from the Tango database.

Parameters
in_dataa list of CuData bundles defining the properties to fetch.

of the input data.

Every element of in_data describes the property you want to get.

properties

To get a device property you must put into the CuData bundle the following key/value pairs:

  • "device" --> "tango/device/name"
  • "name" --> "property_name"

properties

The three following key/values must be set:

  • "device" --> "tango/device/name"
  • "attribute" --> "attribute_name"
  • "name" --> "property_name"
Note
If no "name" is provided, all the device attribute properties and their values are retrieved.

properties.

CuData must be configured as follows:

  • "class" --> "class_name"
  • "name" --> "property_name"

Tutorial

There is a cumbia tutorial dedicated to getting properties from the Tango database: Writing an activity to read Tango device, attribute and class properties.

Example
This code snippet fetches some properties of different kind:
std::list<CuData> in_data;
// device property
CuData devpd("device", "test/device/1");
devpd["name"] = "description";
in_data.push_back(devpd);
// attribute property values from the "double_scalar" attribute
CuData apd("device", "test/device/2");
apd["attribute"] = "double_scalar";
apd["name"] = "values";
in_data.push_back(apd);
// class property
CuData cld("class", "TangoTest");
cld["name"] = "ProjectTitle";
in_data.push_back(cld);
// m_ct is a reference to a CumbiaTango object properly instantiated before.
CuTDbPropertyReader *pr = new CuTDbPropertyReader("getprop", m_ct);
pr->addListener(this); // this class implements CuDataListener
pr->get(in_data); // will receive results within the onUpdate method
Read Tango device, attribute and class properties.
Definition: cutdbpropertyreader.h:30
void get(const std::vector< CuData > &in_data)
Get a list of device, class or attribute properties from the Tango database.
Definition: cutdbpropertyreader.cpp:112
void addListener(CuDataListener *l)
register a CuDataListener that will be notified when data is ready.
Definition: cutdbpropertyreader.cpp:141
See also
addListener

◆ getToken()

CuData CuTDbPropertyReader::getToken ( ) const

◆ onProgress()

void CuTDbPropertyReader::onProgress ( int  step,
int  total,
const CuData &  data 
)

This is not used

◆ onResult() [1/2]

void CuTDbPropertyReader::onResult ( const CuData &  data)

◆ onResult() [2/2]

void CuTDbPropertyReader::onResult ( const std::vector< CuData > &  datalist)

◆ removeListener()

void CuTDbPropertyReader::removeListener ( CuDataListener *  l)

CuTDbPropertyReader::removeListener removes the given listener.

Parameters
la pointer to the listener to be removed

The documentation for this class was generated from the following files: