xentara-cpp-control v1.0.1
The Xentara C++ Control Framework
Loading...
Searching...
No Matches
xentara::Output< Type > Class Template Referencefinal

An class that represents a single output for a control. More...

#include <xentara/Output.hpp>

Public Member Functions

 Output ()
 Constructor.
 
 Output (const Element &dataPoint)
 Constructor with datapoint Element.
 
auto operator= (const Element &dataPoint) -> Output &
 Assignment operator that sets the data point to read from.
 
auto write (RunContext &context, const Type &value) -> std::error_code
 Writes a value to the data point.
 
auto write (RunContext &context, Type &&value) -> std::error_code
 Writes a value to the data point.
 

Related Symbols

(Note that these are not member symbols.)

Typed outputs
using BooleanOutput = Output< bool >
 A type alias for an output that reads the data point as a C++ bool.
 
using SCharOutput = Output< signed char >
 A type alias for an output that reads the data point as an signed char.
 
using UCharOutput = Output< unsigned char >
 A type alias for an output that reads the data point as an unsigned char.
 
using ShortOutput = Output< short >
 A type alias for an output that reads the data point as a short.
 
using UShortOutput = Output< unsigned short >
 A type alias for an output that reads the data point as an unsigned short.
 
using IntOutput = Output< int >
 A type alias for an output that reads the data point as an integer.
 
using UIntOutput = Output< unsigned int >
 A type alias for an output that reads the data point as an unsigned integer.
 
using LongOutput = Output< long >
 A type alias for an output that reads the data point as a long.
 
using ULongOutput = Output< unsigned long >
 A type alias for an output that reads the data point as an unsigned long.
 
using LongLongOutput = Output< long long >
 A type alias for an output that reads the data point as a long long.
 
using ULongLongOutput = Output< unsigned long long >
 A type alias for an output that reads the data point as an unsigned long long.
 
using FloatOutput = Output< float >
 A type alias for an output that reads the data point as a float.
 
using DoubleOutput = Output< double >
 A type alias for an output that reads the data point as a double.
 
using UInt8Output = Output< std::uint8_t >
 A type alias for an output that reads the data point as a 8 bit unsigned integer.
 
using UInt16Output = Output< std::uint16_t >
 A type alias for an output that reads the data point as a 16 bit unsigned integer.
 
using UInt32Output = Output< std::uint32_t >
 A type alias for an output that reads the data point as a 32 bit unsigned integer.
 
using UInt64Output = Output< std::uint64_t >
 A type alias for an output that reads the data point as a 64 bit unsigned integer.
 
using Int8Output = Output< std::int8_t >
 A type alias for an output that reads the data point as a 8 bit signed integer.
 
using Int16Output = Output< std::int16_t >
 A type alias for an output that reads the data point as a 16 bit signed integer.
 
using Int32Output = Output< std::int32_t >
 A type alias for an output that reads the data point as a 32 bit signed integer.
 
using Int64Output = Output< std::int64_t >
 A type alias for an output that reads the data point as a 64 bit signed integer.
 
using Float32Output = Output< float >
 A type alias for an output that reads the data point as a 32 bit floating point.
 
using Float64Output = Output< double >
 A type alias for an output that reads the data point as a 64 bit floating point.
 
using StringOutput = Output< std::string >
 A type alias for an output that reads the data point as a string.
 
using WStringOutput = Output< std::wstring >
 A type alias for an output that reads the data point as a wstring.
 
using U8StringOutput = Output< std::u8string >
 A type alias for an output that reads the data point as a u8string.
 
using U16StringOutput = Output< std::u16string >
 A type alias for an output that reads the data point as a u16string.
 
using U32StringOutput = Output< std::u32string >
 A type alias for an output that reads the data point as a u32string.
 
using UUIDOutput = Output< xentara::utils::core::Uuid >
 A type alias for an output that reads the data point as a UUID.
 
using TimePointOutput = Output< std::chrono::system_clock::time_point >
 A type alias for an output that reads the data point as a time point.
 

Detailed Description

template<typename Type>
class xentara::Output< Type >

An class that represents a single output for a control.

This is class is used to define the outputs for your control code. You must declare one member of this class in your control class for each output your control code needs to read. The output must then be attached to an actual Xentara data point in the initialize() callback of your control class using the data point element assignment operator.

Template Parameters
TypeThe C++ type for the write value.

Constructor & Destructor Documentation

◆ Output() [1/2]

template<typename Type >
xentara::Output< Type >::Output ( )

Constructor.

◆ Output() [2/2]

template<typename Type >
xentara::Output< Type >::Output ( const Element dataPoint)

Constructor with datapoint Element.

Parameters
dataPointThe data point to write to. This can be a data point returned by Config::getDataPoint() or Model::findDataPoint().
Exceptions
std::runtime_errorThe requested element is not a data point in the Xentara model tree
std::runtime_errorThe requested element has value write handle error

Member Function Documentation

◆ operator=()

template<typename Type >
auto xentara::Output< Type >::operator= ( const Element dataPoint) -> Output &

Assignment operator that sets the data point to read from.

Parameters
dataPointThe data point to write to. This can be a data point returned by Config::getDataPoint() or Model::findDataPoint().
Returns
A reference to this object
Exceptions
std::runtime_errorThe requested element is not a data point in the Xentara model tree
std::runtime_errorThe requested element has value write handle error

◆ write() [1/2]

template<typename Type >
auto xentara::Output< Type >::write ( RunContext context,
const Type &  value 
) -> std::error_code

Writes a value to the data point.

The value will be converted to the type used by the target, if possible. If the value cannot be converted, the function will set the type mismatch error in the run context.

The write function first checks if there is any error in the context. If there is any error, the write will not be performed and the same error code will be returned. If there is no error in the context, the write is performed and appropiate error code is returned

Parameters
contextThe run context passed to the step() callback of your control class.
valueThe value which has to be written to the element.
Returns
std::error_code() on success, or an error code if an error occurred. Please note that a return value of std::error_code() does not mean that the value was written successfully to the device. It only means that the handle was valid, and that any preliminary checks on the value, like range checking, succeeded.

◆ write() [2/2]

template<typename Type >
auto xentara::Output< Type >::write ( RunContext context,
Type &&  value 
) -> std::error_code

Writes a value to the data point.

The value will be converted to the type used by the target, if possible. If the value cannot be converted, the function will set the type mismatch error in the run context.

The write function first checks if there is any error in the context. If there is any error, the write will not be performed and the same error code will be returned. If there is no error in the context, the write is performed and appropiate error code is returned

Parameters
contextThe run context passed to the step() callback of your control class.
valueThe value which has to be written to the element.
Returns
std::error_code() on success, or an error code if an error occurred. Please note that a return value of std::error_code() does not mean that the value was written successfully to the device. It only means that the handle was valid, and that any preliminary checks on the value, like range checking, succeeded.

Friends And Related Symbol Documentation

◆ BooleanOutput

template<typename Type >
using BooleanOutput = Output<bool>
related

A type alias for an output that reads the data point as a C++ bool.

◆ DoubleOutput

template<typename Type >
using DoubleOutput = Output<double>
related

A type alias for an output that reads the data point as a double.

◆ Float32Output

template<typename Type >
using Float32Output = Output<float>
related

A type alias for an output that reads the data point as a 32 bit floating point.

◆ Float64Output

template<typename Type >
using Float64Output = Output<double>
related

A type alias for an output that reads the data point as a 64 bit floating point.

◆ FloatOutput

template<typename Type >
using FloatOutput = Output<float>
related

A type alias for an output that reads the data point as a float.

◆ Int16Output

template<typename Type >
using Int16Output = Output<std::int16_t>
related

A type alias for an output that reads the data point as a 16 bit signed integer.

◆ Int32Output

template<typename Type >
using Int32Output = Output<std::int32_t>
related

A type alias for an output that reads the data point as a 32 bit signed integer.

◆ Int64Output

template<typename Type >
using Int64Output = Output<std::int64_t>
related

A type alias for an output that reads the data point as a 64 bit signed integer.

◆ Int8Output

template<typename Type >
using Int8Output = Output<std::int8_t>
related

A type alias for an output that reads the data point as a 8 bit signed integer.

◆ IntOutput

template<typename Type >
using IntOutput = Output<int>
related

A type alias for an output that reads the data point as an integer.

◆ LongLongOutput

template<typename Type >
using LongLongOutput = Output<long long>
related

A type alias for an output that reads the data point as a long long.

◆ LongOutput

template<typename Type >
using LongOutput = Output<long>
related

A type alias for an output that reads the data point as a long.

◆ SCharOutput

template<typename Type >
using SCharOutput = Output<signed char>
related

A type alias for an output that reads the data point as an signed char.

◆ ShortOutput

template<typename Type >
using ShortOutput = Output<short>
related

A type alias for an output that reads the data point as a short.

◆ StringOutput

template<typename Type >
using StringOutput = Output<std::string>
related

A type alias for an output that reads the data point as a string.

◆ TimePointOutput

template<typename Type >
using TimePointOutput = Output<std::chrono::system_clock::time_point>
related

A type alias for an output that reads the data point as a time point.

◆ U16StringOutput

template<typename Type >
using U16StringOutput = Output<std::u16string>
related

A type alias for an output that reads the data point as a u16string.

◆ U32StringOutput

template<typename Type >
using U32StringOutput = Output<std::u32string>
related

A type alias for an output that reads the data point as a u32string.

◆ U8StringOutput

template<typename Type >
using U8StringOutput = Output<std::u8string>
related

A type alias for an output that reads the data point as a u8string.

◆ UCharOutput

template<typename Type >
using UCharOutput = Output<unsigned char>
related

A type alias for an output that reads the data point as an unsigned char.

◆ UInt16Output

template<typename Type >
using UInt16Output = Output<std::uint16_t>
related

A type alias for an output that reads the data point as a 16 bit unsigned integer.

◆ UInt32Output

template<typename Type >
using UInt32Output = Output<std::uint32_t>
related

A type alias for an output that reads the data point as a 32 bit unsigned integer.

◆ UInt64Output

template<typename Type >
using UInt64Output = Output<std::uint64_t>
related

A type alias for an output that reads the data point as a 64 bit unsigned integer.

◆ UInt8Output

template<typename Type >
using UInt8Output = Output<std::uint8_t>
related

A type alias for an output that reads the data point as a 8 bit unsigned integer.

◆ UIntOutput

template<typename Type >
using UIntOutput = Output<unsigned int>
related

A type alias for an output that reads the data point as an unsigned integer.

◆ ULongLongOutput

template<typename Type >
using ULongLongOutput = Output<unsigned long long>
related

A type alias for an output that reads the data point as an unsigned long long.

◆ ULongOutput

template<typename Type >
using ULongOutput = Output<unsigned long>
related

A type alias for an output that reads the data point as an unsigned long.

◆ UShortOutput

template<typename Type >
using UShortOutput = Output<unsigned short>
related

A type alias for an output that reads the data point as an unsigned short.

◆ UUIDOutput

A type alias for an output that reads the data point as a UUID.

◆ WStringOutput

template<typename Type >
using WStringOutput = Output<std::wstring>
related

A type alias for an output that reads the data point as a wstring.