コード例 #1
0
            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 UAEventFilterBuilder(
                        // Either the severity is >= 500, or the event comes from a specified source node
                        UAFilterElements.Or(
                            UAFilterElements.GreaterThanOrEqual(UABaseEventObject.Operands.Severity, 500),
                            UAFilterElements.Equals(
                                UABaseEventObject.Operands.SourceNode,
                                new UANodeId("nsu=http://opcfoundation.org/Quickstarts/AlarmCondition;ns=2;s=1:Metals/SouthMotor"))),
                        UABaseEventObject.AllFields));

                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);
            }
コード例 #2
0
            public static void Events()
            {
                // Instantiate the client object and hook events
                var easyUAClient = new EasyUAClient();

                easyUAClient.EventNotification += easyUAClient_EventNotification;

                Console.WriteLine("Subscribing...");
                easyUAClient.SubscribeMultipleMonitoredItems(new[]
                {
                    new EasyUAMonitoredItemArguments("firstState",
                                                     "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer",
                                                     UAObjectIds.Server,
                                                     new UAMonitoringParameters(1000, new UAEventFilterBuilder(
                                                                                    UAFilterElements.GreaterThanOrEqual(UABaseEventObject.Operands.Severity, 500),
                                                                                    UABaseEventObject.AllFields)))
                    {
                        AttributeId = UAAttributeId.EventNotifier
                    },
                    new EasyUAMonitoredItemArguments("secondState",
                                                     "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer",
                                                     UAObjectIds.Server,
                                                     new UAMonitoringParameters(2000, new UAEventFilterBuilder(
                                                                                    UAFilterElements.Equals(
                                                                                        UABaseEventObject.Operands.SourceNode,
                                                                                        new UANodeId("nsu=http://opcfoundation.org/Quickstarts/AlarmCondition;ns=2;s=1:Metals/SouthMotor")),
                                                                                    UABaseEventObject.AllFields)))
                    {
                        AttributeId = UAAttributeId.EventNotifier
                    },
                });

                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);
            }