public void TestLights()
        {
            var deviceID = DelcomManager.GetDevices();

            if (deviceID != null && deviceID.Count > 0)
            {
                var device = DelcomManager.GetController(deviceID[0]);

                device.Off();
                device.SetColor(new DelcomLight(Colors.Green, Modes.On));
                device.SetColor(new DelcomLight(Colors.Red, Modes.On));
                device.SetColor(new DelcomLight(Colors.Yellow, Modes.On));

                device.SetColor(new DelcomLight(Colors.Green, Modes.Flash));
                device.SetColor(new DelcomLight(Colors.Red, Modes.Flash));
                device.SetColor(new DelcomLight(Colors.Yellow, Modes.Flash));

                device.SetColor(new DelcomLight(Colors.Green, Modes.Off));
                device.SetColor(new DelcomLight(Colors.Red, Modes.Off));
                device.SetColor(new DelcomLight(Colors.Yellow, Modes.Off));

                device.SetColor(new DelcomLight(Colors.Green, Modes.On), new DelcomLight(Colors.Red, Modes.On));
                device.SetColor(new DelcomLight(Colors.Green, Modes.On), new DelcomLight(Colors.Yellow, Modes.On));
                device.SetColor(new DelcomLight(Colors.Red, Modes.On), new DelcomLight(Colors.Yellow, Modes.On));

                device.SetColor(new DelcomLight(Colors.Green, Modes.Flash), new DelcomLight(Colors.Red, Modes.On));
                device.SetColor(new DelcomLight(Colors.Green, Modes.Flash), new DelcomLight(Colors.Yellow, Modes.On));
                device.SetColor(new DelcomLight(Colors.Red, Modes.Flash), new DelcomLight(Colors.Yellow, Modes.On));

                device.SetColor(new DelcomLight(Colors.Green, Modes.On), new DelcomLight(Colors.Red, Modes.Flash));
                device.SetColor(new DelcomLight(Colors.Green, Modes.On), new DelcomLight(Colors.Yellow, Modes.Flash));
                device.SetColor(new DelcomLight(Colors.Red, Modes.On), new DelcomLight(Colors.Yellow, Modes.Flash));

                device.Off();
            }
        }
예제 #2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void Main(string[] args)
        {
            InitialiseLogFile();
            FileLogger.Logger.LogInformation("BuildStatusMonitor Application Starting.");
            FileLogger.Logger.LogInformation("Current Directory is '{0}'", Directory.GetCurrentDirectory());
            FileLogger.Logger.LogInformation("Assembly Directory is '{0}'", Assembly.GetExecutingAssembly().Location);
            FileLogger.Logger.LogInformation("Logging the attached Delcom Lights.");
            foreach (var light in DelcomManager.GetDevices())
            {
                FileLogger.Logger.LogInformation(light);
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
            if (Environment.UserInteractive)
            {
                var parameter = string.Concat(args);
                try {
                    switch (parameter)
                    {
                    case "--install":
                        FileLogger.Logger.LogInformation("Installing Service.");
                        ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
                        break;

                    case "--uninstall":
                        FileLogger.Logger.LogInformation("UnInstalling Service.");
                        ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
                        break;

                    case "--run":
                        FileLogger.Logger.LogInformation("Running in Test Mode.");
                        var controller = new BuildStatusController();
                        controller.Initialise();
                        controller.PollMonitors();
                        controller.Finalise();
                        break;

                    case "--default":
                        FileLogger.Logger.LogInformation("Creating DEFAULT settings file.");
                        BuildStatusConfig.CreateDefaultConfigFile();
                        break;

                    default:
                        Console.WriteLine("BuildStatusMonitor");
                        Console.WriteLine("--install     To install as a service.");
                        Console.WriteLine("--uninstall   To uninstall the service.");
                        Console.WriteLine("--run         To execute a single poll/execution.");
                        Console.WriteLine("--default     To create a sample default config file.");
                        Console.WriteLine("");
                        Console.WriteLine("Attached Lights are:");
                        foreach (var light in DelcomManager.GetDevices())
                        {
                            Console.WriteLine(light);
                        }
                        break;
                    }
                }
                catch (Exception ex) {
                    FileLogger.Logger.LogError("Error starting the Application", ex);
                }
            }
            else
            {
                Run(new Program());
            }
            FileLogger.Logger.LogInformation("BuildStatusMonitor Application Finished.");
            FileLogger.Logger.Terminate();
        }