示例#1
0
        /// <summary>
        /// Polls the powerFail-warning- (if enabled in configuration) and powerBack-signal.
        /// <para>Requires serial-mode</para>
        /// </summary>
        public void Poll()
        {
            CheckSettings();

            if (State != EUpsState.PowerOk)
            {
                Console.WriteLine("***Error: Strompi3 can't start monitoring");
                return;
            }

            if (!Port.IsOpen)
            {
                Port.Open();
            }
            while (State != EUpsState.ShutdownNow)
            {
                Thread.Sleep(PollDelayMilliSec);
                string data = String.Empty;
                try
                {
                    data = Port.ReadLine();
                }
                catch (TimeoutException) { }// ignore timeouts

                SwitchState(data);
            }

            Console.WriteLine($"Start Pi shutdown in 3 seconds...");
            Thread.Sleep(3000);
            Os.ShutDown();
        }