使用 OPC UA 可以实现上述目标。它被称为信息建模。
是否支持取决于 OPC UA SDK(Framework) 到 SDK。
如果 SDK 支持自定义对象类型、自定义变量类型创建,则可以借助简单的节点集 XML 文件创建自定义类型。
在您的示例中,您可以创建一个名为 Person 的变量类型并创建一个相同的实例。而且您也将能够实现如上所述的推送通知..
请找到下面提到的 Nodeset XML Snippet,用于创建自定义对象类型自定义变量并创建相同的实例。
<!-- Below XML logic will explain on how to create Custom Object Type and Custom Variable Type-->
<UAObjectType NodeId="ns=2;s=PersonType" BrowseName="2:PersonType">
<DisplayName>PersonType</DisplayName>
<Description>A Person Object Type</Description>
<References>
<Reference ReferenceType="HasComponent">ns=2;s=NameType</Reference>
<Reference ReferenceType="HasComponent">ns=2;s=AgeType</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
</References>
</UAObjectType>
<UAVariableType NodeId="ns=2;s=AgeType" BrowseName="2:AgeType" DataType="Byte">
<DisplayName>AgeType</DisplayName>
<Description>A Age variable type. it is component of AgeType</Description>
<References>
<Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=PersonType</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=63</Reference>
</References>
</UAVariableType>
<UAVariableType NodeId="ns=2;s=NameType" BrowseName="2:NameType" DataType="LocalizedText">
<DisplayName>NameType</DisplayName>
<Description>A Name Variable type. it is component of NameType</Description>
<References>
<Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=PersonType</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=63</Reference>
</References>
</UAVariableType>
<!-- Below XML logic will explain on how to create instance of an object using above mentioned types-->
<!-- This will create a person1 object inside the Object folder -->
<UAObject NodeId="ns=2;s=Person1" BrowseName="2:Person1">
<DisplayName>Person1</DisplayName>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasComponent">ns=2;s=Name1</Reference>
<Reference ReferenceType="HasComponent">ns=2;s=Age1</Reference>
<Reference ReferenceType="HasTypeDefinition" IsForward="false">ns=2;s=PersonType</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=2;s=Age1" BrowseName="2:Age1" DataType="Byte">
<DisplayName>Age1</DisplayName>
<Description>A Age variable type. it is component of AgeType</Description>
<References>
<Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=Person1</Reference>
<Reference ReferenceType="HasTypeDefinition" IsForward="false">ns=2;s=AgeType</Reference>
</References>
<Value>
<Byte>10</Byte>
</Value>
</UAVariable>
<UAVariable NodeId="ns=2;s=Name1" BrowseName="2:Name1" DataType="LocalizedText">
<DisplayName>Name1</DisplayName>
<Description>A Name Variable type. it is component of NameType</Description>
<References>
<Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=Person1</Reference>
<Reference ReferenceType="HasTypeDefinition" IsForward="false">ns=2;s=NameType</Reference>
</References>
<Value>
<LocalizedText>
<Locale>en</Locale>
<Text>MyName</Text>
</LocalizedText>
</Value>
</UAVariable>
如果 SDK 支持 nodeset 文件解析,请将此代码段放在现有的 nodeset 文件中并导入。或者创建一个节点集文件并将此代码段和导入到您的服务器代码中。
这将轻松创建对象类型及其实例。
我希望这有帮助。
谢谢你。