Exemplo n.º 1
0
        static void MainTest()
        {
            log4net.Config.XmlConfigurator.Configure();
            var journal = new Journal(LogManager.GetLogger("logger"));
            var factory = new SignalsFactory(journal, 502);


            var rv = new Signal("my.signal.one");

            rv.AddCalibrationPoint(2, 100.0f);
            rv.AddCalibrationPoint(50000, 65000.0f);

            //factory.AddUshort(new Signal("my.double.one"), 1);

            //factory.AddDiscreet(new Signal("my.signal.5"), 2, 5, false);
            //factory.AddDiscreet(new Signal("my.signal.6"), 2, 6, false);

            factory.Start();
            factory.PrintInfo();

            var i    = 0;
            var time = new Stopwatch();

            time.Start();
            while (i < 50000)
            {
                rv.Update(i++);
            }
            time.Stop();

            Console.WriteLine(time.ElapsedMilliseconds);
            Console.WriteLine("Enter Press");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main()
        {
            //ConfiguratorTest();


            log4net.Config.XmlConfigurator.Configure();
            var journal = new Journal(LogManager.GetLogger("logger"));
            var signals = new SignalsFactory(journal);

            var wago = new Coupler(journal, signals, "192.168.1.111");

            CouplerConfigurator.Init(wago);

            var local = new RemoteConsole(journal, signals, 5000);

            //var invertors = new InvertorsService(journal, signals, "COM7");
            //var invertors = new InvertorsService(journal, signals, "/dev/ttySP1");

            signals.PrintInfo();

            #region start
            //var tasklets = new List<ITask> { invertors, local, wago, signals };
            var tasklets = new List <ITask> {
                local, wago, signals
            };

            foreach (var task in tasklets)
            {
                task.Start();
            }
            #endregion


            #region test & dump
            {
                Thread.Sleep(500);
                //TestRelay(signals);

                TestKeyboard(signals);

                //signals.SensorInfo();
                //signals.OutputInfo();
            }
            #endregion

            while (true)
            {
                Thread.Sleep(100);
            }


            //using (new SystemContol(journal, invertors, signals))
            {
                //Console.WriteLine("press Enter to stop");
                //Console.ReadLine();
                while (true)
                {
                    Thread.Sleep(100);
                }
            }

            #region stop tasks
            tasklets.Reverse();
            foreach (var task in tasklets)
            {
                task.Stop();
            }
            #endregion
        }