PdCom
5.3
Process data communication client
|
PdCom Variable interface. More...
#include <Variable.h>
Public Types | |
using | PollFuture = Future< PdCom::Exception const &, VariablePollResult, std::chrono::nanoseconds > |
using | SetValueFuture = Future< PdCom::Exception const & > |
Public Member Functions | |
Variable ()=default | |
Constructs an empty variable. | |
template<typename T > | |
std::enable_if<!std::is_arithmetic< T >::value, SetValueFuture >::type | setValue (T const &data, const Selector &selector={nullptr}) const |
Write to a variable. More... | |
template<typename T > | |
std::enable_if< std::is_arithmetic< T >::value, SetValueFuture >::type | setValue (T const &data, const Selector &selector={nullptr}) const |
Write to a variable. More... | |
template<typename T , size_t M, size_t N> | |
SetValueFuture | setValue (const T(&data)[M][N], const Selector &selector={nullptr}) const |
Write to a variable. More... | |
SetValueFuture | setValue (const void *src, TypeInfo::DataType src_type, size_t count, const Selector &selector={nullptr}) const |
Write to a variable. More... | |
PdCom::Variable::SetValueFuture | setValue (const void *src, TypeInfo::DataType src_type, size_t count, size_t offset) const |
Write to a variable. More... | |
TypeInfo | getTypeInfo () const |
Get details about the variable type. More... | |
SizeInfo | getSizeInfo () const |
Get details about the variable shape. More... | |
std::string | getPath () const |
The Path of the variable. More... | |
std::string | getName () const |
The name of the variable. More... | |
std::string | getAlias () const |
The alias of the variable, if set. More... | |
int | getTaskId () const |
The task id of the variable. More... | |
bool | isWriteable () const |
std::chrono::duration< double > | getSampleTime () const |
bool | empty () const noexcept |
Checks whether this instance is empty. More... | |
PollFuture | poll () const |
Read a variable without subscription. More... | |
Process * | getProcess () const |
Get the assigned Process. More... | |
Friends | |
class | impl::Variable |
PdCom Variable interface.
This class represents a variable (signal or parameter). It contains information about the datatype and the shape of a variable.
If you default-construct a Variable instance, it does not contain any information. Calling any other member function than empty() is forbidden. To get a valid variable instance, call Process::find().
setValue() returns a Future, which takes up to two callbacks to notify about the parameter update operation. If the server does not support these notifications, the Future is empty and no callbacks can be passed to it.
|
inlinenoexcept |
Checks whether this instance is empty.
Default-constructed variables are empty per default, calling any other member function than empty() will crash.
std::string PdCom::Variable::getAlias | ( | ) | const |
The alias of the variable, if set.
The variable must not be empty!
std::string PdCom::Variable::getName | ( | ) | const |
The name of the variable.
The variable must not be empty!
std::string PdCom::Variable::getPath | ( | ) | const |
The Path of the variable.
The variable must not be empty!
std::chrono::duration<double> PdCom::Variable::getSampleTime | ( | ) | const |
SizeInfo PdCom::Variable::getSizeInfo | ( | ) | const |
int PdCom::Variable::getTaskId | ( | ) | const |
The task id of the variable.
The variable must not be empty!
TypeInfo PdCom::Variable::getTypeInfo | ( | ) | const |
bool PdCom::Variable::isWriteable | ( | ) | const |
PollFuture PdCom::Variable::poll | ( | ) | const |
Read a variable without subscription.
This method returns a Future. To get the actual result, set a callback function using Future::then(). You can use Lambdas to capture local variables in the callback. The callback gets two arguments: a VariablePollResult instance and a timestamp. Make sure to keep the Future until it is resolved, otherwise the poll request will be dropped. So this is not fire-and-forget.
|
inline |
Write to a variable.
This function is also asynchronous, so the server might still use the old value when this function returns. This overload is for any container of arithmetic types (e.g. std::vector<int>).
T
must be a contiguous container (must have a size() method and a value_type typedef).
data | Data. |
selector | Optional selector. |
|
inline |
Write to a variable.
This function is also asynchronous, so the server might still use the old value when this function returns. This overload is for any arithmetic type (int, double, etc.). The variable must not be empty!
data | Data. |
selector | Optional selector. |
|
inline |
Write to a variable.
This function is also asynchronous, so the server might still use the old value when this function returns. This overload is for any arithmetic type (int, double, etc.). The variable must not be empty!
data | Data. |
selector | Optional selector. |
SetValueFuture PdCom::Variable::setValue | ( | const void * | src, |
TypeInfo::DataType | src_type, | ||
size_t | count, | ||
const Selector & | selector = {nullptr} |
||
) | const |
Write to a variable.
This function is also asynchronous, so the server might still use the old value when this function returns. The variable must not be empty!
src | Pointer to one or more values. |
src_type | Type of the source. |
count | Number of values. |
selector | Optional selector. |
PdCom::Variable::SetValueFuture PdCom::Variable::setValue | ( | const void * | src, |
TypeInfo::DataType | src_type, | ||
size_t | count, | ||
size_t | offset | ||
) | const |
Write to a variable.
This function is also asynchronous, so the server might still use the old value when this function returns. The variable must not be empty!
src | Pointer to one or more values. |
src_type | Type of the source. |
count | Number of values. |
offset | Optional offset in the destination. |