cumbia-qtcontrols 1.x
Qt widgets on top of the cumbia C++ library
Public Member Functions | List of all members
CuContext Class Reference

CuLinkControl stores a small set of objects to help create readers and writers. More...

#include <cucontext.h>

Public Member Functions

 CuContext (Cumbia *cumbia, const CuControlsReaderFactoryI &r_factory)
 
 CuContext (Cumbia *cumbia, const CuControlsWriterFactoryI &w_factory)
 
 CuContext (CumbiaPool *cumbia_pool, const CuControlsFactoryPool &fpool)
 
virtual ~CuContext ()
 
bool isAuto () const
 
CuControlsReaderAreplace_reader (const std::string &s, CuDataListener *datal)
 
CuControlsWriterAreplace_writer (const std::string &s, CuDataListener *datal)
 
CuControlsReaderAadd_reader (const std::string &s, CuDataListener *datal)
 
CuControlsWriterAadd_writer (const std::string &s, CuDataListener *datal)
 
CuControlsPropertyReaderA * get_property_reader (const std::string &s, CuDataListener *datal)
 
void disposeReader (const std::string &src=std::string())
 
void disposeWriter (const std::string &src=std::string())
 
void setOptions (const CuData &options)
 
void sendData (const CuData &data)
 Send options bundle to the link, if active, and save them locally. More...
 
void sendData (const QList< CuData > &data)
 
void getData (CuData &d_inout)
 Send to the link a bundle with input arguments (keys) and get back the same bundle with values, if applicable. More...
 
void getData (QList< CuData > &in_datalist)
 Get data from multiple readers (writers). More...
 
CuData options () const
 Get the options currently set on the context. More...
 
CuControlsReaderAgetReader () const
 
CuControlsWriterAgetWriter () const
 
CuControlsReaderAfindReader (const std::string &srcnam)
 
CuControlsWriterAfindWriter (const std::string &targetnam)
 
CuControlsReaderFactoryIgetReaderFactoryI () const
 returns a pointer to the CuControlsReaderFactoryI or NULL if the context is not a reader context More...
 
CuControlsWriterFactoryIgetWriterFactoryI () const
 returns a pointer to the CuControlsWriterFactoryI or NULL if the context is not a writer context More...
 
CuControlsFactoryPool getControlsFactoryPool () const
 returns a copy of the CuControlsFactoryPool, which will be valid if the context is configured with a CumbiaPool object. More...
 
CuLinkStatsgetLinkStats () const
 
QList< CuControlsReaderA * > readers () const
 
QList< CuControlsWriterA * > writers () const
 
Cumbia * cumbia () const
 
CumbiaPool * cumbiaPool () const
 

Detailed Description

CuLinkControl stores a small set of objects to help create readers and writers.

This can be considered a helper class for private management of Cumbia and reader/writer factories within reader or writer classes.

Usage
CuLinkControl can be created
  • passing specific Cumbia and reader (writer) factory instances;
  • passing CumbiaPool and CuControlsFactoryPool objects.
When make_reader is called, either the specific Cumbia and reader factory are used to create a reader or implementations of Cumbia and reader factory are picked from the pools provided. If CuData is passed to make_reader (or make_writer), it is used to configure the options of the underlying engine. CuData key/value set is specific to the engine used.
Options
The setOptions method can be used to configure how the readers and writers created by CuContext are set up. setOptions accepts a CuData bundle with settings organised in key/value pairs.
Relevant key/value pairs
  • no-properties [bool, default: false]. If true, skip attribute configuration.
  • fetch_props [std::vector<std::string>, default: empty] list of attribute properties to fetch from the database during configuration. The no-properties key must be left to false (default).

Constructor & Destructor Documentation

◆ CuContext() [1/3]

CuContext::CuContext ( Cumbia *  cumbia,
const CuControlsReaderFactoryI r_factory 
)

◆ CuContext() [2/3]

CuContext::CuContext ( Cumbia *  cumbia,
const CuControlsWriterFactoryI w_factory 
)

◆ CuContext() [3/3]

CuContext::CuContext ( CumbiaPool *  cumbia_pool,
const CuControlsFactoryPool fpool 
)

◆ ~CuContext()

CuContext::~CuContext ( )
virtual

References disposeReader(), and disposeWriter().

Member Function Documentation

◆ add_reader()

CuControlsReaderA * CuContext::add_reader ( const std::string &  s,
CuDataListener *  datal 
)

References disposeReader().

◆ add_writer()

CuControlsWriterA * CuContext::add_writer ( const std::string &  s,
CuDataListener *  datal 
)

◆ cumbia()

Cumbia * CuContext::cumbia ( ) const

Referenced by CuContext().

◆ cumbiaPool()

CumbiaPool * CuContext::cumbiaPool ( ) const

◆ disposeReader()

void CuContext::disposeReader ( const std::string &  src = std::string())

◆ disposeWriter()

void CuContext::disposeWriter ( const std::string &  src = std::string())

◆ findReader()

CuControlsReaderA * CuContext::findReader ( const std::string &  srcnam)

References CuControlsReaderA::source().

Referenced by getData(), and sendData().

◆ findWriter()

CuControlsWriterA * CuContext::findWriter ( const std::string &  targetnam)

References CuControlsWriterA::target().

Referenced by getData(), and sendData().

◆ get_property_reader()

CuControlsPropertyReaderA * CuContext::get_property_reader ( const std::string &  s,
CuDataListener *  datal 
)

◆ getControlsFactoryPool()

CuControlsFactoryPool CuContext::getControlsFactoryPool ( ) const

returns a copy of the CuControlsFactoryPool, which will be valid if the context is configured with a CumbiaPool object.

Returns
a copy of the CuControlsFactoryPool used by the pool to create readers or writers, if the CuContext is configured with the CumbiaPool/CuControlsFactoryPool pair.

◆ getData() [1/2]

void CuContext::getData ( CuData &  d_inout)

Send to the link a bundle with input arguments (keys) and get back the same bundle with values, if applicable.

Parameters
d_inouta CuData bundle with input arguments for the CuControlsReaderA/CuControlsWriter in use.
See also
setOptions
getData(QList<CuData> &in_datalist)
Note
How CuControlsReaderA::sendData deals with data is up to the CuControlsReaderA specific implementation. The same goes for CuControlsWriterA. See CuTReader::getData/CuTWritergetData for further details and a list of supported key/values in the CuData bundle for the Tango control system.
If the context contains more readers (writers), use the getData(QList<CuData> &in_datalist) version of the method.

◆ getData() [2/2]

void CuContext::getData ( QList< CuData > &  in_datalist)

Get data from multiple readers (writers).

Parameters
in_datalista list of CuData containing the keys you want to be associated to values. Each in_datalist element must contain a "src" key with the name of the source to search for in the readers (writers) list.
Example. Get the period property of each curve in the plot.
Suppose the plot has two curves with different refresh period. Get the period of each one.
  • curve 1 has source current:a
  • curve 2 has source current:b
CuData p1, p2;
p1["src"] = "current:a";
p1["period"] = -1; // will be set by getData
p2["src"] = "current:b";
p2["period"] = -1;
QList<CuData> in_dlist = QList<CuData>() << p1 << p2;
// suppose we have a QuTrendPlot named myTrendPlot...
myTrendPlot->getContext()->getData(in_dlist);
printf("Period a: %d[ms] period b: %d[ms]\n", p1["period"].toInt(), p2["period"].toInt() );

References findReader(), findWriter(), CuControlsReaderA::getData(), and CuControlsWriterA::getData().

◆ getLinkStats()

CuLinkStats * CuContext::getLinkStats ( ) const

◆ getReader()

CuControlsReaderA * CuContext::getReader ( ) const

◆ getReaderFactoryI()

CuControlsReaderFactoryI * CuContext::getReaderFactoryI ( ) const

returns a pointer to the CuControlsReaderFactoryI or NULL if the context is not a reader context

Returns
a pointer to CuControlsReaderFactoryI * if the context refers to a reader, NULL otherwise

◆ getWriter()

CuControlsWriterA * CuContext::getWriter ( ) const

◆ getWriterFactoryI()

CuControlsWriterFactoryI * CuContext::getWriterFactoryI ( ) const

returns a pointer to the CuControlsWriterFactoryI or NULL if the context is not a writer context

Returns
a pointer to CuControlsWriterFactoryI * if the context refers to a writer, NULL otherwise

◆ isAuto()

bool CuContext::isAuto ( ) const

◆ options()

CuData CuContext::options ( ) const

Get the options currently set on the context.

See also
setOptions

Referenced by setOptions().

◆ readers()

QList< CuControlsReaderA * > CuContext::readers ( ) const

◆ replace_reader()

CuControlsReaderA * CuContext::replace_reader ( const std::string &  s,
CuDataListener *  datal 
)

◆ replace_writer()

CuControlsWriterA * CuContext::replace_writer ( const std::string &  s,
CuDataListener *  datal 
)

◆ sendData() [1/2]

void CuContext::sendData ( const CuData &  data)

Send options bundle to the link, if active, and save them locally.

If the link (reader or writer) is active (either setSource or setTarget has been called) the options are sent to either CuControlsReaderA or CuControlsWriterA (hereafter named "<em>link</em>") through CuControlsReaderA::sendData or CuControlsWriterA::sendData CuData options bundle is also saved locally and can be fetched with the QuContext::options method.

Note
Call setOptions on CuContext before setSource/setTargets on the qumbia-qtcontrols object to set up the link with the desired options. Please remind that the options that can be applied are CuControlsReaderA/CuControlsWriterA (named link implementation hereafter) implementation dependent. (For example, read mode - polling or event driven - polling period and so on).
Observations
  • options bundle contents apply to the link implementation.
  • depending on the link implementation, it may be necessary to call setSource or setTargets (for example, Tango attribute properties are fetched only at setup, so options concerning initial configuration require setSource after setOptions). See the qumbia-tango-controls qucontext example.
See the specific link implementation (e.g. CuTReader/CuTWriter for Tango and CuEpReader/CuEpWriter for Epics) to determine what are the available options and what is done by CuControlsReaderA::sendData.
See also
CuTReader::sendData
Since
1.2.3
Argument editing
The "args" key can be used to update the readers' arguments (Tango, also through cumbia-http).
Example
myreader->getContext()->sendData(CuData("args", std::vector<std::string> {"1", "0" }));

References CuControlsReaderA::sendData(), and CuControlsWriterA::sendData().

◆ sendData() [2/2]

void CuContext::sendData ( const QList< CuData > &  data)

Multiple link version of sendData(const CuData& data).

Parameters
datalist of CuData options bundle to send to the links with the names provided. Every element of the list must have a "src" key with the name of the source (target) of the link to which the data must be sent to.
See also
getData(QList<CuData> &in_datalist)

References findReader(), findWriter(), CuControlsReaderA::sendData(), and CuControlsWriterA::sendData().

◆ setOptions()

void CuContext::setOptions ( const CuData &  options)

Set the options bundle on the context.

Parameters
optionsa CuData bundle with key/value pairs of options.

Saves the options locally. Options are used to configure the readers and writers instantiated by CuContext.

Note
You may want to call setOptions before replace_reader or replace_writer, so that they affect the link configuration. The CuContext introductory documentation lists the known options.
See also
sendData
options

References options().

◆ writers()

QList< CuControlsWriterA * > CuContext::writers ( ) const

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