'Declaration
Public Class AEEventDataPayload
'Usage
Dim instance As AEEventDataPayload
public class AEEventDataPayload
public ref class AEEventDataPayload
'Declaration
Public Class AEEventDataPayload
'Usage
Dim instance As AEEventDataPayload
public class AEEventDataPayload
public ref class AEEventDataPayload
The event payload class for OPC Alarms&Events is the AENotificationPayload class. This class contains an embedded AEEventDataPayload object, which contains the actual OPC event. This object is always present; in case of errors and special cases, it contains default or pre-defined values.
A special event priority value is used when no OPC event is present (in case of errors, but also re-gained connections, and a completed refresh). Normal OPC event priorities are in the range from 0(1) to 1000. When creating a payload for a notification where no actual OPC event is present, an event priority value of 9999 is used. The value 9999 is chosen to be higher than the severity of any OPC-A&E event, yet still in a 4-digit range.
The payload class does not contain any fields for OPC server-specific event attributes. If you need to process the OPC event attributes in StreamInsight, derive your own class from AEEventDataPayload, add the fields you need, and develop a code that extracts the attributes from the AEEventData object (in EasyAENotificationEventArgs.EventData).
In addition, there is a Server string property, identifying the source of the event. For a single OPC observable, it always contains the same value, but it becomes useful once you start combining events from different OPC sources into one stream.
// This example shows how to create an OPC Alarms&Events event source, and query it for events with severity 20 or higher. using System; using System.Diagnostics; using System.Reactive; using System.ServiceModel; using Microsoft.ComplexEventProcessing; using Microsoft.ComplexEventProcessing.Linq; using Microsoft.ComplexEventProcessing.ManagementService; using OpcLabs.EasyOpc.AlarmsAndEvents; using OpcLabs.EasyOpc.AlarmsAndEvents.ComplexEventProcessing; using OpcLabs.EasyOpc.AlarmsAndEvents.Reactive; namespace SimpleAEStreamInsightApplication { class Program { static void Main() { // Create an embedded StreamInsight server //using (var server = Server.Create("Default")) using (var server = Server.Create("Instance1")) { Debug.Assert(server != null); // Create a local end point for the server embedded in this program var managementService = server.CreateManagementService(); Debug.Assert(managementService != null); var host = new ServiceHost(managementService); host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), "http://localhost/MyStreamInsightServer"); host.Open(); /* The following entities will be defined and available in the server for other clients: * serverApp * serverSource * serverSink * serverProcess */ // CREATE a StreamInsight APPLICATION in the server var myApp = server.CreateApplication("serverApp"); // DEFINE a simple SOURCE (returns a point event every second) const string machineName = ""; const string serverClass = "OPCLabs.KitEventServer.2"; var observable = AENotificationObservable.Create( machineName, serverClass, 100, AESubscriptionFilter.Empty, AEAttributeSetDictionary.Empty); var mySource = myApp .DefineObservable(() => observable) .ToPointStreamable( eventArgs => PointEvent.CreateInsert( DateTimeOffset.Now, (AENotificationPayload)eventArgs), AdvanceTimeSettings.StrictlyIncreasingStartTime); // DEPLOY the source to the server for clients to use mySource.Deploy("serverSource"); // Compose a QUERY over the source (return events with severity 20 or higher) var myQuery = from e in mySource where e.EventDataPayload.Severity >= 20 select e; // DEFINE a simple observer SINK (writes the value to the server console) var mySink = myApp.DefineObserver(() => Observer.Create<AENotificationPayload>( payload => Console.WriteLine("sink_Server..: {0}", payload))); // DEPLOY the sink to the server for clients to use mySink.Deploy("serverSink"); // BIND the query to the sink and RUN it var binding = myQuery.Bind(mySink); Debug.Assert(binding != null); using (/*var proc = */binding.Run("serverProcess")) { // Wait for the user stops the server Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine("MyStreamInsightServer is running, press Enter to stop the server"); Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine(" "); Console.ReadLine(); } host.Close(); } } } }
System.Object
OpcLabs.EasyOpc.AlarmsAndEvents.ComplexEventProcessing.AEEventDataPayload
Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2012, Windows Server 2016; .NET Core, .NET 5, .NET 6: Linux, macOS, Microsoft Windows