示例#1
0
        private async Task DoSolve(ushort[] pixels, int width, int height)
        {
            var result = await PlateSolve.Solve(pixels, width, height);

            if (result.HasValue)
            {
                var(ra, dec) = result.Value;
                Console.WriteLine("Solved position (degrees):");
                Console.WriteLine($"{ra.Degrees}d {dec.Degrees}d");
                Console.WriteLine("Solved position (dms):");
                Console.WriteLine($"{ra.ToDmsString(Dms.Unit.Degrees)} {dec.ToDmsString(Dms.Unit.Degrees)}");
                Console.WriteLine("Solved position (hms/dms):");
                Console.WriteLine($"{ra.ToDmsString(Dms.Unit.Hours)} {dec.ToDmsString(Dms.Unit.Degrees)}");
            }
            else
            {
                Console.WriteLine("Failed to solve");
            }
        }
示例#2
0
        private static async Task ReplMount(string[] cmd, Mount mount)
        {
            switch (cmd[0])
            {
            case "help":
                Console.WriteLine("slew [ra] [dec] - slew to direction");
                Console.WriteLine("slewra [ra] - slow goto");
                Console.WriteLine("slewdec [dec] - slow goto");
                Console.WriteLine("cancel - cancel slew");
                Console.WriteLine("pos - get current direction");
                Console.WriteLine("setpos - overwrite current direction");
                Console.WriteLine("syncpos - sync/calibrate current direction");
                Console.WriteLine("azalt - get current az/alt");
                Console.WriteLine("azalt [az] [alt] - slew to az/alt");
                Console.WriteLine("track - get tracking mode");
                Console.WriteLine("track [value] - set tracking mode");
                Console.WriteLine("location - get lat/lon");
                Console.WriteLine("location [lat] [lon] - set lat/lon");
                Console.WriteLine("time - get mount's time");
                Console.WriteLine("time now - set mount's time to now");
                Console.WriteLine("aligned - get true/false if mount is aligned");
                Console.WriteLine("ping - ping mount, prints time it took");
                Console.WriteLine("solve [filename] - plate-solve image with ANSVR");
                break;

            case "slew":
            {
                cmd[1] = cmd[1].TrimEnd(',');
                if (cmd.Length == 3 && Dms.TryParse(cmd[1], out var ra) && Dms.TryParse(cmd[2], out var dec))
                {
                    await mount.Slew(ra, dec);
                }
                else
                {
                    goto default;
                }
            }
            break;

            case "slewra":
            {
                if (cmd.Length == 2 && Dms.TryParse(cmd[1], out var ra))
                {
                    await mount.SlowGotoRA(ra);
                }
                else
                {
                    goto default;
                }
            }
            break;

            case "slewdec":
            {
                if (cmd.Length == 2 && Dms.TryParse(cmd[1], out var ra))
                {
                    await mount.SlowGotoDec(ra);
                }
                else
                {
                    goto default;
                }
            }
            break;

            case "cancel":
                await mount.CancelSlew();

                break;

            case "pos":
            {
                var(ra, dec) = await mount.GetRaDec();

                Console.WriteLine($"{ra.ToDmsString(Dms.Unit.Hours)}, {dec.ToDmsString(Dms.Unit.Degrees)}");
            }
            break;

            case "setpos":
            {
                cmd[1] = cmd[1].TrimEnd(',');
                if (cmd.Length == 3 && Dms.TryParse(cmd[1], out var ra) && Dms.TryParse(cmd[2], out var dec))
                {
                    await mount.ResetRA(ra);

                    await mount.ResetDec(dec);
                }
                else
                {
                    goto default;
                }
            }
            break;

            case "syncpos":
            {
                cmd[1] = cmd[1].TrimEnd(',');
                if (cmd.Length == 3 && Dms.TryParse(cmd[1], out var ra) && Dms.TryParse(cmd[2], out var dec))
                {
                    await mount.OverwriteRaDec(ra, dec);
                }
                else
                {
                    goto default;
                }
            }
            break;

            case "azalt":
                if (cmd.Length == 1)
                {
                    var(az, alt) = await mount.GetAzAlt();

                    Console.WriteLine($"{az.ToDmsString(Dms.Unit.Degrees)}, {alt.ToDmsString(Dms.Unit.Degrees)}");
                }
                else if (cmd.Length == 3 && Dms.TryParse(cmd[1], out var az) && Dms.TryParse(cmd[2], out var alt))
                {
                    await mount.SlewAzAlt(az, alt);
                }
                else
                {
                    goto default;
                }
                break;

            case "track":
                if (cmd.Length == 1)
                {
                    var track = await mount.GetTrackingMode();

                    Console.WriteLine($"Mode: {track}");
                    Console.WriteLine($"(available: {string.Join(", ", (Mount.TrackingMode[])Enum.GetValues(typeof(Mount.TrackingMode)))})");
                }
                else if (cmd.Length == 2 && Enum.TryParse <Mount.TrackingMode>(cmd[1], out var mode))
                {
                    await mount.SetTrackingMode(mode);
                }
                else
                {
                    goto default;
                }
                break;

            case "location":
                if (cmd.Length == 1)
                {
                    var(lat, lon) = await mount.GetLocation();

                    Console.WriteLine($"{lat.ToDmsString(Dms.Unit.Degrees)}, {lon.ToDmsString(Dms.Unit.Degrees)}");
                }
                else if (cmd.Length == 3 && Dms.TryParse(cmd[1], out var lat) && Dms.TryParse(cmd[2], out var lon))
                {
                    await mount.SetLocation(lat, lon);
                }
                else
                {
                    goto default;
                }
                break;

            case "time":
                if (cmd.Length == 1)
                {
                    var now_one = DateTime.Now;
                    var time    = await mount.GetTime();

                    Console.WriteLine($"Mount time: {time} (off by {now_one - time})");
                }
                else if (cmd.Length == 2 && cmd[1] == "now")
                {
                    await mount.SetTime(DateTime.Now);
                }
                else
                {
                    goto default;
                }
                break;

            case "aligned":
            {
                var aligned = await mount.IsAligned();

                Console.WriteLine($"IsAligned: {aligned}");
            }
            break;

            case "ping":
            {
                var timer = Stopwatch.StartNew();
                var res   = await mount.Echo('p');

                Console.WriteLine($"{timer.ElapsedMilliseconds}ms");
            }
            break;

            case "solve":
                if (cmd.Length == 2)
                {
                    var task = PlateSolve.SolveFile(cmd[1]);
                }
                else
                {
                    goto default;
                }
                break;

            default:
                Console.WriteLine($"Unknown command {string.Join(" ", cmd)}");
                break;
            }
        }
示例#3
0
        private static void ReplCamera(string[] cmd, QhyCcd camera, ref CameraDisplay cameraDisplay)
        {
            switch (cmd[0])
            {
            case "help":
                Console.WriteLine("open - runs display");
                Console.WriteLine("save - saves image");
                Console.WriteLine("save [n] - saves next n images");
                Console.WriteLine("solve - plate-solve next image with ANSVR");
                Console.WriteLine("solve [filename] - plate-solve image with ANSVR");
                Console.WriteLine("controls - prints all controls");
                Console.WriteLine("[control name] - prints single control");
                Console.WriteLine("[control name] [value] - set control value");
                break;

            case "open":
                cameraDisplay = new CameraDisplay(camera);
                cameraDisplay.Start();
                break;

            case "save":
                if (cmd.Length == 1)
                {
                    cameraDisplay.Save(1);
                }
                else if (cmd.Length == 2 && int.TryParse(cmd[1], out var numToSave))
                {
                    cameraDisplay.Save(numToSave);
                }
                else
                {
                    goto default;
                }
                break;

            case "solve":
                if (cmd.Length == 1)
                {
                    cameraDisplay.Solve();
                }
                else if (cmd.Length == 2)
                {
                    var task = PlateSolve.SolveFile(cmd[1]);
                    Console.WriteLine("TODO");
                }
                else
                {
                    goto default;
                }
                break;

            case "controls":
            {
                foreach (var control in camera.Controls)
                {
                    Console.WriteLine(control.ToString());
                }
            }
            break;

            default:
            {
                var control = camera.Controls.SingleOrDefault(x => x.Name == cmd[0]);
                if (control != null && cmd.Length == 1)
                {
                    Console.WriteLine(control.ToString());
                    break;
                }
                else if (control != null && cmd.Length == 2 && double.TryParse(cmd[1], out var value))
                {
                    control.Value = value;
                    break;
                }
                Console.WriteLine($"Unknown command {string.Join(" ", cmd)}");
            }
            break;
            }
        }