class QOpcUaGenericStructValue

Holds the value of a generic OPC UA structured type. More

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

This class holds a generic OPC UA struct value which consists of named fields with their values which can be built-in types or their sub types as well as other nested generic structs. Some meta information like the type ID and the structure definition of the type contained in an object of this class is also included.

It is used as return type for the decoding result and as input type for the encoding method of QOpcUaGenericStructHandler .

For a struct with optional fields, only the fields that were specified are contained in the fields() list. To omit an optional field during encoding, it must not appear in the fields() list. For structs derived from the Union type, only one of the fields must be specified. The only entry in the fields() list of a decoded type determines which field (if any) of the type definition was specified.

Example:

// Decode an extension object
QOpcUaGenericStructValue value = decoder.decode(extensionObject, success);

// Print the value of a mandatory field
qDebug() << value.fields().value("MyField").value<QOpcUaLocalizedText>();

// Print the value of an optional field
if (value.fields().contains("MyOptionalField"))
    qDebug() << value.fields().value("MyField").value<QOpcUaQualifiedName>();

// Get a nested struct for a field
const auto unionMember = value.fields().value("MyUnionMember").value<QOpcUaGenericStructValue>();

// Print the specified field
if (unionMember.fields().contains("UnionMember1"))
    qDebug() << unionMember.fields().value("UnionMember1").toInt();
else if (unionMember.fields().contains("UnionMember2"))
    qDebug() << unionMember.fields().value("UnionMember2").toDouble();
else
    qDebug() << "Empty union";
__init__()

Constructs a generic struct value.

__init__(other)
Parameters:

otherQOpcUaGenericStructValue

Constructs a generic struct value from other.

__init__(typeName, typeId, definition)
Parameters:

Constructs a generic struct value from typeName, typeId and definition.

__init__(typeName, typeId, definition, fields)
Parameters:
  • typeName – str

  • typeId – str

  • definitionQOpcUaStructureDefinition

  • fields – Dictionary with keys of type .QString and values of type QVariant.

Constructs a generic struct value from typeName, typeId, definition and fields.

fields()
Return type:

Dictionary with keys of type .QString and values of type QVariant.

Returns the fields of this generic struct value.

See also

setFields()

fieldsRef()
Return type:

Dictionary with keys of type .QString and values of type QVariant.

Returns a reference to the fields of this generic struct value.

__ne__(rhs)
Parameters:

rhsQOpcUaGenericStructValue

Return type:

bool

Returns true if lhs is not equal to rhs.

__eq__(rhs)
Parameters:

rhsQOpcUaGenericStructValue

Return type:

bool

Returns true if lhs is equal to rhs.

setFields(fields)
Parameters:

fields – Dictionary with keys of type .QString and values of type QVariant.

Sets the fields of this generic struct value to fields.

See also

fields()

setStructureDefinition(structureDefinition)
Parameters:

structureDefinitionQOpcUaStructureDefinition

Sets the structure definition for this generic struct value to structureDefinition.

setTypeId(typeId)
Parameters:

typeId – str

Sets the type node id for this generic struct value to typeId.

See also

typeId()

setTypeName(typeName)
Parameters:

typeName – str

Sets the type name for this generic struct value to typeName.

See also

typeName()

structureDefinition()
Return type:

QOpcUaStructureDefinition

Returns the structure definition for this generic struct value.

swap(other)
Parameters:

otherQOpcUaGenericStructValue

Swaps generic struct value object other with this generic struct value object. This operation is very fast and never fails.

toString()
Return type:

str

Returns a string representation for this generic struct value.

typeId()
Return type:

str

Returns the type node id for this generic struct value.

See also

setTypeId()

typeName()
Return type:

str

Returns the type name for this generic struct value.

See also

setTypeName()