PicoOPC User's Guide and Reference
Variants and Data Values
In This Topic

Variants

When transferring data, OPC UA uses a flexible mechanism that can cope with various data types. A variant (PicoOPC Variant type) is basically a union of well-defined (built-in) data types. The different built-in types are distinguished by the BuiltInType type (an enumeration). You specify the built-in type when creating the variant, and the Variant type has a BuiltInType property that you can use to obtain the type of data the variant contains. The actual data is in the Value property of the Variant.

Beside a single value of a built-in type (a scalar), variants can also hold arrays of built-in types. In this case, the IsArray property of the Variant is set to true.

PicoOPC reads in all arrays as one-dimensional, and it only supports one-dimensional array upon writing. PicoOpc treats DateTime built-in type as 64-bit signed integer. PicoOPC treats LocalizedText built-in type as a non-localized string. PicoOPC also treats XmlElement built-in type as a string. PicoOPC does not support ExpandedNodeId, QualifiedName, and ExtensionObject built-in types.

The actual representation of the different built-in types, and their arrays, depends on the concrete PicoOPC language binding.

Data Values

When you read an OPC UA node, you receive back a structure called data value. Besides the actual value, expressed as a variant (in the Variant property), the data value also contains the status code (in the StatusCode property, defines the server's ability to access/provide the value), and the source and server timestamps for the value (the SourceTimestamp and ServerTimestamp properties). See the Operation Model for discussion of status codes. The timestamps are represented as integers, denoting the number of 100 nanosecond intervals since January 1, 1601 (UTC).

Data value is also used when writing into an OPC UA node. In this case, usually only the Variant property (the actual value) is relevant, and the other properties stay at the their defaults (a zero in the timestamp means that the timestamp is not written).  

See Also