OPC UA Object Types

OPC UA object types define class like structures in OPC UA namespace that can be instanciated and added to the server address space. For more details on OPC UA Object Types please refer to: <https://reference.opcfoundation.org/v104/Core/docs/Part3/5.5.2/>

It is possible to create an instance of an object type by using the resource type Cybus::Node::OpcuaObject

Example Commissioning File

Download: opcua-objecttype-example.yml

 1---
 2  description: demo for OPC UA objecttype nodes
 3  
 4  metadata:
 5    name: OPC UA Objecttypes demo
 6
 7  resources:
 8    opcuaServer:
 9      type: Cybus::Server::Opcua
10      properties:
11        hostname: 192.168.178.46
12        securityModes: ['None', 'SignAndEncrypt']
13        nodesetFiles: ['di', 'machinery', 'ia', 'machineTool']
14        securityPolicies: ['None', 'Basic256Sha256']
15        allowAnonymous: true
16        port: 4841
17
18    parentNodeRoot:
19      type: Cybus::Node::Opcua
20      properties:
21        parent: !ref opcuaServer
22        browseName: cybus
23        nodeId: ns=1;s=cybus
24        nodeType: Object
25
26    #######################################################
27    #
28    # Sample of an insance of an 
29    # machine tool type. The type "MachineToolType" is 
30    # defined in the MachineTool Umati namespace
31    #
32    #######################################################
33    testMachineToolType:
34      type: Cybus::Node::OpcuaObject
35      properties:
36        parent: !ref parentNodeRoot
37        browseName: MyMachineToolTypeTest
38        objectTypeName: MachineToolType
39        sourceNamespaceUrl: 'http://opcfoundation.org/UA/MachineTool/'

Output Format

The server provides the structure of the object types and its values as a JSON structure as the example:

{
  "ObjectTypeSample": {
    "_children": {
      "OperationMode": {
        "_children": {
          "ChildExample": {
            "_children": {},
            "_metadata": {
              "nodeClass": "Variable",
              "dataType": "Int64"
            },
            "_value": "1883344340925958233434349340394"
          }
        }
      },
      "_metadata": {
        "nodeClass": "Variable",
        "dataType": "Int32"
      },
      "_value": 0
    }
  },
  "_metadata": {
    "nodeClass": "Object"
  }
}
Details

_metadata

contains all metadata on a node. The nodeclass corresponds to the node-opcua Nodeclass enum documented here: <http://node-opcua.github.io/api_doc/2.0.0/enums/nodeclass.html> On nodes of type “Variable” the dataType entry indicates the OPC UA native data type documented here: <http://node-opcua.github.io/api_doc/2.0.0/enums/datatype.html>

_children

contains child objects in the OPC UA object tree

_value

contains the plain serialized value as JSON

Writing Updates

Writing updates to the OPC UA object type can be achieved by publishing to the <ObjectNodeName>/write topic. The same JSON structure can be used with updated data in the _value items. For data updates on U/INT64 please review the section on BigInt datatypes in OPC UA Server documentation. It is not necessary to update the complete structure. You can also only write a JSON structure that contains the direct value update. To update all values for the example structure above, only the following structure would be required:

{
  "ObjectTypeSample": {
    "_children": {
      "OperationMode": {
        "_children": {
          "ChildExample": {
            "_value": "50000000000000"
          }
        },
        "_value": 10
      }
    }
  }
}