Exemplo n.º 1
0
        static void Main(string[] args)
        {
            QhyCcd        camera  = null;
            Mount         mount   = null;
            CameraDisplay display = null;

            while (true)
            {
                Console.Write("> ");
                Console.Out.Flush();
                var cmd = Console.ReadLine().Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                if (cmd.Length == 0)
                {
                    continue;
                }
                if (cmd[0] == "quit")
                {
                    break;
                }
                try
                {
                    if (camera != null)
                    {
                        ReplCamera(cmd, camera, ref display);
                    }
                    else if (mount != null)
                    {
                        ReplMount(cmd, mount).Wait();
                    }
                    else
                    {
                        ReplMain(cmd, ref camera, ref mount);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error processing command - {e.GetType().FullName}: {e.Message}");
                    Console.WriteLine(e.ToString());
                }
            }
            camera?.Dispose();
        }
Exemplo n.º 2
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;
            }
        }