4. View & Write Node Data

OPC UA Client Project Data

Data values of Nodes can be viewed and modified through the Node Data table accessible through the () Data button on the OPC UA Client project main page.

This guide describes:

  1. How to view and chart OPC UA Client real time data.
  2. Viewing a Group’s data payload with the MQTT Client.
  3. How to write values into one or more OPC UA Client Nodes.

Back to Top

Viewing and Charting Node Data

The Data tab of a OPC UA Client project is used to display the real time values of the Nodes configured. The Data tab is only visible when the project is running.

To see the real time values of the Nodes configured for a Project:

  1. Open the target OPC UA Client project from the Projects list.
  2. Confirm that the Project is running. If it is not Running, please Start or Restart your Project.
  3. When the Project is Running, Click on the () Data button on the OPC UA project’s main page to display the Node’s page.
Open Data page
  1. Select the Group whose Nodes you want to view from the dropdown menu. This opens the Node table.

  2. The table displays the following columns:

    • Name is the name given to the Node being displayed.
    • ID is the Node’s address.
    • Last Value displays the Node’s last value.
    • Timestamp displays the timestamp of the last value written to the Node.
    • New Value displays a new value written to the Node.
    • Chart displays switches on every row. Turning the switches on will display a real time chart for the Node selected.
Data Chart
  1. To view near real-time chart(s) of one or more Nodes, turn on the corresponding switch(es) in the Chart column. The values of the Node(s) will be displayed on chart(s) below. Note that you can toggle the display of the charts when there are multiple values by clicking on their respective legends.
Data Chart

Back to Top

Viewing Data with the MQTT Client

The Edge One™ MQTT Client can also be used to see the payloads of real-time data published by the OPC UA Server.

Note that the MQTT Client only operates in real-time and must be opened when the data is published. For example, if you want to see the data from a Group and the Client is closed when the data is published, you will not see any data after opening the MQTT Client.

To view the data payload of a data Group:

  1. Open the MQTT Client.

  2. Click on Topic

  3. Enter the topic name as:

     data/myprojectname/groupID
    

Where myprojectname is the name of your OPC UA project and GroupID is the GroupID of the Group whose payload you want to see.

  1. The data published will start flowing and you can use the features as described in the MQTT Client documentation.

Back to Top

Writing Nodes

There are two ways to write data to OPC UA Nodes:

  1. Using the Data user interface.
  2. Publishing data into cmd channels.

Write Using Data Interface

To write values into one or more Nodes using the graphical user interface:

  1. Open the target OPC UA Client project from the Projects list.
  2. Confirm that the Project is running. If it is not Running, please Start or Restart your Project.
  3. When the Project is Running, Click on the () Data button on the OPC UA project’s main page to display the Nodes page.
Open Data page
  1. Select the Group whose Nodes you want to view. This opens the Node table.
Select Group
  1. In the New Value column of the Node(s) you want to write, enter the value(s) you want to write using the data format required by the Node. In the example below, the Node is an integer. We enter the new value as 80.

The Write values button will appear indicating the number of Nodes whose values you will write.

Written data
  1. Click on the Write values button to complete the process.

  2. The Last Value column will display the values you wrote on the respective Nodes, and any chart being displayed will also be updated as shown below. The value prior to the last shown as 82, is the one we wrote. The example sampling rate was too fast to capture the image the moment the value of 80 was written. The chart, however, does show our value of 80.

Written data

Back to Top

Writing Nodes using cmd channels

This section describes how to write data to a single node or to multiple nodes by publishing data to the cmd/ or write/ channels.

Writing data to a single node

To write data to Node ns=3, publish data to channel cmd/, where is the project ID, as follows:

	{
 		 "data": {
  	 	 "value": "e0af7e11-7aa8-4a89-9865-5d00fea9525b",
  		  "nodeId": "ns=3;s=StringDataItem"
 	 },
 		 "otp": "94605235",
 		 "type": "write",
 		 "cid": "31843409-8570-48bb-b353-b76511f74f89"
	 }

the OPC UA Client replies with:

	{
 		 "mod": "opc-ua",
 		 "data": {
  			  "result": "ok",
  			  "status": true
 	 },
		  "pid": 666,
 		  "type": "write",
		  "status": true,
	      "cid": "31843409-8570-48bb-b353-b76511f74f89",
	      "ts": 1519226946712
   }

or, in case of error on the type of data, for example, when trying to write a String into a Node that requires a numerical value:

	{
	      "data": {
		        "value": "A String cannot be an Integer",
 			   "nodeId": "ns=3;s=Int16DataItem"
	     },
	    "otp": "77201598",
        "type": "write",
   		"cid": "97682281-53bb-46ce-9e33-1b56f4116875"
	}

the Client sends an error code. In the example above:

	{
	      "mod": "opc-ua",
	      "data": {
			        "result": "ko",
			        "code": "TypeMismatch",
			        "errors": {
					          "code": "TypeMismatch",
   							  "nodeId": "ns=3;s=Int16DataItem"
   					 },
   					 "status": false
  					},
		  "pid": 666,
	      "type": "write",
          "status": false,
	      "cid": "97682281-53bb-46ce-9e33-1b56f4116875",
	      "ts": 1519227431920
   }

To write data to a list of nodes, the following message can be sent to cmd/:

{
  "data": {"vals": [
    {
      "v": "false",
      "k": "ns=3;s=BooleanDataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=ByteDataItem"
    },
    {
      "v": "c99ef4cc-363f-4a60-afa4-a01c44e01d5b",
      "k": "ns=3;s=ByteStringDataItem"
    },
    {
      "v": "1517582765552",
      "k": "ns=3;s=DateTimeDataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=DoubleDataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=FloatDataItem"
    },
    {
      "v": "1dee0d4a-fea8-4622-8f79-2b97e2a5f027",
      "k": "ns=3;s=GUIDDataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=Int16DataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=Int32DataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=Int64DataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=SByteDataItem"
    },
    {
      "v": "c99ef4cc-363f-4a60-afa4-a01c44e01d5b",
      "k": "ns=3;s=StringDataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=UInt16DataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=UInt32DataItem"
    },
    {
      "v": "78",
      "k": "ns=3;s=UInt64DataItem"
    },
    {
      "v": "<?xml ?><testCP/>",
      "k": "ns=3;s=XmlElementDataItem"
    }
  ]},
  "otp": "41336017",
  "type": "write",
  "cid": "400cd60b-3461-4b60-8f7d-464699c0e626"
}

If there is an error, the Client replies with a list as follows:

	{
      "mod": "opc-ua",
      "data": {
      			"errors": [
			        {
			         "result": "ko",
			          "code": "TypeMismatch",
			          "v": "1dee0d4a-fea8-4622-8f79-2b97e2a5f027",
			          "k": "ns=3;s=GUIDDataItem",
			          "status": false
			        },
		        	{
 		         	  "result": "ko",
		        	  "code": "InvalidArgument",
      				  "v": "<?xml ?><testCP/>",
      				  "k": "ns=3;s=XmlElementDataItem",
      				  "status": false
   					 }
				  ]},
 		"pid": 666,
 		"type": "write",
 		"status": false,
		"cid": "400cd60b-3461-4b60-8f7d-464699c0e626",
		"ts": 1519227524181
	  }

For each of the four types of configurations (subscribe only to data changes, subscribe to all data with a sampling rate, subscribe only to events, or write without subscription) the Client Groups are always subscribed to the MQTT topics write//, where groupID is the ID of each individual group. You can publish data values to these topics as:

	{"vals": [{
		      	"v": "ad64e051-9237-4938-93a7-c40ce1d59227",
		      	"k": "ns=3;s=StringDataItem"
		      },
		      {
  				"v": "275",
 				 "k": "ns=3;s=UInt64DataItem"
			   }]
	}

Another way to write data is to use the default topic write/. The Client subscribes to this channel on the Edge One™ MQTT Broker as default. Here is the result of a query on the MQTT server:

	2018-02-21 16:51:54 [MQTT Call: opc-ua_185786422110240] INFO  SmartPlug:-1 - (18)
	received data from channel: write/666 
	data:{"vals": [{
 		 "v": "ab67b808-3971-40c1-9282-5feda6fb5acb",
 		 "k": "ns=3;s=StringDataItem"
	 }]}

When data is written into the channel data// using one of the two data subscription methods, the payload has the following structure:

	{
	 "pid" : 666,
	 "mod" : "opc-ua",
	 "vals" : [ {
			  "q" : 0,
		      "st" : 1519232160127,
		      "k" : "ns=5;s=Counter1",
		      "v" : 26,
		      "ts" : 1519232160000
	  } ],
	 "g" : 2,
	 "ts" : 1519232185236
	}

where the first timestamp ts under vals is the timestamp of when the data was generated by the device/PLC sending data to the OPC server, st is the timestamp when the data was handled by the OPC Server and the last timestamp ts in the main structure is when the OPC UA Client sends the message to Edge One™.

Still need help? Get in touch!
Last updated on 6th May 2021