public static void Main1()
            {
                // Instantiate the client object and hook events
                var easyUAClient = new EasyUAClient();

                easyUAClient.EventNotification += easyUAClient_EventNotification;

                Console.WriteLine("Subscribing...");
                easyUAClient.SubscribeEvent(
                    "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer",
                    UAObjectIds.Server,
                    1000,
                    new UAAttributeFieldCollection
                {
                    // Select specific fields using standard operand symbols
                    UABaseEventObject.Operands.NodeId,
                    UABaseEventObject.Operands.SourceNode,
                    UABaseEventObject.Operands.SourceName,
                    UABaseEventObject.Operands.Time,

                    // Select specific fields using an event type ID and a simple relative path
                    UAFilterElements.SimpleAttribute(UAObjectTypeIds.BaseEventType, "/Message"),
                    UAFilterElements.SimpleAttribute(UAObjectTypeIds.BaseEventType, "/Severity"),
                });

                Console.WriteLine("Processing event notifications for 30 seconds...");
                System.Threading.Thread.Sleep(30 * 1000);

                Console.WriteLine("Unsubscribing...");
                easyUAClient.UnsubscribeAllMonitoredItems();

                Console.WriteLine("Waiting for 5 seconds...");
                System.Threading.Thread.Sleep(5 * 1000);
            }
Example #2
0
            static void easyUAClient_EventNotification(object sender, EasyUAEventNotificationEventArgs e)
            {
                Console.WriteLine();

                // Display the event
                if (e.EventData == null)
                {
                    Console.WriteLine(e);
                    return;
                }
                Console.WriteLine("All fields:");
                foreach (KeyValuePair <UAAttributeField, ValueResult> pair in e.EventData.FieldResults)
                {
                    UAAttributeField attributeField = pair.Key;
                    ValueResult      valueResult    = pair.Value;
                    Console.WriteLine("  {0} -> {1}", attributeField, valueResult);
                }
                // Extracting a specific field using a standard operand symbol
                Console.WriteLine("Source name: {0}",
                                  e.EventData.FieldResults[UABaseEventObject.Operands.SourceName]);
                // Extracting a specific field using an event type ID and a simple relative path
                Console.WriteLine("Message: {0}",
                                  e.EventData.FieldResults[UAFilterElements.SimpleAttribute(UAObjectTypeIds.BaseEventType, "/Message")]);
            }