Beispiel #1
0
        private static void Main(string[] args)
        {
            Control = new PiControl();
            Control.Open();
            Config = new PiConfiguration();
            Config.Open();

            var hostUrl = args.Length > 1 ? args[1] : "http://*:8000";
            var server  = WebApp.Start <Startup>(hostUrl);

            Trace.TraceInformation($"RevPi Variable Server running on {hostUrl}");

            var terminate = new AutoResetEvent(false);

            Console.CancelKeyPress += (sender, eventArgs) => { terminate.Set(); };
            terminate.WaitOne();

            Trace.TraceInformation("Terminating RevPi Variable Server");
            server.Dispose();
        }
Beispiel #2
0
        public void OpenConfigFileShouldSucceed()
        {
            var opened = _configuration.Open();

            Assert.IsTrue(opened);
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            Trace.Listeners.Add(new ConsoleTraceListener(false));

            if (args.Length == 0 || args.Any(a => new Regex(@"^-[\?hH]$").IsMatch(a)))
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                var fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
                Console.WriteLine($"PiTest V{fileVersionInfo.FileVersion}");
                Console.WriteLine(" -s               Display system state");
                Console.WriteLine(" -d               Get device list");
                Console.WriteLine(" -v <varName>     Get variable info");
                Console.WriteLine(" -r <varName>     Read variable");
                Console.WriteLine(" -y <led> <color> Set system LED (1/2) to color");
                Console.WriteLine("                    r - red, g - green, o - orange, x - off");
                Environment.Exit(0);
            }

            var control = new PiControl();

            if (!control.Open())
            {
                Console.WriteLine("Could not open PiControl.");
                Environment.Exit(1);
            }

            var config = new PiConfiguration();

            if (!config.Open())
            {
                Console.WriteLine("Could not open PiConfiguration.");
                Environment.Exit(2);
            }

            var leds = new RevPiLeds(control, config);

            string name = (args.Length >= 2) ? args[1] : string.Empty;

            switch (args[0])
            {
            case "-x":
                Console.WriteLine("Resetting driver");
                control.Reset();
                break;

            case "-d":
                ListDevices(config);
                break;

            case "-s":
                ShowSystemState(config, control);
                break;

            case "-v":
                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine("Missing parameter <varName>.");
                    Environment.Exit(3);
                }
                ShowVarInfo(config, name);
                break;

            case "-r":
                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine("Missing parameter <varName>.");
                    Environment.Exit(3);
                }
                ReadVarValue(config, control, name);
                break;

            case "-y":
                int.TryParse((args.Length >= 2) ? args[1] : string.Empty, out var led);
                var color = (args.Length >= 3) ? args[2] : string.Empty;
                if ((led < 1) || (led > 2) || string.IsNullOrEmpty(color))
                {
                    Console.WriteLine("Missing parameter(s) <led> <color>.");
                    Environment.Exit(3);
                }
                SetLed(leds, led, color);
                break;
            }

            control.Close();
            Environment.Exit(0);
        }