Conceptual question about events

General topics regarding OPC Foundation and communication technology in general.

Moderator: Support Team

Post Reply
trofimich
Jr. Member
Jr. Member
Posts: 4
Joined: 19 Jul 2018, 09:24

Conceptual question about events

Post by trofimich »

Hello everybody. Tryed to ask same on OPC foundation forum, but post is awaiting moderation from yesterday. So, i've decided to ask here too...

The short question is next: two events have diffirent semantics, but same syntax (set of event parameters). Are these events should have two diffirent event types or same event type for both events?

Now the long explenation. We create model for welding machine. Welding machine has two events: “CurrentBecameGreaterThenZero” and “CurrentBacameZero”. These events do not have parameters. We develop our application using C#. In C# class we have two events of same type:

Code: Select all

public class PowerSource
    public event EventHandler CurrentBecameGreaterThanZero;
    public event EventHandler CurrentBecameZero;
In C# we can subscribe to each event separately, so we can distinguish one event from other.

It seems in OPC-UA there are no analogues for C# events and we should subscribe to PowerSource. But, in this case, it seems we can’t distinguish one event from other if they both of same type.

So, we are thinking what to do with this. The one solution is to make new event type for each event. The second solution is to make single event type with argument like “EventName”. The third solution is to make single event type and two event containers (special nested empty objects for each event).

I want to ask what is recommended way for solving such problem?

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

Re: Conceptual question about events

Post by Support Team »

An Event in OPC UA contains a list of event fields in the event notification. The possible list of fields is defined by the Server (EventType) and the actually subscribed list is defined by the client.

Therefore all information that can be processed by a client must be in one of the event fields.

The EventType is a standard event field. If this is all you need, having different EventTypes would be one was to solve your problem.

Another way is to define a dedicated event field e.g. ApplicationEventType with an enumeration.
Best regards
Unified Automation Support Team

Post Reply