Ejemplo n.º 1
0
        private static void QueryDevice()
        {
            // Other system tests
            Console.WriteLine("Connecting...");
            zeitgeber.Connect();

            Console.Write("Connected to ");
            Console.WriteLine(zeitgeber.DeviceDescription);

            Console.WriteLine("Ping()");
            zeitgeber.Ping();

            //zeitgeber.SetLed(2, 1);

            Console.WriteLine("GetBatteryInfo()");
            var battery = zeitgeber.GetBatteryInfo();

            Console.WriteLine(String.Format("\tlevel: {0}%", battery.Level));
            Console.WriteLine(String.Format("\tvoltage: {0}mV", battery.Voltage));
            Console.WriteLine(String.Format("\tpower status: {0}", battery.PowerStatus));
            Console.WriteLine();

            Console.WriteLine("GetCpuInfo()");
            var cpu = zeitgeber.GetCpuInfo();

            Console.WriteLine(String.Format("\tsystick: {0}", cpu.systick));
            Console.WriteLine();

            Console.WriteLine("QueryDisplay()");
            var display = zeitgeber.QueryDisplay();

            Console.WriteLine(String.Format(
                                  "\tsize: {0}x{1}x{2}bpp ({3} bytes)",
                                  display.Width, display.Height, display.BitsPerPixel,
                                  display.Width * display.Height * (display.BitsPerPixel / 8)
                                  ));
            Console.WriteLine();

            zeitgeber.SetDateTime(DateTime.Now);

            Console.WriteLine("GetDateTime()");
            var dt = zeitgeber.GetDateTime();

            Console.WriteLine(dt.ToString());
            Console.WriteLine("Actual:");
            Console.WriteLine(DateTime.Now.ToString());
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        private void timerUpdate_Tick(object sender, EventArgs e)
        {
            // Automatic connection/disconnection
            if (zeitgeber.isConnected)
            {
                try
                {
                    zeitgeber.Ping();
                    UpdateDiagnostics();
                }
                catch (Exception ex)
                {
                    zeitgeber.isConnected = false;
                    lblConnected.Text     = "Not Connected";
                    listViewInfo.Enabled  = false;
                    groupBox1.Enabled     = false;
                }
            }
            else
            {
                try
                {
                    zeitgeber.Connect();

                    zeitgeber.Ping();

                    OnDeviceConnect();

                    lblConnected.Text    = "Connected";
                    listViewInfo.Enabled = true;
                    groupBox1.Enabled    = true;
                }
                catch (Exception ex)
                {
                    zeitgeber.isConnected = false;
                    // Couldn't connect
                }
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] argv)
        {
            try
            {
                args = new Args();
                opts = new OptionSet()
                {
                    { "h|help", v => args.showhelp = (v != null) },
                    { "v|verbose", v => args.verbose = (v != null) },
                };

                List <string> subargs = opts.Parse(argv);

                if (args.showhelp) // --help
                {
                    ShowHelp();
                    return;
                }

                // Un-named parameters
                if (subargs.Count < 1)
                {
                    Console.WriteLine("No action specified");
                    Console.WriteLine("");
                    ShowHelp();
                    return;
                }
                string action_str = subargs[0];
                try
                {
                    args.action = (CommandLineAction)Enum.Parse(typeof(CommandLineAction), action_str, true);
                }
                catch (System.ArgumentException e)
                {
                    throw new ZeitgeberException(String.Format("Invalid action '{0}'", action_str), e);
                }



                zeitgeber = new Zeitgeber();
                zeitgeber.Connect();

                if (args.verbose)
                {
                    Console.WriteLine(String.Format("Connected to '{0}'", zeitgeber.DeviceDescription));
                }

                switch (args.action)
                {
                case CommandLineAction.Ping:
                    PingDevice();
                    break;

                case CommandLineAction.Reset:
                    ResetDevice();
                    break;

                case CommandLineAction.Query:
                    QueryDevice();
                    break;

                case CommandLineAction.SyncTime:
                    SyncTime();
                    break;

                case CommandLineAction.Screenshot:
                    string filename = (subargs.Count >= 2) ? subargs[1] : "screenshot.png";
                    Screenshot(filename);
                    break;

                case CommandLineAction.Calendar:
                    CalendarSubCommand(subargs.Skip(1).ToArray());
                    break;

                default:
                    throw new NotImplementedException("The action is not yet implemented");
                }
            }
            catch (Exception e)
            {
                //Console.Error.WriteLine();
#if DEBUG
                Console.Error.WriteLine(e);
#else
                Console.Error.WriteLine("Error: " + e.Message);
#endif
                //Console.Error.WriteLine();
            }
            finally
            {
                Console.WriteLine("Done.");
#if DEBUG
                // Pause the console so we can see the output
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
#endif
            }
        }