Exemple #1
0
        private static void TestServer()
        {
            var sw = new Stopwatch();

            sw.Start();

            var app    = new DemoApplication();
            var server = new LibUA.Server.Master(app, 7718, 10, 30, 100, new DemoLogger());

            server.Start();

            sw.Stop();
            Console.WriteLine("Created and started server in {0} ms", sw.ElapsedMilliseconds.ToString("N3"));
            Console.WriteLine("opc.tcp://localhost:7718");

            var timer = new Timer(1000);

            timer.Elapsed += (sender, e) => { app.PlayRow(); };

            timer.Start();
            Console.ReadKey();
            timer.Stop();

            server.Stop();
        }
Exemple #2
0
        private static void TestServer()
        {
            var sw = new Stopwatch();

            sw.Start();
            try
            {
                var app    = new DemoApplication();
                var server = new LibUA.Server.Master(app, Types.TCPPortDefault, 10, 30, 100, new DemoLogger());
                server.Start();

                sw.Stop();
                Console.WriteLine("Created and started server in {0} ms", sw.ElapsedMilliseconds.ToString("N3"));

                var timer = new Timer(1000);
                timer.Elapsed += (sender, e) =>
                {
                    app.PlayRow();
                };

                timer.Start();
                Console.ReadKey();
                timer.Stop();

                server.Stop();
            }
            catch (OperationCanceledException ex)
            {
                Console.WriteLine(ex.Message);
                System.Threading.Thread.Sleep(3500);
            }
            catch (Exception gex)
            {
                Console.WriteLine(gex.ToString());
                System.Threading.Thread.Sleep(3500);
            }

            return;
        }