Esempio n. 1
0
 private static void Shutdown()
 {
     _shutingDown = true;
     _controller.ChangeColorForAreas(new System.Collections.Generic.List <LedCommand> {
         new LedCommand {
             AreaId = -1, NewColor = Color.FromArgb(0, 0, 0, 0)
         }
     });
     Thread.Sleep(500);
     _controller.Shutdown();
 }
Esempio n. 2
0
        public static void Run(string[] args)
        {
            int waitTimeOut = 0;

            while ((_controller?.IsInitialized() == false) && (waitTimeOut < 5000))//We will wait for ¿5? seconds to get all things initialized, if we take more time the command will be discarded.
            {
                Thread.Sleep(100);
                waitTimeOut += 100;
            }

            var _ledCommands = CommandLineParser.GetLedCommands(args);

            if (_ledCommands.Count > 0)
            {
                if (_transaction.TransactioStarted)
                {
                    _transaction.TransactionSetZoned(_ledCommands);
                    return;
                }
                _controller?.ChangeColorForAreas(_ledCommands);
                return;
            }

            int traxMaxAlive = CommandLineParser.GetTransactionStartCommand(args);

            if (traxMaxAlive > -1)
            {
                _transaction.TransactionStart(traxMaxAlive);
                return;
            }

            if (CommandLineParser.GetTransactionCommitCommand(args))
            {
                try

                {
                    _transaction.TransactionCommit();
                }
                catch //No transaction started
                { }
            }

            if (CommandLineParser.GetTransactionCancel(args))
            {
                _transaction.TransactionCancel();
                return;
            }

            if (CommandLineParser.GeShutdownCommand(args))
            {
                //Shutdown this shit
                Run(new string[] { "--sa:-1:0:0:0:0" });
                Thread.Sleep(500);
                _controller.Shutdown();
                Thread.Sleep(500);
            }

            int _profileCommandIndex = CommandLineParser.LoadProfileCommand(args);

            if (_profileCommandIndex > 0)
            {
                _controller?.LoadProfile(_profileCommandIndex);
            }
            else if (CommandLineParser.GetAreasCommand(args))
            {
                MessageBox.Show(_controller?.GetAreasReport());
            }
        }