示例#1
0
        public async Task <bool> Dither(CancellationToken token)
        {
            if (Guider?.Connected == true)
            {
                try {
                    Guider.GuideEvent -= Guider_GuideEvent;
                    applicationStatusMediator.StatusUpdate(new Model.ApplicationStatus()
                    {
                        Status = Locale.Loc.Instance["LblDither"], Source = Title
                    });
                    GuideStepsHistory.AddDitherIndicator();
                    await Guider.Dither(token);
                } finally {
                    Guider.GuideEvent += Guider_GuideEvent;
                    applicationStatusMediator.StatusUpdate(new Model.ApplicationStatus()
                    {
                        Status = string.Empty, Source = Title
                    });
                }

                return(true);
            }
            else
            {
                await Disconnect();

                return(false);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            string host = "localhost";

            if (args.Length > 0)
            {
                host = args[0];
            }

            try
            {
                using (Guider guider = Guider.Factory(host))
                {
                    // connect to PHD2

                    guider.Connect();

                    // get the list of equipment profiles

                    foreach (var p in guider.GetEquipmentProfiles())
                    {
                        Console.WriteLine("profile: {0}", p);
                    }

                    // connect equipment in profile "Simulator"

                    string profile = "Simulator";
                    Console.WriteLine("connect profile {0}", profile);

                    guider.ConnectEquipment(profile);

                    // start guiding

                    double settlePixels  = 2.0;
                    double settleTime    = 10.0;
                    double settleTimeout = 100.0;

                    Console.WriteLine("guide");

                    guider.Guide(settlePixels, settleTime, settleTimeout);

                    // wait for settling to complete

                    WaitForSettleDone(guider);

                    // monitor guiding for a little while

                    for (int i = 0; i < 15; i++)
                    {
                        GuideStats stats = guider.GetStats();

                        string state;
                        double avgDist;
                        guider.GetStatus(out state, out avgDist);

                        Console.WriteLine("{0} dist={1:F1} rms={2:F1} ({3:F1}, {4:F1}) peak = {5:F1}, {6:F1}",
                                          state, avgDist,
                                          stats.rms_tot, stats.rms_ra, stats.rms_dec, stats.peak_ra, stats.peak_dec);

                        System.Threading.Thread.Sleep(1000);
                    }

                    // Pause/resume guiding

                    Console.WriteLine("pause for 5s");
                    guider.Pause();
                    System.Threading.Thread.Sleep(5000);
                    Console.WriteLine("un-pause");
                    guider.Unpause();

                    // dither

                    double ditherPixels = 3.0;

                    Console.WriteLine("dither");

                    guider.Dither(ditherPixels, settlePixels, settleTime, settleTimeout);

                    // wait for settle

                    WaitForSettleDone(guider);

                    // stop guiding

                    Console.WriteLine("stop\n");

                    guider.StopCapture();

                    // disconnect from PHD2 (optional in this case since we've got a using() block to take care of it)
                    guider.Close();
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("Error: {0}", err.Message);
            }
        }