C++ Based OPC UA Client/Server SDK  1.5.3.346

Wrapper class for the UA stack structure OpcUa_DataValue. More...

#include <uadatavalue.h>

Public Member Functions

 UaDataValue ()
 Constructs a UaDataValue with default settings.
 
 UaDataValue (const UaDataValue &other)
 Constructs a UaDataValue with another UaDataValue. More...
 
 UaDataValue (const OpcUa_DataValue &other)
 Constructs a UaDataValue with an OpcUa_DataValue structure. More...
 
 UaDataValue (const UaVariant &value, OpcUa_StatusCode statusCode, const UaDateTime &sourceTimestamp, const UaDateTime &serverTimestamp)
 Constructs a UaDataValue with a list of parameters. More...
 
 ~UaDataValue ()
 Destroys the UaDataValue object.
 
void clear ()
 Clear the data of the UaDataValue. More...
 
UaDataValueoperator= (const UaDataValue &other)
 Assignment operator. More...
 
bool operator== (const UaDataValue &other) const
 Compare variables if they are similar. More...
 
bool operator!= (const UaDataValue &other) const
 Returns true if other is not equal to this. More...
 
 operator const OpcUa_DataValue * () const
 Return internal OpcUa_DataValue structure. More...
 
OpcUa_DataValuecopy () const
 Copy UaDataValue data to a newly allocated OpcUa_DataValue. More...
 
void copyTo (OpcUa_DataValue *pDst) const
 Copy UaDataValue data to an existing OpcUa_DataValue structure. More...
 
void attach (const OpcUa_DataValue *pValue)
 Attaches the data of the parameter pValue. More...
 
OpcUa_DataValuedetach (OpcUa_DataValue *pDst)
 Detaches the internal NodeId structure from this class. More...
 
void setDataValue (UaVariant &value, OpcUa_Boolean detachValue, OpcUa_StatusCode statusCode, OpcUa_DateTime sourceTimestamp, OpcUa_DateTime serverTimestamp)
 Sets all fields of the data value. More...
 
void setDataValue (OpcUa_Variant &value, OpcUa_Boolean detachValue, OpcUa_StatusCode statusCode, OpcUa_DateTime sourceTimestamp, OpcUa_DateTime serverTimestamp)
 Sets all fields of the data value. More...
 
void setValue (UaVariant &value, OpcUa_Boolean detachValue, OpcUa_Boolean updateTimeStamps=OpcUa_False)
 Sets the value field of the data value and provides functionality to update the timestamp fields. More...
 
void setValue (OpcUa_Variant &value, OpcUa_Boolean detachValue, OpcUa_Boolean updateTimeStamps=OpcUa_False)
 Sets the value field of the data value and provides functionality to update the timestamp fields. More...
 
void setStatusCode (OpcUa_StatusCode statusCode)
 Set the status code. More...
 
void setSourceTimestamp (OpcUa_DateTime sourceTimestamp)
 Sets the source timestamp. More...
 
void setServerTimestamp (OpcUa_DateTime serverTimestamp)
 Sets the source timestamp of the server. More...
 
void setSourcePicoseconds (OpcUa_UInt16 sourcePicoseconds)
 Sets the source picoseconds. More...
 
void setServerPicoseconds (OpcUa_UInt16 serverPicoseconds)
 Sets the server picoseconds. More...
 
const OpcUa_Variantvalue () const
 Get the value of a variable. More...
 
OpcUa_DateTime sourceTimestamp () const
 Get the source timestamp. More...
 
OpcUa_DateTime serverTimestamp () const
 Get the source timestamp of the server. More...
 
OpcUa_UInt16 sourcePicoseconds () const
 Get the source picoseconds. More...
 
OpcUa_UInt16 serverPicoseconds () const
 Get the source picoseconds of the server. More...
 
OpcUa_Boolean isSourceTimestampSet () const
 Check if the source timestamp is set. More...
 
OpcUa_Boolean isServerTimestampSet () const
 Check if the server timestamp is set. More...
 

Static Public Member Functions

static OpcUa_DataValueclone (const OpcUa_DataValue &source)
 Copy OpcUa_DataValue data to a newly allocated OpcUa_DataValue. More...
 
static void cloneTo (const OpcUa_DataValue &source, OpcUa_DataValue &copy)
 Copy OpcUa_DataValue data to an existing OpcUa_DataValue structure. More...
 
static bool compare (const OpcUa_DataValue &, const OpcUa_DataValue &, OpcUa_Boolean bCompareTimestamps)
 Compares two DataValues and returns true if they are equal. More...
 
static OpcUa_StatusCode checkDeadbandExceeded (const UaDataValue &lastDataValue, const UaDataValue &newDataValue, OpcUa_Double absoluteDeadband, OpcUa_Boolean &bDeadbandExceeded)
 Calculate if the deadband is exceeded.
 

Detailed Description

Wrapper class for the UA stack structure OpcUa_DataValue.

This class encapsulates the native OpcUa_DataValue structure and handles memory allocation and cleanup for you. UaDataValue uses implicit sharing to avoid needless copying and to boost the performance. Only if you modify a shared DataValue it creates a copy for that (copy-on-write). So assigning another UaDataValue or passing it as parameter needs constant time is nearly as fast as assigning a pointer.

Constructor & Destructor Documentation

UaDataValue::UaDataValue ( const UaDataValue other)

Constructs a UaDataValue with another UaDataValue.

Parameters
[in]otherthe other UaDataValue.
UaDataValue::UaDataValue ( const OpcUa_DataValue other)

Constructs a UaDataValue with an OpcUa_DataValue structure.

Parameters
[in]otherthe other OpcUa_DataValue.
UaDataValue::UaDataValue ( const UaVariant value,
OpcUa_StatusCode  statusCode,
const UaDateTime sourceTimestamp,
const UaDateTime serverTimestamp 
)

Constructs a UaDataValue with a list of parameters.

Parameters
[in]valuethe value of a UaVariant.
[in]statusCodethe OPC UA Status code.
[in]sourceTimestampthe source timestamp.
[in]serverTimestampthe timestamp of the server.

Member Function Documentation

void UaDataValue::attach ( const OpcUa_DataValue pValue)

Attaches the data of the parameter pValue.

Don't clear the data of pValue afterwards manually, because UaDataValue is responsible for it now.

Parameters
[in]pValueParameter to attach to.
void UaDataValue::clear ( )

Clear the data of the UaDataValue.

OpcUa_DataValue * UaDataValue::clone ( const OpcUa_DataValue source)
static

Copy OpcUa_DataValue data to a newly allocated OpcUa_DataValue.

Returns
a newly allocated OpcUa_DataValue.
Parameters
[in]sourcethe source of this operation.
void UaDataValue::cloneTo ( const OpcUa_DataValue source,
OpcUa_DataValue copy 
)
static

Copy OpcUa_DataValue data to an existing OpcUa_DataValue structure.

Parameters
[in]sourceSource OpcUa_VariableTypeAttributes to clone.
[in,out]copyCopy of source OpcUa_VariableTypeAttributes.
bool UaDataValue::compare ( const OpcUa_DataValue dataValue1,
const OpcUa_DataValue dataValue2,
OpcUa_Boolean  bCompareTimestamps 
)
static

Compares two DataValues and returns true if they are equal.

See also
operator==
Parameters
[in]dataValue1The source to compare to.
[in]dataValue2The destination to compare to.
[in]bCompareTimestampsFlag indicating if the timestamp part of the data value should be included in the compare (True) or ignored (False).
OpcUa_DataValue * UaDataValue::copy ( ) const

Copy UaDataValue data to a newly allocated OpcUa_DataValue.

Returns
a newly allocated OpcUa_DataValue.
void UaDataValue::copyTo ( OpcUa_DataValue pDst) const

Copy UaDataValue data to an existing OpcUa_DataValue structure.

Parameters
[in,out]pDstthe destination of this operation.
OpcUa_DataValue * UaDataValue::detach ( OpcUa_DataValue pDst)

Detaches the internal NodeId structure from this class.

This way you take over the control of releasing the NodeId data. You can only detach the data if not more than one references exists.

It is strongly recommended to use the check in the following sample code and to do a deep copy if detach fails.

UaDataValue uaDataValue;
UaDataValue uaDataValue2;
OpcUa_DataValue rawDataValue;
OpcUa_DataValue_Initialize(&rawDataValue);
// If the following line of code is commented in, detach fails
// uaDataValue2 = uaDataValue;
// Try to detach the DataValue from the wrapper class
if ( NULL == uaDataValue.detach(&rawDataValue) )
{
// Create a deep copy since the internal data is
// referenced from another wrapper instance
uaDataValue.copyTo(&rawDataValue);
}
Returns
If the functions succeeds pDst is returned, otherwise 0 is returned.
Parameters
[out]pDstPointer to OpcUa_DataValue structure that receives the DataValue data.
OpcUa_Boolean UaDataValue::isServerTimestampSet ( ) const

Check if the server timestamp is set.

Returns
true if set false if not.
OpcUa_Boolean UaDataValue::isSourceTimestampSet ( ) const

Check if the source timestamp is set.

Returns
true if set false if not.
UaDataValue::operator const OpcUa_DataValue * ( ) const

Return internal OpcUa_DataValue structure.

Returns
internal OpcUa_DataValue structure.
bool UaDataValue::operator!= ( const UaDataValue other) const

Returns true if other is not equal to this.

See also
operator==
Returns
true if other is not equal to this.
Parameters
[in]otherthe other UaDataValue to compare.
UaDataValue & UaDataValue::operator= ( const UaDataValue other)

Assignment operator.

Returns
the reference to itself.
Parameters
[in]otherthe other UaDataValue to assign.
bool UaDataValue::operator== ( const UaDataValue other) const

Compare variables if they are similar.

Returns
true if not similar false if similar.
Parameters
[in]otherthe other UaDataValue to compare.
OpcUa_UInt16 UaDataValue::serverPicoseconds ( ) const

Get the source picoseconds of the server.

Returns
the source picoseconds of the server.
OpcUa_DateTime UaDataValue::serverTimestamp ( ) const

Get the source timestamp of the server.

Returns
the source timestamp of the server.
void UaDataValue::setDataValue ( UaVariant value,
OpcUa_Boolean  detachValue,
OpcUa_StatusCode  statusCode,
OpcUa_DateTime  sourceTimestamp,
OpcUa_DateTime  serverTimestamp 
)

Sets all fields of the data value.

Parameters
[in]valueThe value to set as UaVariant
[in]detachValueFlag indicating if the passed variant should be detached
[in]statusCodeThe status code to set
[in]sourceTimestampThe source timestamp
[in]serverTimestampThe server timestamp
void UaDataValue::setDataValue ( OpcUa_Variant value,
OpcUa_Boolean  detachValue,
OpcUa_StatusCode  statusCode,
OpcUa_DateTime  sourceTimestamp,
OpcUa_DateTime  serverTimestamp 
)

Sets all fields of the data value.

Parameters
[in]valueThe value to set as OpcUa_Variant
[in]detachValueFlag indicating if the passed variant should be detached
[in]statusCodeThe status code to set
[in]sourceTimestampThe source timestamp
[in]serverTimestampThe server timestamp
void UaDataValue::setServerPicoseconds ( OpcUa_UInt16  serverPicoseconds)

Sets the server picoseconds.

This is the number of 10 picoseconds intervals to add to the ServerTimestamp.

Parameters
[in]serverPicosecondsthe number of 10 picoseconds intervals.
void UaDataValue::setServerTimestamp ( OpcUa_DateTime  serverTimestamp)

Sets the source timestamp of the server.

Parameters
[in]serverTimestampthe server timestamp to set.
void UaDataValue::setSourcePicoseconds ( OpcUa_UInt16  sourcePicoseconds)

Sets the source picoseconds.

This is the number of 10 picoseconds intervals to add to the SourceTimestamp.

Parameters
[in]sourcePicosecondsthe number of 10 picoseconds intervals.
void UaDataValue::setSourceTimestamp ( OpcUa_DateTime  sourceTimestamp)

Sets the source timestamp.

Parameters
[in]sourceTimestampThe source timestamp to set.
void UaDataValue::setStatusCode ( OpcUa_StatusCode  statusCode)

Set the status code.

Parameters
[in]statusCodethe OPC UA Status code.
void UaDataValue::setValue ( UaVariant value,
OpcUa_Boolean  detachValue,
OpcUa_Boolean  updateTimeStamps = OpcUa_False 
)

Sets the value field of the data value and provides functionality to update the timestamp fields.

Parameters
[in]valueThe value to set as UaVariant
[in]detachValueFlag indicating if the passed variant should be detached
[in]updateTimeStampsFlag indicating if the timestamp fields should be updated
void UaDataValue::setValue ( OpcUa_Variant value,
OpcUa_Boolean  detachValue,
OpcUa_Boolean  updateTimeStamps = OpcUa_False 
)

Sets the value field of the data value and provides functionality to update the timestamp fields.

Parameters
[in]valueThe value to set as UaVariant
[in]detachValueFlag indicating if the passed variant should be detached
[in]updateTimeStampsFlag indicating if the timestamp fields should be updated
OpcUa_UInt16 UaDataValue::sourcePicoseconds ( ) const

Get the source picoseconds.

Returns
the source picoseconds.
OpcUa_DateTime UaDataValue::sourceTimestamp ( ) const

Get the source timestamp.

Returns
the source timestamp.
const OpcUa_Variant * UaDataValue::value ( ) const

Get the value of a variable.

Returns
the value of a variable.

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