Ejemplo n.º 1
0
 // Notification event handler
 static void easyAEClient_Notification([NotNull] object sender, [NotNull] EasyAENotificationEventArgs e)
 {
     if (e.EventData != null)
     {
         Console.WriteLine(e.EventData.Message);
     }
 }
            public static void Main1()
            {
                // In order to use event pull, you must set a non-zero queue capacity upfront.
                using (var easyAEClient = new EasyAEClient {
                    PullNotificationQueueCapacity = 1000
                })
                {
                    Console.WriteLine("Subscribing events...");
                    int handle = easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000);

                    Console.WriteLine("Processing event notifications for 1 minute...");
                    int endTick = Environment.TickCount + 60 * 1000;
                    do
                    {
                        EasyAENotificationEventArgs eventArgs = easyAEClient.PullNotification(2 * 1000);
                        if (eventArgs != null)
                        {
                            // Handle the notification event
                            Console.WriteLine(eventArgs);
                        }
                    } while (Environment.TickCount < endTick);

                    Console.WriteLine("Unsubscribing events...");
                    easyAEClient.UnsubscribeEvents(handle);

                    Console.WriteLine("Finished.");
                }
            }
            // Notification event handler
            static void easyAEClient_Notification([NotNull] object sender, [NotNull] EasyAENotificationEventArgs e)
            {
                Console.WriteLine();
                Console.WriteLine("Refresh: {0}", e.Refresh);
                Console.WriteLine("RefreshComplete: {0}", e.RefreshComplete);
                AEEventData eventData = e.EventData;

                if (eventData != null)
                {
                    Console.WriteLine("Event.QualifiedSourceName: {0}", eventData.QualifiedSourceName);
                    Console.WriteLine("Event.Message: {0}", eventData.Message);
                    Console.WriteLine("Event.Active: {0}", eventData.Active);
                    Console.WriteLine("Event.Acknowledged: {0}", eventData.Acknowledged);
                    Console.WriteLine("Event.AcknowledgeRequired: {0}", eventData.AcknowledgeRequired);

                    if (eventData.AcknowledgeRequired)
                    {
                        Console.WriteLine(">>>>> ACKNOWLEDGING THIS EVENT");
                        EasyAEClient.AcknowledgeCondition("", "OPCLabs.KitEventServer.2", "Simulation.ConditionState1", "Simulated",
                                                          eventData.ActiveTime, eventData.Cookie);
                        Console.WriteLine(">>>>> EVENT ACKNOWLEDGED");
                        _done = true;
                    }
                }
            }
 // Notification event handler
 static void easyAEClient_Notification([NotNull] object sender, [NotNull] EasyAENotificationEventArgs e)
 {
     if (!e.Refresh && (e.EventData != null))
     {
         // Display all received event attribute IDs and their corresponding values
         Console.WriteLine("Event attribute count: {0}", e.EventData.AttributeValues.Count);
         foreach (KeyValuePair <long, object> pair in e.EventData.AttributeValues)
         {
             Console.WriteLine("    {0}: {1}", pair.Key, pair.Value);
         }
     }
 }
            // Notification event handler
            static void easyAEClient_Notification([NotNull] object sender, [NotNull] EasyAENotificationEventArgs e)
            {
                Console.WriteLine();
                Console.WriteLine("Refresh: {0}", e.Refresh);
                Console.WriteLine("RefreshComplete: {0}", e.RefreshComplete);
                AEEventData eventData = e.EventData;

                if (eventData != null)
                {
                    Console.WriteLine("Event.QualifiedSourceName: {0}", eventData.QualifiedSourceName);
                    Console.WriteLine("Event.Message: {0}", eventData.Message);
                    Console.WriteLine("Event.Active: {0}", eventData.Active);
                    Console.WriteLine("Event.Acknowledged: {0}", eventData.Acknowledged);
                }
            }
Ejemplo n.º 6
0
 // Notification event handler
 static void easyAEClient_Notification([NotNull] object sender, [NotNull] EasyAENotificationEventArgs e)
 {
     if (e.Exception != null)
     {
         Console.WriteLine("e.Exception.Message: {0}", e.Exception.Message);
     }
     if (e.Exception != null)
     {
         Console.WriteLine("e.Exception.Source: {0}", e.Exception.Source);
     }
     Console.WriteLine("e.Refresh: {0}", e.Refresh);
     Console.WriteLine("e.RefreshComplete: {0}", e.RefreshComplete);
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.QualifiedSourceName: {0}", e.EventData.QualifiedSourceName);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Time: {0}", e.EventData.Time);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Message: {0}", e.EventData.Message);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.EventType: {0}", e.EventData.EventType);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.CategoryId: {0}", e.EventData.CategoryId);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Severity: {0}", e.EventData.Severity);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.ConditionName: {0}", e.EventData.ConditionName);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.SubconditionName: {0}", e.EventData.SubconditionName);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Enabled: {0}", e.EventData.Enabled);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Active: {0}", e.EventData.Active);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Acknowledged: {0}", e.EventData.Acknowledged);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.Quality: {0}", e.EventData.Quality);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.AcknowledgeRequired: {0}", e.EventData.AcknowledgeRequired);
     }
     if (e.EventData != null)
     {
         Console.WriteLine("e.EventData.ActiveTime: {0}", e.EventData.ActiveTime);
     }
 }