Ejemplo n.º 1
0
        static async Task <bool> TestGyro()
        {
            Console.Clear();
            ConsoleOutput.Logo();
            Console.WriteLine("Press ESC to stop");
            int outputStart = Console.CursorTop + 1;

            do
            {
                var result = await SendCommand(":XL1#,#");

                while (!Console.KeyAvailable)
                {
                    Console.CursorTop  = outputStart;
                    Console.CursorLeft = 0;
                    Console.WriteLine("********* GYRO TEST **************");
                    ConsoleOutput.ClearRestOfScreen();
                    Console.CursorTop = outputStart;
                    await SendCommand(":XLGC#,#");

                    await Task.Delay(250);
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);

            await SendCommand(":XL0#,#");

            _commHandler.Disconnect();
            _commHandler = null;
            await Task.Delay(250);

            return(true);
        }
Ejemplo n.º 2
0
        static async Task <bool> TestGPS()
        {
            Console.Clear();
            ConsoleOutput.Logo();
            Console.WriteLine("********* GPS TEST ***************\r");
            Console.WriteLine("* Battery may need to be charged *\r");
            Console.WriteLine("* first time GPS is used ~30min  *\r");
            Console.WriteLine("* 0 = No satelites found         *\r");
            Console.WriteLine("* 1 = Satelites found            *\r");
            Console.WriteLine("**********************************\r");
            Console.WriteLine("Press ESC to stop");
            int outputStart = Console.CursorTop + 1;

            do
            {
                while (!Console.KeyAvailable)
                {
                    Console.CursorTop  = outputStart;
                    Console.CursorLeft = 0;
                    ConsoleOutput.ClearRestOfScreen();
                    var result = await SendCommand(":gT100#,n");

                    if (result.Data == "1")
                    {
                        result = await SendCommand(":Gt#,#");

                        var   latitudeArray = result.Data.Split('*');
                        float latitude      = float.Parse(latitudeArray[0], _oatCulture) + (float.Parse(latitudeArray[1], _oatCulture) / 60.0f);
                        await Task.Delay(250);

                        result = await SendCommand(":Gg#,#");

                        var   longitudeArray = result.Data.Split('*');
                        float longitude      = float.Parse(longitudeArray[0], _oatCulture) + (float.Parse(longitudeArray[1], _oatCulture) / 60.0f);
                        if (longitude > 180)
                        {
                            longitude -= 360;
                        }
                        await Task.Delay(250);

                        ConsoleOutput.Error(string.Format("Lat: {0}", latitude));
                        ConsoleOutput.Error(string.Format("Lon: {0}", longitude));
                    }

                    //Console.WriteLine("ESC - Exit\n");
                    await Task.Delay(1000);
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);


            _commHandler.Disconnect();
            _commHandler = null;

            Console.ReadKey();
            return(true);
        }
Ejemplo n.º 3
0
        static async Task <bool> CreateCommHandler(string device)
        {
            var tempCon = ConnectToDevice(device);

            if (tempCon == null)
            {
                return(true);
            }

            _commHandler              = tempCon;
            _commHandler.ReadTimeout  = _readTimeout;
            _commHandler.WriteTimeout = _writeTimeout;
            _commHandler.BaudRate     = _baudRate;

            await SendCommand(":I#,");

            var versionResponse = await SendCommand(":GVN#,#");

            _firmwareVersion = 1000;
            if (versionResponse.Success)
            {
                _oatFwVersion = versionResponse.Data;

                var versionNumbers = _oatFwVersion.Substring(1).Split(".".ToCharArray());
                if (versionNumbers.Length != 3)
                {
                    ConsoleOutput.Error(string.Format("Unrecognizable firmware version '{0}'", _oatFwVersion));
                }
                else
                {
                    try
                    {
                        _firmwareVersion = long.Parse(versionNumbers[0]) * 10000L + long.Parse(versionNumbers[1]) * 100L + long.Parse(versionNumbers[2]);
                    }
                    catch
                    {
                        ConsoleOutput.Error(string.Format("Unparseable firmware version '{0}'", _oatFwVersion));
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        static async Task CustomCommand()
        {
            // Console.Clear();
            string userChoice = "";

            Console.ForegroundColor = ConsoleOutput.menuColor;
            Console.WriteLine("---------------------------\r");
            Console.WriteLine("  OAT Communication Test\r");
            Console.WriteLine("      Custom Command\r");
            Console.WriteLine("---------------------------\r");
            Console.WriteLine("[ 0 ] Return to Main Menu\n");
            Console.WriteLine("Enter MEADE Command, examples: \r");
            Console.WriteLine(":GX#,#> - for a full reply\r");
            Console.WriteLine(":SG+01#,n - single digit reply\r");
            Console.WriteLine(":Qn#, - when no reply\r");
            Console.ResetColor();

            while (true)
            {
                userChoice = Console.ReadLine();

                switch (userChoice)
                {
                case "0":
                    _commHandler.Disconnect();
                    _commHandler = null;
                    return;

                default:
                    Console.WriteLine("Sending command: {0}", userChoice);
                    await SendCommand(userChoice);

                    break;
                }
            }
        }
Ejemplo n.º 5
0
        static async Task <bool> StartTest()
        {
            Dictionary <string, string> keyValuePairs = new Dictionary <string, string>();

            keyValuePairs.Add("GVP#,#", "Product name");
            keyValuePairs.Add("GVN#,#", "Firmware version");
            keyValuePairs.Add("XGM#,#", "Mount configuration");
            keyValuePairs.Add("Gt#,#", "Site Latitude");
            keyValuePairs.Add("Gg#,#", "Site Longitude");
            keyValuePairs.Add("XGR#,#", "RA Steps");
            keyValuePairs.Add("XGD#,#", "DEC Steps");
            if (_firmwareVersion >= 10869)
            {
                keyValuePairs.Add("XGDL#,#", "DEC Limits");
            }
            keyValuePairs.Add("XGT#,#", "Tracking speed");
            keyValuePairs.Add("XGH#,#", "HA");
            keyValuePairs.Add("XGL#,#", "LST");
            keyValuePairs.Add("GC#,#", "Local date");
            keyValuePairs.Add("GL#,#", "Local time");
            keyValuePairs.Add("GG#,#", "UTC Offset");
            keyValuePairs.Add("XGN#,#", "Network settings");

            List <CommandResponse> replys = new List <CommandResponse>();

            foreach (var cmd in keyValuePairs)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("----- {0} -----\r", cmd.Value);
                Console.ResetColor();
                var result = await SendCommand(cmd.Key);

                if (!result.Success)
                {
                    Console.WriteLine("Press any key to return...");
                    Console.ReadKey();
                    return(false);
                }
                replys.Add(result);
            }

            // Disconnect
            _commHandler.Disconnect();
            _commHandler = null;

            // Print summery
            int cnt = 0;

            ConsoleOutput.Info("--------------------------------------- SUMMARY -----------------------------------------------------------\r");
            foreach (var cmd in keyValuePairs)
            {
                ConsoleOutput.Info(string.Format("| {0} | {1} |\r", cmd.Value.PadLeft(30), replys[cnt].Data.PadRight(70)));
                cnt++;
            }
            ConsoleOutput.Info("-----------------------------------------------------------------------------------------------------------\r");

            ConsoleOutput.Info("Press any key to return...");
            Console.ReadKey();

            return(true);
        }