PySide6.QtOpcUa.QOpcUaGenericStructValue¶
- class QOpcUaGenericStructValue¶
保存通用OPC UA结构化类型的值。更多…
概要¶
方法¶
def
__init__()
def
fields()
def
fieldsRef()
def
__ne__()
def
__eq__()
def
setFields()
def
setTypeId()
def
setTypeName()
def
swap()
def
toString()
def
typeId()
def
typeName()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
此类包含一个通用的OPC UA结构值,该值由具有其值的命名字段组成,这些字段可以是内置类型或其子类型,以及其他嵌套的通用结构。此类对象中还包含一些元信息,如类型ID和类型结构定义。
它被用作解码结果的返回类型,并作为
QOpcUaGenericStructHandler
编码方法的输入类型。对于一个具有可选字段的结构体,只有指定的字段才会包含在
fields()
列表中。在编码过程中要省略一个可选字段,它不能出现在fields()
列表中。对于从Union类型派生的结构体,必须指定其中一个字段。解码类型的fields()
列表中的唯一条目决定了类型定义中指定了哪个字段(如果有的话)。示例:
// 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__()¶
构造一个通用的结构体值。
- __init__(other)
- Parameters:
从
other
构造一个通用的结构体值。- __init__(typeName, typeId, definition)
- Parameters:
typeName – str
typeId – str
从
typeName
、typeId
和definition
构造一个通用的结构体值。- __init__(typeName, typeId, definition, fields)
- Parameters:
typeName – str
typeId – str
fields – 字典,键类型为 .QString,值类型为 QVariant。
从
typeName
、typeId
、definition
和fields
构造一个通用的结构体值。- fields()¶
- Return type:
字典的键类型为 .QString,值类型为 QVariant。
返回此通用结构体值的字段。
另请参阅
- fieldsRef()¶
- Return type:
字典的键类型为 .QString,值类型为 QVariant。
返回对此通用结构体值的字段的引用。
- __ne__(rhs)¶
- Parameters:
rhs –
QOpcUaGenericStructValue
- Return type:
布尔
如果
lhs
不等于rhs
,则返回true
。- __eq__(rhs)¶
- Parameters:
rhs –
QOpcUaGenericStructValue
- Return type:
布尔
如果
lhs
等于rhs
,则返回true
。- setFields(fields)¶
- Parameters:
fields – 字典,键类型为 .QString,值类型为 QVariant。
将此通用结构体值的字段设置为
fields
。另请参阅
- setStructureDefinition(structureDefinition)¶
- Parameters:
structureDefinition –
QOpcUaStructureDefinition
将此通用结构值的结构定义设置为
structureDefinition
。- setTypeId(typeId)¶
- Parameters:
typeId – str
将此通用结构值的类型节点ID设置为
typeId
。另请参阅
- setTypeName(typeName)¶
- Parameters:
typeName – str
将此泛型结构体值的类型名称设置为
typeName
。另请参阅
- structureDefinition()¶
- Return type:
返回此通用结构值的结构定义。
- swap(other)¶
- Parameters:
将此通用结构值对象与
other
通用结构值对象交换。此操作非常快速且永远不会失败。- toString()¶
- Return type:
字符串
返回此通用结构体值的字符串表示。
- typeId()¶
- Return type:
字符串
返回此通用结构值的类型节点ID。
另请参阅
- typeName()¶
- Return type:
字符串
返回此通用结构体值的类型名称。
另请参阅