OPC UA Write Task

Write data to OPC UA servers with write tasks.

Write tasks are the primary method for acquiring data from an OPC UA server and starting it in Synnax.

Prerequisites

Before configuring the task, you’ll need to have connected to an OPC UA server.

A Short Primer on Tasks

Tasks are the primary method for communicating with devices in Synnax. Tasks can be used for both control and data acquisition purposes. An OPC UA write task defines a background process that writes data to nodes on the OPC UA server based on values written to Synnax command channels.

An OPC UA write task can be started, stopped, and re-configured at any time. We permanently store the configuration of the task in Synnax, so it’s easy to set up multiple tasks for different purposes.

How Commands Work in Synnax

Commands in Synnax require two types of channels: a command channel and state channel. Command channels signal a task to set the value of a digital output. To set a digital output to high, you would write a 1 to the command channel. To set it to low, you would write a 0.

A command channel for a digital output might be my_temp_card_do_0_1_cmd, where my_temp_card is the device identifier, do_0_1 is the port and line of the digital output, and _cmd indicates that it’s a command channel.

Command channels also have an associated index channel that stores the timestamps at which commands were sent. This channel is suffixed with _cmd_time. For the command channel my_temp_card_do_0_1_cmd, the index channel would be my_temp_card_do_0_1_cmd_time.

State channels represent the current state of the digital output. When you send a command, the corresponding digital write task will process the command and update the value in the state channel.

State channels are typically suffixed with _state. A state channel maintains the same format as its corresponding command channel, but suffixed with _state instead of _cmd.

As an example, to configure a valve in the console schematic to write to a digital output, you would set the command field to the command channel of the digital output and the state field to the state channel of the digital output. Clicking the valve would send a command to the digital output, and the valve would turn solid or transparent based on the state channel.

Using two channels provides a guarantee that a particular command was acknowledged by a running task.

Open the Task Configuration Dialog

There are several ways to create OPC UA write tasks in the Synnax Console.

From the Resources Toolbar

To create a write task from the resources toolbar, open the Synnax Console and click on the resources () toolbar in the left sidebar. Find the device you’d like to create the task for, right-click on it, and select “Create a Write Task”.

From the Command Palette

To create a write task from the command palette, open the Synnax Console and click on the Quick Search & Command Palette at the top. You can also open this palette with Ctrl+Shift+P on Windows/Linux and Cmd+Shift+P on macOS.

In command mode (enabled when the first character in the input is ”>”), type “OPC UA”. You’ll see an option called “Create a New Write Task”. Select this option to open the write task configuration dialog.

From The Layout Selector

To create a write task from the layout selector, click on the ”+” button in the top right corner and select “OPC write Task”.

Task Configuration Parameters

FieldDescription
NameA name for your read task.
OPC UA ServerWhich OPC UA server the task will read from.
Data SavingData saving defines whether acquired data will be permanently stored in Synnax. When enabled, Synnax will both stream and store data. When disabled, Synnax will only stream data for real-time visualization. Historical data will not be available for review.

Adding Channels to a Task

To add a channel to a task, simple find the desired channel in the browser and drag it over to the channels window. From here, you can change the name of the channel. If you would like to stop a channel from being read, you can click the disable/enable button to the right of the channel.

To configure the task, just click the “Configure” button. This will save the task configuration, and you will be able to pause and resume the tasks whenever you want. Note that configuring a write task here will only create command channels. In order to create state channels, you must configure a read task.

Stopping and Starting Tasks

To stop and start a task, you can open up the task toolbar on the right-hand side and click play and pause. You can also click the play/pause icon in the bottom of the task configuration window.

State Configuration

Configuring a write task will only create command channels. To create state channels to access the states of the nodes you are writing to, you must configure a read task. You can then use the read task to read back states of the nodes you are writing to.

Using a Schematic to Control Write Tasks

Once the necessary tasks are configured, you can use the console schematic to write commands to the OPC UA server.