Showing results for 
Search instead for 
Did you mean: 

How do I associate a data change event with its corresponding variable?

Go to solution

We have an OPC-UA server with about 100 tags (NodeID) and are planning to use LabVIEW as a supervisory program.

I created a OPC-UA client subscription and a event structure according to NI OPC-UA example:


NI OPC-UA Client ExampleNI OPC-UA Client Example












But now I don't know how to associate the data change event with the right indicator.

Let me give you an example:

Let's suppose that our OPC-UA server have four variables:

OPC-UA server variablesOPC-UA server variables




With the "Create" we can have an <OPC UA Data change event> that will update the values.

The output of the change event is a cluster with "Item URL" and "Value" (data type = variant)


I want to associate each one of these variables with indicators, that will have info, measurements, messages and decisions for the user of the supervisory program (remember that we are have 100+ nodeIDs).


But I don't know how to associate the event output ("Data change") with the corresponding variable, because the variables change its value in different times. For example: the 1st iteration change the value for the 2nd variable, the 2nd iteration change the value for the 4th variable, the 3rd iteration change the value for the 2nd variable again and etc.


The OPC-UA Client Example from NI have only one NodeID, so it isn't clear to me how do I do the "data distribution" to my indicators

The image below is my current OPC-DAQ






















0 Kudos
Message 1 of 4

Case structure by Item URL?

0 Kudos
Message 2 of 4
Accepted by mthheitor

You could do it with a simple case structure as suggested by  Artem.SPb, with a case for each variable:



Or you could use a more generic way, so you just have to created the control with the right name, and the value is automatically updated without additional code. Here it detects the name of the control to update by taking the end of the Item URL, for example you just need to name your controls Variable1, Variable2, Variable3, ... to automatically update from OPC variables "ServerInterfaces.OPC.Variable1", "ServerInterfaces.OPC.Variable2", "ServerInterfaces.OPC.Variable3", ...


For the 2nd solution, you can also use "Set Control Values by Index", which is more effective in case you have lots of controls and need a high refresh rate. However it requires to know the index of the controls in the front panel.


Message 3 of 4

I have to question the sanity of designing a UI with 100s of controls/indicators. Yes, your system may actually have that many items but from a UI perspective, more than a handful of items displayed at any one point in time is very difficult for a user to comprehend. Surely the UI design can be broken down to display fewer related items at one time. You may have groups of related items which are displayed as well as apply to different groups of node IDs. The user makes some sort of selection of what to display. Behind the scenes youyr application could have a data repository which has the latest values for all your nodes and get updated via the URL. You could think or maps or sets for storing the data. Based on a user selection you would display the desired elements on the UI in a concise display.

Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4