コード例 #1
0
            public static void Main1()
            {
                // Instantiate the client object and hook events
                var easyUAClient = new EasyUAClient();

                easyUAClient.DataChangeNotification += easyUAClient_DataChangeNotification;

                Console.WriteLine("Subscribing...");
                int[] handleArray = easyUAClient.SubscribeMultipleMonitoredItems(new[]
                {
                    new EasyUAMonitoredItemArguments(null, "http://opcua.demo-this.com:51211/UA/SampleServer",
                                                     "nsu=http://test.org/UA/Data/;i=10845", 1000),
                    new EasyUAMonitoredItemArguments(null, "http://opcua.demo-this.com:51211/UA/SampleServer",
                                                     "nsu=http://test.org/UA/Data/;i=10853", 1000),
                    new EasyUAMonitoredItemArguments(null, "http://opcua.demo-this.com:51211/UA/SampleServer",
                                                     "nsu=http://test.org/UA/Data/;i=10855", 1000)
                });

                Console.WriteLine("Getting monitored item arguments...");
                EasyUAMonitoredItemArguments monitoredItemArguments =
                    easyUAClient.GetMonitoredItemArguments(handleArray[2]);

                Console.WriteLine("NodeDescriptor: {0}", monitoredItemArguments.NodeDescriptor);
                Console.WriteLine("SamplingInterval: {0}", monitoredItemArguments.MonitoringParameters.SamplingInterval);
                Console.WriteLine("PublishingInterval: {0}", monitoredItemArguments.SubscriptionParameters.PublishingInterval);

                Console.WriteLine("Waiting for 5 seconds...");
                System.Threading.Thread.Sleep(5 * 1000);

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

                Console.WriteLine("Waiting for 5 seconds...");
                System.Threading.Thread.Sleep(5 * 1000);
            }
コード例 #2
0
        public List<EasyUAMonitoredItemArguments> readConf(String[] args)
        {
            var lines = File.ReadLines(args[0]).Select(a => a.Split(';'));
            var csv = from line in lines
                      select (from piece in line
                              select piece);
            //Build a list of the nodeId's
            List<EasyUAMonitoredItemArguments> nodeList = new List<EasyUAMonitoredItemArguments>();
            foreach (var item in csv) {
                UANodeId nid = new UANodeId("ns=2;s=" + item.ToArray<String>()[0] + "." + item.ToArray<String>()[1] + "." + item.ToArray<String>()[2]);
                UAEndpointDescriptor ud = new UAEndpointDescriptor("opc.tcp://test-opc-ua.powerhub.dk:32402");

                EasyUAMonitoredItemArguments euia = new EasyUAMonitoredItemArguments(null, ud, nid);

                nodeList.Add(euia);
            }

            return nodeList;
        }
コード例 #3
0
        public List <EasyUAMonitoredItemArguments> readConf(String[] args)
        {
            var lines = File.ReadLines(args[0]).Select(a => a.Split(';'));
            var csv   = from line in lines
                        select(from piece in line
                               select piece);

            //Build a list of the nodeId's
            List <EasyUAMonitoredItemArguments> nodeList = new List <EasyUAMonitoredItemArguments>();

            foreach (var item in csv)
            {
                UANodeId             nid = new UANodeId("ns=2;s=" + item.ToArray <String>()[0] + "." + item.ToArray <String>()[1] + "." + item.ToArray <String>()[2]);
                UAEndpointDescriptor ud  = new UAEndpointDescriptor("opc.tcp://test-opc-ua.powerhub.dk:32402");

                EasyUAMonitoredItemArguments euia = new EasyUAMonitoredItemArguments(null, ud, nid);

                nodeList.Add(euia);
            }

            return(nodeList);
        }