PdCom  4.2
Process data communication client
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
PdCom::Variable Class Referenceabstract

Process variable. More...

#include <Variable.h>

Classes

class  Subscription
 Subscription class. More...
 

Public Types

enum  Type {
  boolean_T = 0, uint8_T, int8_T, uint16_T,
  int16_T, uint32_T, int32_T, uint64_T,
  int64_T, double_T, single_T
}
 Variable's type.
 

Public Member Functions

 Variable (Type type, double sampleTime, size_t task, bool writeable, const std::string &alias, size_t ndim, const size_t *dims)
 Constructor.
 
virtual std::string name () const =0
 Short name without leading path.
 
virtual std::string path () const =0
 complete path, including name()
 
bool isScalar () const
 Scalar test.
 
size_t isVector () const
 Test for a vector. More...
 
bool setStringValue (const std::string &value) const
 Set a parameter's value. More...
 
template<typename T >
bool setValue (const T *val, size_t offset, size_t nelem) const
 Set a parameter's value. More...
 
bool read (std::istream &is) const
 Set a parameter's value. More...
 

Public Attributes

const Type type
 Data type.
 
const char *const ctype
 c-type string One of: More...
 
const double sampleTime
 sample time of variable; 0 for parameters
 
const size_t task
 Task id of signals. More...
 
const bool writeable
 Can be written to, for parameters.
 
const std::string alias
 Optional alias.
 
const size_t nelem
 Number of elements.
 
const std::vector< size_t > dim
 Dimension array.
 
const size_t typeWidth
 sizeof(datatype)
 
const size_t bytes
 memory required to store everything
 

Detailed Description

Process variable.

This class abstracts the process variable.

Examples:
example.cpp.

Member Function Documentation

◆ isVector()

size_t PdCom::Variable::isVector ( ) const

Test for a vector.

A scalar is also a vector with one element

Returns
Number of vector elements

◆ read()

bool PdCom::Variable::read ( std::istream &  is) const

Set a parameter's value.

Parameters
isa std::istream value. Elements must be delimited by any non-numeric character.
Returns
true on error

◆ setStringValue()

bool PdCom::Variable::setStringValue ( const std::string &  value) const

Set a parameter's value.

Alias for read().

Examples:
example.cpp.

◆ setValue()

template<typename T >
bool PdCom::Variable::setValue ( const T *  val,
size_t  offset,
size_t  nelem 
) const

Set a parameter's value.

Parameters
valvalue buffer to read from. Must have at lease nelem elements
offsetStarting index
nelemnumber of elements to write
Returns
true on error
Examples:
example.cpp.

Member Data Documentation

◆ ctype

const char* const PdCom::Variable::ctype

c-type string One of:

  • "uint8_t"
  • "int8_t"
  • "uint16_t"
  • "int16_t"
  • "uint32_t"
  • "int32_t"
  • "uint64_t"
  • "int64_t"
  • "double"
  • "float"
Examples:
example.cpp.

◆ task

const size_t PdCom::Variable::task

Task id of signals.

Note that signals of the same task may have different sample times, indicating that the signal is subrated within the task


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