Exemple #1
0
        /// <summary>
        /// Test discovery
        /// </summary>
        private static async Task TestOpcUaDiscoveryServiceAsync(string addressRanges,
                                                                 bool stress)
        {
            using (var logger = StackLogger.Create(ConsoleLogger.Create()))
                using (var client = new ClientServices(logger.Logger, new TestClientServicesConfig()))
                    using (var scanner = new DiscoveryServices(client, new ConsoleEmitter(),
                                                               logger.Logger)) {
                        var rand = new Random();
                        while (true)
                        {
                            var configuration = new DiscoveryConfigModel {
                                IdleTimeBetweenScans = TimeSpan.FromMilliseconds(1),
                                AddressRangesToScan  = addressRanges
                            };
                            await scanner.ConfigureAsync(DiscoveryMode.Scan, configuration);

                            await scanner.ScanAsync();

                            await Task.Delay(!stress?TimeSpan.FromMinutes(10) :
                                             TimeSpan.FromMilliseconds(rand.Next(0, 120000)));

                            logger.Logger.Information("Stopping discovery!");
                            await scanner.ConfigureAsync(DiscoveryMode.Off, null);

                            await scanner.ScanAsync();

                            if (!stress)
                            {
                                break;
                            }
                        }
                    }
        }
Exemple #2
0
 public void TestInitialize()
 {
     this.discoveryServices = new DiscoveryServices(Global.LogFactory.CreateLogger <DiscoveryServices>());
 }