Skip to content

Variant

Variant is a container for the build in OPC-UA datatypes. It is used to hold the values for the input and output values of a MethodNode's method.

Functions

Variant.new(type)

Creates a new Variant instance

Params

Returns: Variant new instance

Methods

Variant:isEmpty()

Checks if the Variant has no value defined

Returns: boolean true if there is no value defined

Variant:isScalar()

Checks if the Variant contains a scalar value

Returns: boolean true if the variant contains a scalar value

Variant:hasScalarType(type)

Checks if a Variant contains a scalar value of the given type

Params

Returns: boolean true if the variant contains a scalar value of the given type

Variant:hasArrayType()

Checks if a Variant contains an array of the given type

Params

Returns: boolean true if the variant contains an array of the given type

Variant:setScalar(value)

Set the variant to a scalar value

Params

  • value
  • string|number|boolean
  • The scalar value

Variant:setArray(value, shape)

Set the variant to an array

Params

  • value
  • string[]|number[]|boolean[]
  • array of values

  • shape

  • number[]
  • The arrays dimensions
  • Optional
    • If not provided, the variant will default to a flat array shape.

Variant:getScalar()

Get the value of a scalar variant

Returns: string|number|boolean the variants scalar value

Variant:getArray()

Get the value of an array variant

Returns: string[]|number[]|boolean[] the variant's array

Variant:getArrayShape()

Get the array dimensions (shape) of the variant

Returns: number[] the variant's shape or nil if the shape is scalar.

Back to top