public static void Main1() { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); EasyAEClient.Notification += eventHandler; Console.WriteLine("Processing event notifications..."); var subscriptionFilter = new AESubscriptionFilter { Sources = new AENodeDescriptor[] { "Simulation.ConditionState1", "Simulation.ConditionState2", "Simulation.ConditionState3" } }; int handle = EasyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter); // The component will perform auto-refresh at this point, give it time to happen Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); // Set some events to active state, which will cause them to appear in refresh Console.WriteLine("Activating conditions and waiting for 10 seconds..."); EasyDaClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.Activate", true); EasyDaClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState2.Activate", true); Thread.Sleep(10 * 1000); Console.WriteLine("Refreshing subscription and waiting for 10 seconds..."); EasyAEClient.RefreshEventSubscription(handle); Thread.Sleep(10 * 1000); EasyAEClient.UnsubscribeEvents(handle); }
public static void Main1() { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); EasyAEClient.Notification += eventHandler; Console.WriteLine("Processing event notifications..."); var subscriptionFilter = new AESubscriptionFilter { Sources = new AENodeDescriptor[] { "Simulation.ConditionState1", "Simulation.ConditionState3" } }; // You can also filter using event types, categories, severity, and areas. int handle = EasyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter); // Allow time for initial refresh Thread.Sleep(5 * 1000); // Set some events to active state. // The activation below will come from a source contained in a filter and the notification will arrive. EasyDaClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.Activate", true); // The activation below will come from a source that is not contained in a filter and the notification will not arrive. EasyDaClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState2.Activate", true); Thread.Sleep(10 * 1000); EasyAEClient.UnsubscribeEvents(handle); }
public static void FilterByCategories() { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification_FilterByCategories); EasyAEClient.Notification += eventHandler; Console.WriteLine("Processing event notifications..."); var subscriptionFilter = new AESubscriptionFilter { Categories = new long[] { 15531778 } }; // You can also filter using event types, severity, areas, and sources. int handle = EasyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter); // Allow time for initial refresh Thread.Sleep(5 * 1000); // Set some events to active state. EasyDaClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.Activate", true); EasyDaClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState2.Activate", true); Thread.Sleep(10 * 1000); EasyAEClient.UnsubscribeEvents(handle); }
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."); } }
public static void Main1() { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); EasyAEClient.Notification += eventHandler; Console.WriteLine("Processing event notifications for 1 minute..."); var subscriptionFilter = new AESubscriptionFilter { Sources = new AENodeDescriptor[] { "Simulation.ConditionState1" } }; int handle = EasyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter); // Give the refresh operation time to complete Thread.Sleep(5 * 1000); // Trigger an acknowledgeable event EasyDAClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.Activate", true); _done = false; DateTime endTime = DateTime.Now + new TimeSpan(0, 0, 5); while ((!_done) && (DateTime.Now < endTime)) { Thread.Sleep(1000); } // Give some time to also receive the acknowledgement notification Thread.Sleep(5 * 1000); EasyAEClient.UnsubscribeEvents(handle); }
public static void Main1() { var easyAEClient = new EasyAEClient(); // Browse for some areas and sources AENodeElementCollection areaElements = easyAEClient.BrowseAreas("", "SWToolbox.TOPServer_AE.V5", ""); foreach (AENodeElement areaElement in areaElements) { Debug.Assert(areaElement != null); Debug.Assert(areaElement.QualifiedName != null); Console.WriteLine("areaElements[\"{0}\"]:", areaElement.Name); Console.WriteLine(" .QualifiedName: {0}", areaElement.QualifiedName); AENodeElementCollection sourceElements = easyAEClient.BrowseSources("", "SWToolbox.TOPServer_AE.V5", areaElement.QualifiedName); foreach (AENodeElement sourceElement in sourceElements) { Debug.Assert(sourceElement != null); Console.WriteLine(" sourceElements[\"{0}\"]:", sourceElement.Name); Console.WriteLine(" .QualifiedName: {0}", sourceElement.QualifiedName); } } // Query for event categories AECategoryElementCollection categoryElements = easyAEClient.QueryEventCategories("", "SWToolbox.TOPServer_AE.V5"); foreach (AECategoryElement categoryElement in categoryElements) { Debug.Assert(categoryElement != null); Console.WriteLine("CategoryElements[\"{0}\"].Description: {1}", categoryElement.CategoryId, categoryElement.Description); } // Subscribe to events, wait, and unsubscribe var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); easyAEClient.Notification += eventHandler; int handle = easyAEClient.SubscribeEvents("", "SWToolbox.TOPServer_AE.V5", 1000); Console.WriteLine("Processing event notifications for 1 minute..."); Thread.Sleep(60 * 1000); easyAEClient.UnsubscribeEvents(handle); }
public static void Main1() { using (var easyAEClient = new EasyAEClient()) { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); easyAEClient.Notification += eventHandler; int handle = easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000); Console.WriteLine("Processing event notifications for 1 minute..."); Thread.Sleep(60 * 1000); easyAEClient.UnsubscribeEvents(handle); } }
public static void Main1() { var easyAEClient = new EasyAEClient(); var easyDAClient = new EasyDAClient(); var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); easyAEClient.Notification += eventHandler; // Inactivate the event condition (we will later activate it and receive the notification) easyDAClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.Inactivate", true); var subscriptionFilter = new AESubscriptionFilter { Sources = new AENodeDescriptor[] { "Simulation.ConditionState1" } }; // Prepare a dictionary holding requested event attributes for each event category // The event category IDs and event attribute IDs are hard-coded here, but can be obtained from the OPC // server by querying as well. var returnedAttributesByCategory = new AEAttributeSetDictionary(); returnedAttributesByCategory[0x00ECFF02] = new long[] { 0x00EB0003, 0x00EB0008 }; Console.WriteLine("Subscribing to events..."); int handle = easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter, returnedAttributesByCategory); // Give the refresh operation time to complete Thread.Sleep(5 * 1000); // Trigger an event carrying specified attributes (activate the condition) easyDAClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.AttributeValues.15400963", 123456); easyDAClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.AttributeValues.15400968", "Some string value"); easyDAClient.WriteItemValue("", "AutoJet.ACPFileServerAE.1", "SimulateEvents.ConditionState1.Activate", true); Console.WriteLine("Processing event notifications for 10 seconds..."); Thread.Sleep(10 * 1000); easyAEClient.UnsubscribeEvents(handle); }
public static void Main1() { using (var easyAEClient = new EasyAEClient()) { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); easyAEClient.Notification += eventHandler; Console.WriteLine("Subscribing..."); int handle = easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing..."); easyAEClient.UnsubscribeEvents(handle); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); } }