# OPC UA Server References

If you want to use a predefined OPC UA node in your service commissioning file, you can use a Node reference to achieve that. One use case of that is placing newly defined nodes at the certain point in the OPC UA server tree. The other possibility is to publish data of predefined nodes as MQTT capable nodes.

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

* [Custom ReferenceNode Properties](/2-1-2/connectors/servers/opc-ua-server-references/opcuareferencenode.md)
* [Custom ObjectNode Properties](/2-1-2/connectors/servers/opc-ua-server-references/opcuaobjectnode.md)

## Service Commissioning File Example

{% file src="/files/20ETK1e7NYHR3kYce9EO" %}

{% code lineNumbers="true" %}

```yaml
---
description: Test for placing a ToolType inside a MachineTool instance

metadata:
  name: Tooltype placement test

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

  ######################################
  #
  # referencing the "Machines" folder
  # which got provided by the Machinery
  # nodeset file
  #
  ######################################
  machineRoot:
    type: Cybus::Node::OpcuaReference
    properties:
      parent: !ref opcuaServer
      referenceNodeId: 'i=1001'
      namespaceUrl: 'http://opcfoundation.org/UA/Machinery/'

  ######################################
  #
  # instantiating a MachineToolType
  # from the MachineTool type
  #
  ######################################
  testMachineToolType:
    type: Cybus::Node::OpcuaObject
    properties:
      parent: !ref machineRoot
      browseName: MyMachineToolTypeTest
      objectTypeName: MachineToolType
      sourceNamespaceUrl: 'http://opcfoundation.org/UA/MachineTool/'

  ######################################
  #
  # referencing the "Equipment" subfolder
  # of the instantiated toolType
  #
  ######################################
  EquipmentFolder:
    type: Cybus::Node::OpcuaReference
    properties:
      parent: !ref testMachineToolType
      relativeBrowsePath: '/4:Equipment'

  ######################################
  #
  # add a toolList type
  # of the instantiated toolType
  #
  ######################################
  toolList:
    type: Cybus::Node::OpcuaObject
    properties:
      parent: !ref EquipmentFolder
      browseName: Tools
      objectTypeName: ToolListType
      sourceNamespaceUrl: 'http://opcfoundation.org/UA/MachineTool/'

  #########################################
  #
  # instantiating a ToolType and placing it
  # into the tools list folder of the instance
  #
  ########################################
  demoToolInstance:
    type: Cybus::Node::OpcuaObject
    properties:
      parent: !ref toolList
      browseName: DemoTool
      objectTypeName: ToolType
      sourceNamespaceUrl: 'http://opcfoundation.org/UA/MachineTool/'
```

{% endcode %}

Preexisting nodeIds can be referenced using an absolute nodeId, e.g `ns=1;s=1001`. It is also possible to reference a nodeId by a browsePath from a certain start point that needs to be specified as well.

{% hint style="info" %}
For more information on BNF, see the [OPC Foundation Reference](https://reference.opcfoundation.org/v104/Core/docs/Part4/A.2/).
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://docs.cybus.io/2-1-2/connectors/servers/opc-ua-server-references.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
