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?
05/30/2017
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.
1 Guest(s)