public static void CallbackLambda() { // Instantiate the client object var easyAEClient = new EasyAEClient(); Console.WriteLine("Subscribing..."); // The callback is a lambda expression the displays the event message easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, (sender, eventArgs) => { Debug.Assert(eventArgs != null); if (eventArgs.EventData != null) { Console.WriteLine(eventArgs.EventData.Message); } }); Console.WriteLine("Processing event notifications for 20 seconds..."); Thread.Sleep(20 * 1000); Console.WriteLine("Unsubscribing..."); easyAEClient.UnsubscribeAllEvents(); Console.WriteLine("Waiting for 2 seconds..."); Thread.Sleep(2 * 1000); }
public static void Main1() { var easyAEClient = new EasyAEClient(); AECategoryElementCollection categoryElements = easyAEClient.QueryEventCategories("", "AutoJet.ACPFileServerAE.1"); foreach (AECategoryElement categoryElement in categoryElements) { Debug.Assert(categoryElement != null); Debug.Assert(categoryElement.AttributeElements.Keys != null); Debug.Assert(categoryElement.ConditionElements.Keys != null); Console.WriteLine("Information about category {0}:", categoryElement); Console.WriteLine(" .CategoryId: {0}", categoryElement.CategoryId); Console.WriteLine(" .Description: {0}", categoryElement.Description); Console.WriteLine(" .ConditionElements:"); foreach (string conditionKey in categoryElement.ConditionElements.Keys) { Console.WriteLine(" {0}", conditionKey); } Console.WriteLine(" .AttributeElements:"); foreach (long attributeKey in categoryElement.AttributeElements.Keys) { Console.WriteLine(" {0}", attributeKey); } } }
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 easyAEClient = new EasyAEClient(); AECategoryElementCollection categoryElements = easyAEClient.QueryEventCategories("", "OPCLabs.KitEventServer.2"); foreach (AECategoryElement categoryElement in categoryElements) { Debug.Assert(categoryElement != null); Console.WriteLine("CategoryElements[\"{0}\"].Description: {1}", categoryElement.CategoryId, categoryElement.Description); } }
public static void Main1() { var easyAEClient = new EasyAEClient(); ServerElementCollection serverElements = easyAEClient.BrowseServers(""); foreach (ServerElement serverElement in serverElements) { Debug.Assert(serverElement != null); Console.WriteLine("serverElements[\"{0}\"].ProgId: {1}", serverElement.Clsid, serverElement.ProgId); } }
public static void Main1() { var easyAEClient = new EasyAEClient(); AEConditionElementCollection conditionElements = easyAEClient.QuerySourceConditions( "", "OPCLabs.KitEventServer.2", "Simulation.ConditionState1"); foreach (AEConditionElement conditionElement in conditionElements) { Debug.Assert(conditionElement != null); Console.WriteLine("ConditionElements[\"{0}\"]: {1} subcondition(s)", conditionElement.Name, conditionElement.SubconditionNames.Length); } }
public static void Main1() { var easyAEClient = new EasyAEClient(); AENodeElementCollection nodeElements = easyAEClient.BrowseAreas("", "AutoJet.ACPFileServerAE.1", ""); foreach (AENodeElement nodeElement in nodeElements) { Debug.Assert(nodeElement != null); Console.WriteLine("nodeElements[\"{0}\"]:", nodeElement.Name); Console.WriteLine(" .QualifiedName: {0}", nodeElement.QualifiedName); } }
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() { var easyAEClient = new EasyAEClient(); AEConditionState conditionState = easyAEClient.GetConditionState("", "OPCLabs.KitEventServer.2", "Simulation.ConditionState1", "Simulated"); Console.WriteLine("ConditionState:"); Console.WriteLine(" .ActiveSubcondition: {0}", conditionState.ActiveSubcondition); Console.WriteLine(" .Enabled: {0}", conditionState.Enabled); Console.WriteLine(" .Active: {0}", conditionState.Active); Console.WriteLine(" .Acknowledged: {0}", conditionState.Acknowledged); Console.WriteLine(" .Quality: {0}", conditionState.Quality); // Remark: IAEConditionState has many more properties }
public static void Main1() { var easyAEClient = new EasyAEClient(); //AENodeElementCollection nodeElements = easyAEClient.BrowseSources("", "OPCLabs.KitEventServer.2", "Simulation"); AENodeElementCollection nodeElements = easyAEClient.BrowseSources("", "AutoJet.ACPFileServerAE.1", "AI1 sensor fault"); foreach (AENodeElement nodeElement in nodeElements) { Debug.Assert(nodeElement != null); Console.WriteLine("nodeElements[\"{0}\"]:", nodeElement.Name); Console.WriteLine(" .QualifiedName: {0}", nodeElement.QualifiedName); } }
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..."); easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing..."); easyAEClient.UnsubscribeAllEvents(); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); } }
public static void Main1() { var easyAEClient = new EasyAEClient(); AECategoryElementCollection categoryElements = easyAEClient.QueryEventCategories("", "AutoJet.ACPFileServerAE.1"); foreach (AECategoryElement categoryElement in categoryElements) { Debug.Assert(categoryElement != null); Console.WriteLine("Category {0}:", categoryElement); foreach (AEConditionElement conditionElement in categoryElement.ConditionElements) { Debug.Assert(conditionElement != null); Console.WriteLine(" Information about condition \"{0}\":", conditionElement); Console.WriteLine(" .Name: {0}", conditionElement.Name); Console.WriteLine(" .SubconditionNames:"); DumpSubconditionNames(conditionElement.SubconditionNames); } } }
public static void Main1() { var easyAEClient = new EasyAEClient(); AECategoryElementCollection categoryElements = easyAEClient.QueryEventCategories("", "AutoJet.ACPFileServerAE.1"); foreach (AECategoryElement categoryElement in categoryElements) { Debug.Assert(categoryElement != null); Console.WriteLine("Category {0}:", categoryElement); foreach (AEAttributeElement attributeElement in categoryElement.AttributeElements) { Debug.Assert(attributeElement != null); Console.WriteLine(" Information about attribute {0}:", attributeElement); Console.WriteLine(" .AttributeId: {0}", attributeElement.AttributeId); Console.WriteLine(" .Description: {0}", attributeElement.Description); Console.WriteLine(" .DataType: {0}", attributeElement.DataType); } } }
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", 500); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Changing subscription..."); easyAEClient.ChangeEventSubscription(handle, 5 * 1000); Console.WriteLine("Waiting for 50 seconds..."); Thread.Sleep(50 * 1000); easyAEClient.UnsubscribeEvents(handle); } }