Combine multiple variables

Unified Architecture topics related to OPC UA Specification, compliant behavior and any technical issues of OPC UA, like Security, Information Model, Companion Specs DI, PLCopen, ADI, ...

Moderator: Support Team

Post Reply
delema98
Jr. Member
Jr. Member
Posts: 1
Joined: 21 Aug 2023, 13:53

Combine multiple variables

Post by delema98 »

Hi all together,

I am fairly new to the OPC-UA topic and am currently trying to implement some functionality for a student project.
My current challenge is that I want to combine several variables that I subscribe to into a single event like "PartIsProduced".
My configuration is the following:
PLC (with OPC-UA enabled) --> Broker (Zenon) --> Custom UA Client (C#) / UaExpert.
(I know that the broker is not necessary, but it is used for legacy reasons).

In my custom client I implemented some code that collects all necessary variables for the event "PartIsProduced" and when a "trigger variable" changes, I pack everything into a predefined structure and send it to downstream services.

When packing my data structure, I sometimes have the problem that the different variables don't arrive in the right order and I pack the wrong values together.
For example, the change in the value of the trigger variable arrives earlier than some of the other values and some old and new values are packed together.


Does anyone have some tips how I can solve this problem?

Thanks in advance!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Combine multiple variables

Post by Support Team »

Hi,

you can not "pack" individual variables together and assume they are consistently changing all together at the same time. Either they have been packed already at the source, i.e. being a "structure", hence a type in itself and by this have consistency over the type. However an intermediate entity can not "pack" and make "consistent" an arbitrary set of individual variables coming from one or (even worse) multiple sources.

BTW this is a data consistency problem, that has nothing to do with OPC in general or OPC UA in particular. The approach to "pack" and "combine" at any intermediate or at the target, and "hope" for consistency, is just a wrong assumption. If the source would have envisioned that it makes sense to have a combination of data being consistent, it would have modeled it as structure (but not individual variables).
Best regards
Unified Automation Support Team

Post Reply