C++ Based OPC UA Client/Server/PubSub SDK
1.7.8.584
|
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... | |
UaDataValue & | operator= (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_DataValue * | copy () 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_DataValue * | detach (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_Variant * | value () 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_DataValue * | clone (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 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. | |
static bool | deadbandExceeded (OpcUa_Double val1, OpcUa_Double val2, OpcUa_Double absoluteDeadband) |
Helper function to calculate if the difference between val1 and val2 exceeds the absoluteDeadband. More... | |
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.
UaDataValue::UaDataValue | ( | const UaDataValue & | other | ) |
Constructs a UaDataValue with another UaDataValue.
[in] | other | the other UaDataValue. |
UaDataValue::UaDataValue | ( | const OpcUa_DataValue & | other | ) |
Constructs a UaDataValue with an OpcUa_DataValue structure.
[in] | other | the 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.
[in] | value | the value of a UaVariant. |
[in] | statusCode | the OPC UA Status code. |
[in] | sourceTimestamp | the source timestamp. |
[in] | serverTimestamp | the timestamp of the server. |
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.
[in] | pValue | Parameter to attach to. |
void UaDataValue::clear | ( | ) |
Clear the data of the UaDataValue.
|
static |
Copy OpcUa_DataValue data to a newly allocated OpcUa_DataValue.
[in] | source | the source of this operation. |
|
static |
Copy OpcUa_DataValue data to an existing OpcUa_DataValue structure.
[in] | source | Source OpcUa_VariableTypeAttributes to clone. |
[in,out] | copy | Copy of source OpcUa_VariableTypeAttributes. |
|
static |
Compares two DataValues and returns true if they are equal.
[in] | dataValue1 | The source to compare to. |
[in] | dataValue2 | The destination to compare to. |
[in] | bCompareTimestamps | Flag 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.
void UaDataValue::copyTo | ( | OpcUa_DataValue * | pDst | ) | const |
Copy UaDataValue data to an existing OpcUa_DataValue structure.
[in,out] | pDst | the destination of this operation. |
|
static |
Helper function to calculate if the difference between val1 and val2 exceeds the absoluteDeadband.
Implements a special handling for NaN values. If exactly one of the value is NaN this method returns true.
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.
[out] | pDst | Pointer to OpcUa_DataValue structure that receives the DataValue data. |
OpcUa_Boolean UaDataValue::isServerTimestampSet | ( | ) | const |
Check if the server timestamp is set.
OpcUa_Boolean UaDataValue::isSourceTimestampSet | ( | ) | const |
Check if the source timestamp is set.
UaDataValue::operator const OpcUa_DataValue * | ( | ) | const |
Return internal OpcUa_DataValue structure.
bool UaDataValue::operator!= | ( | const UaDataValue & | other | ) | const |
Returns true if other is not equal to this.
The timestamps are ignored for this comparison.
[in] | other | the other UaDataValue to compare. |
UaDataValue & UaDataValue::operator= | ( | const UaDataValue & | other | ) |
Assignment operator.
[in] | other | the other UaDataValue to assign. |
bool UaDataValue::operator== | ( | const UaDataValue & | other | ) | const |
Compare variables if they are similar.
The timestamps are ignored for this comparison.
[in] | other | the other UaDataValue to compare. |
OpcUa_UInt16 UaDataValue::serverPicoseconds | ( | ) | const |
Get the source picoseconds of the server.
OpcUa_DateTime UaDataValue::serverTimestamp | ( | ) | const |
Get 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.
[in] | value | The value to set as UaVariant |
[in] | detachValue | Flag indicating if the passed variant should be detached |
[in] | statusCode | The status code to set |
[in] | sourceTimestamp | The source timestamp |
[in] | serverTimestamp | The 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.
[in] | value | The value to set as OpcUa_Variant |
[in] | detachValue | Flag indicating if the passed variant should be detached |
[in] | statusCode | The status code to set |
[in] | sourceTimestamp | The source timestamp |
[in] | serverTimestamp | The 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.
[in] | serverPicoseconds | the number of 10 picoseconds intervals. |
void UaDataValue::setServerTimestamp | ( | OpcUa_DateTime | serverTimestamp | ) |
Sets the source timestamp of the server.
[in] | serverTimestamp | the 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.
[in] | sourcePicoseconds | the number of 10 picoseconds intervals. |
void UaDataValue::setSourceTimestamp | ( | OpcUa_DateTime | sourceTimestamp | ) |
Sets the source timestamp.
[in] | sourceTimestamp | The source timestamp to set. |
void UaDataValue::setStatusCode | ( | OpcUa_StatusCode | statusCode | ) |
Set the status code.
[in] | statusCode | the 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.
This method sets the Value of the DataValue to the passed value and the StatusCode to OpcUa_Good. The SourceTimestamp and ServerTimestamp are updated if the updateTimeStamps parameter is set to OpcUa_True.
[in] | value | The value to set as UaVariant |
[in] | detachValue | Flag indicating if the passed variant should be detached |
[in] | updateTimeStamps | Flag 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.
This method sets the Value of the DataValue to the passed value and the StatusCode to OpcUa_Good. The SourceTimestamp and ServerTimestamp are updated if the updateTimeStamps parameter is set to OpcUa_True.
[in] | value | The value to set as UaVariant |
[in] | detachValue | Flag indicating if the passed variant should be detached |
[in] | updateTimeStamps | Flag indicating if the timestamp fields should be updated |
OpcUa_UInt16 UaDataValue::sourcePicoseconds | ( | ) | const |
Get the source picoseconds.
OpcUa_DateTime UaDataValue::sourceTimestamp | ( | ) | const |
Get the source timestamp.
const OpcUa_Variant * UaDataValue::value | ( | ) | const |
Get the value of a variable.