> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/datran/datran-vi-scada/datran-opc-ua-server/node-changes.md).

# Node changes and node names

How the OPC UA Server handles DATRAN nodes being added and deleted, and nodes with spaces in their names.

Restarting OPC UA Server is no longer required to see DATRAN TBD tree structure changes (V1.5). DATRAN OPC UA Server attempts to overcome spaces in node names by automatically creating aliases for the DATRAN nodes in the OPC UA address space, which have the space characters replaced with underscores ("\_").

{% hint style="info" %}
**Applies to:** DATRAN OPC UA Server V1.5 and higher, with DATRAN version 6.75 or later. This is in contrast to versions 1.4 and below of OPC UA Server, which would require a restart of OPC UA Server.
{% endhint %}

## New and deleted nodes

Any nodes created in the DATRAN TBD during an OPC UA session are now reflected in OPC UA Server's address space. These changes can be seen by connected clients by re-browsing the server's address space. Similarly, any nodes deleted from the DATRAN TBD during an OPC UA session are also reflected in OPC UA Server's address space. The changes can be seen by connected clients by re-browsing instead of requiring a full server restart.

Note that this only applies to valid nodes located in the Data Root subtree of the TBD. Valid nodes are all nodes not excluded by DATRAN's TCP Server Application. By default, all nodes whose name begins with "\_" are excluded. Exceptions can be added by modifying the "Include" property of TCP Server.

### The delete delay

Unlike node creation reporting, OPC UA Server delays deleting a node from its Address Space until a configurable timeout has expired, in case the node reappears in DATRAN during this period. The reason for this delay is that if a node is deleted from the OPC UA Address Space and re-added, it is treated as a new object and any subscribers to the old node will not be subscribed to the new one.

By default, the delete delay is 20 seconds. This is configurable in the file `OpcUAServer.exe.Config`, located in your DATRAN OPC UA Server install directory, typically `C:\Program Files\QTech\DATRAN OPC UA Server`. The property is called `nodeDeleteDelayMs`, and is specified in milliseconds:

```xml
<setting name="nodeDeleteDelayMs" serializeAs="String">
  <value>10000</value>
</setting>
```

## Spaces in node names

DATRAN allows nodes to be represented with space characters in their path. For example, `Data Root\Sites\My Site\` is a valid path in DATRAN. Some third-party applications such as Wonderware InTouch will not tolerate spaces in node paths and will be unable to see these nodes when connected to a DATRAN server.

DATRAN OPC UA Server attempts to overcome this by automatically creating aliases for the DATRAN nodes in the OPC UA address space, which have the space characters replaced with underscores ("\_"). This works for most use cases and is the preferred method for achieving interoperability. Note the Item names are the fully qualified Datran path with spaces replaced by underscores.

### Renaming nodes in DATRAN

However, in some cases it may be necessary to remove the spaces from some node names in the DATRAN TBD. Node renaming can be done manually, but to rename a large number of nodes quickly QTech has produced a script called "Space Replace". When activated, the script will rename all subnodes of the target node, excluding any special DATRAN nodes (e.g. `_Comms_Object_`, `_Alarm_`, `_Script_`, etc.) and the children thereof. The renaming simply replaces any spaces in the node names with underscores.

For example, when run on a node called "Sites", the script would make the following changes:

| Before                                      | After                                       |
| ------------------------------------------- | ------------------------------------------- |
| `Sites\My Site\`                            | `Sites\My_Site\`                            |
| `Sites\Northern Sites\My Other Site\`       | `Sites\Northern_Sites\My_Other_Site\`       |
| `Sites\My Site\_Comms_Object_\Do Not Touch` | `Sites\My_Site\_Comms_Object_\Do Not Touch` |

{% hint style="warning" %}
This script should be used as a last resort. Renaming nodes may break DATRAN functionality as other scripts, formulas, alarms, services etc. may be depending on nodes as they are currently named. BACK UP YOUR TBD BEFORE USING THIS SCRIPT. THE SCRIPT'S EFFECTS ARE PERMANENT. CTRL Z WILL NOT UNDO THE EFFECTS OF THE SCRIPT.
{% endhint %}

To run it:

1. **Back up your TBD.** It is recommended that you back up the TBD. DATRAN VI Server Manager is configured to maintain backups of the TBD at a variety of intervals by default, but you are advised to create one manually. To do so, simply locate the TBD file on your hard drive (usually found at `C:\Program Files (x86)\DATRAN\Data\Datran.tbd` or `C:\Program Files\DATRAN\Data\Datran.tbd`), and copy the file to a safe location.
2. **Install the script.** The script needs to exist somewhere in the TBD in DATRAN Browser. The recommended location is `Data Root\System\Scripts\Space Replace`. Create the script if it does not already exist and copy the contents.
3. **Create a template in the target location.** To run the script, you need to create a `_Template_` node in the directory you want the script to run. When run, the script will rename the subnodes of the node containing the `_Template_`, but not the node itself.
4. **Select the Space Replace script.** A dialogue box will appear allowing you to select the script to run. Choose the "Space Replace" script.
5. **Apply the `_Template_` node.** If the `_Template_` did not apply already, apply it manually. The script should execute and apply the changes to all valid subnodes of the node containing the `_Template_`.
