> For the complete documentation index, see [llms.txt](https://docs.cybus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cybus.io/1-7-3/documentation/industry-protocol-details/opc-ua/opc-ua-object-types.md).

# OPC UA Object Types

OPC UA object types define class like structures in OPC UA namespace that can be instantiated and added to the server address space.

{% hint style="info" %}
For more information on UPC UA Object Types, see the [OPC Foundation Reference](https://reference.opcfoundation.org/v104/Core/docs/Part3/5.5.2/).
{% endhint %}

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

## Example Commissioning File

Download:

{% file src="/files/R9SaHQD7HG6N7kDWOFik" %}

{% code lineNumbers="true" %}

```yaml
---
description: demo for OPC UA objecttype nodes

metadata:
    name: OPC UA Objecttypes demo

resources:
    opcuaServer:
        type: Cybus::Server::Opcua
        properties:
            hostname: 192.168.178.46
            securityModes: ['None', 'SignAndEncrypt']
            nodesetFiles: ['di', 'machinery', 'ia', 'machineTool']
            securityPolicies: ['None', 'Basic256Sha256']
            allowAnonymous: true
            port: 4841

    parentNodeRoot:
        type: Cybus::Node::Opcua
        properties:
            parent: !ref opcuaServer
            browseName: cybus
            nodeId: ns=1;s=cybus
            nodeType: Object

    #######################################################
    #
    # Sample of an insance of an
    # machine tool type. The type "MachineToolType" is
    # defined in the MachineTool Umati namespace
    #
    #######################################################
    testMachineToolType:
        type: Cybus::Node::OpcuaObject
        properties:
            parent: !ref parentNodeRoot
            browseName: MyMachineToolTypeTest
            objectTypeName: MachineToolType
            sourceNamespaceUrl: 'http://opcfoundation.org/UA/MachineTool/'
```

{% endcode %}

## Output Format

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

{% code lineNumbers="true" %}

```yaml
{
    'ObjectTypeSample':
        {
            '_children':
                {
                    'OperationMode':
                        {
                            '_children':
                                {
                                    'ChildExample':
                                        {
                                            '_children': {},
                                            '_metadata': { 'nodeClass': 'Variable', 'dataType': 'Int64' },
                                            '_value': '1883344340925958233434349340394',
                                        },
                                },
                        },
                    '_metadata': { 'nodeClass': 'Variable', 'dataType': 'Int32' },
                    '_value': 0,
                },
        },
    '_metadata': { 'nodeClass': 'Object' },
}
```

{% endcode %}

| \_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:

{% code lineNumbers="true" %}

```yaml
{ 'ObjectTypeSample': { '_children': { 'OperationMode': { '_children': { 'ChildExample': { '_value': '50000000000000' } }, '_value': 10 } } } }
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cybus.io/1-7-3/documentation/industry-protocol-details/opc-ua/opc-ua-object-types.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
