.NET Based OPC UA Client/Server SDK  3.3.3.537
Events

For emitting events with the BindModel mechanism, you first declare a .NET event of the EventHandler<TEvent> type where TEvent is either of the type BaseEventModel or of the type GenericEvent.

[UaEvent]
public event EventHandler<MaterialReceivedEventModel> MaterialReceivedEvent;

If the event is decorated by the [UaEvent], the server will subscribe to the event. To raise the UA event you just have to raise the .NET event:

MaterialReceivedEvent?.Invoke(this, new MaterialReceivedEventModel
{
Message = "Material entered.",
JobdIdentifier = ActiveJob?.Identifier,
Identifier = Identification.SerialNumber,
Location = Identification.Location
});

Once the server receive an event, it will first fill the EventId, Time, SourceNode, SourceName, EventType, Message, Severity, ConditionClassId, ConditionClassName, and ConditionName, properties with reasonable values if they are not already set before. Then it will convert the event to a generic event and report it to the nearest notifier in the event hierarchy.

The event hierarchy is determine during the call to BindModel. To participate, a node must have set the EventNotifier flag SubscribeToEvents. The flag can be set with the UaModeler while designing the address space or in-code with AddNotifier and AddReference. There is a third option, if you want an object type to be part of the event hierarchy you can decorate the class with the attribute UaNotifier:

[UaNotifier]
public partial class HeaterModel
{

Then BindModel will add the SubscribeToEvents flag and the necessary reference automatically. In the MachineDemoServer, two variants are demonstrated. The GlassTemperingMachine has the SubscribeToEvents flag set in the nodeset file. The heater, on the other hand, is decorated with the UaNotifier attribute.