Conceptual question about events|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Conceptual question about events
Avatar
Alexander Tyutik
Ukraine
Member
Members
Forum Posts: 15
Member Since:
07/21/2015
sp_UserOfflineSmall Offline
1
07/18/2018 - 03:27
sp_Permalink sp_Print

Hello everybody.

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:

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?

Avatar
Randy Armstrong
Admin
Forum Posts: 1445
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
07/19/2018 - 08:46
sp_Permalink sp_Print

You need to create 2 event types. They can share a common base type.

Avatar
Alexander Tyutik
Ukraine
Member
Members
Forum Posts: 15
Member Since:
07/21/2015
sp_UserOfflineSmall Offline
3
07/23/2018 - 02:15
sp_Permalink sp_Print

Thank you for response.

But this mean that number of types can grow very fast and all types will be idencical and have diffirent names only. And this looks like bad software architecture.

I don't understand why such ideology is used. Maybe somebody give some explenation?

Avatar
Randy Armstrong
Admin
Forum Posts: 1445
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
07/23/2018 - 05:46
sp_Permalink sp_Print sp_EditHistory

Well, you gave an example of 2 events in C# and I suggested a model that would preserve the C# style behavoir. If you have a scenario where you have multiple criteria that are used independently of each other as filters then you would want to use custom event properties for these criteria to avoid the combitorial explosion you noted.

In your case, you don't need 2 events that are the inverse of each other. Instead you can create an CurrentChangedEventType with a CurrentValue Property. The application would then use the CurrentValue to test for GreaterThanZero or Zero.

The best model depends on your compete set of requirements.

Avatar
Alexander Tyutik
Ukraine
Member
Members
Forum Posts: 15
Member Since:
07/21/2015
sp_UserOfflineSmall Offline
5
07/24/2018 - 01:29
sp_Permalink sp_Print sp_EditHistory

We have such implementation (with additional property). Strange thing for us is that BaseEventType does not have any built in identification (somithing like EventSender mandatory property).

In any case, thank you for explenation!

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 19
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1347
Posts: 4567