Esempio n. 1
0
 public void PulseGuide(GuideDirections Direction, int Duration)
 {
     if (MyDriverType == 0)
     {
         MySSCamera.PulseGuide(Direction, Duration);
     }
     else
     {
         tl.LogMessage("PulseGuide", "Not implemented");
         throw new ASCOM.MethodNotImplementedException("PulseGuide");
     }
 }
Esempio n. 2
0
        public void PulseGuide(GuideDirections Direction, int Duration)
        {
            CheckConnected();
            if (!Platform.IsTracking)
            {
                throw new InvalidOperationException("cannot PulseGuide when platform is not tracking");
            }

            double ra = 0.0, dec = 0.0;

            switch (Direction)
            {
            case GuideDirections.guideEast: ra = (double)Duration; break;

            case GuideDirections.guideWest: ra = (double)-Duration; break;

            case GuideDirections.guideNorth: dec = (double)Duration; break;

            case GuideDirections.guideSouth: dec = (double)-Duration; break;
            }

            double st4ra, st4dec;

            TransformGuidePulse(ra, dec, out st4ra, out st4dec);

            // issue the RA pulse

            GuideDirections dir;

            if (st4ra >= 0.0)
            {
                dir = GuideDirections.guideEast;
            }
            else
            {
                dir = GuideDirections.guideWest;
            }

            int dur = (int)(Math.Abs(st4ra) + 0.5);

            if (dur > 0)
            {
                m_camera.PulseGuide(dir, dur);
                tl.LogMessage("TransformGuidePulse", String.Format("log: dir={0} dur={1} ms Tet={2:F3} sec", dir, dur, Platform.TrackingTimeElapsed));
                System.Threading.Thread.Sleep(dur + 10);
                Stopwatch stopwatch = Stopwatch.StartNew();
                while (m_camera.IsPulseGuiding)
                {
                    if (stopwatch.ElapsedMilliseconds > 5000 + dur)
                    {
                        throw new ASCOM.DriverException("timed-out waiting for pulse guide to complete");
                    }
                    System.Threading.Thread.Sleep(10);
                }
                tl.LogMessage("TransformGuidePulse", String.Format("log: dir={0} dur={1} ms Tet={2:F3} sec", dir, dur, Platform.TrackingTimeElapsed));
            }

            // issue the dec pulse

            if (st4dec >= 0.0)
            {
                dir = GuideDirections.guideNorth;
            }
            else
            {
                dir = GuideDirections.guideSouth;
            }

            dur = (int)(Math.Abs(st4dec) + 0.5);
            if (dur > 0)
            {
                m_camera.PulseGuide(dir, dur);
                tl.LogMessage("TransformGuidePulse", String.Format("log: dir={0} dur={1} ms Tet={2:F3} sec", dir, dur, Platform.TrackingTimeElapsed));
                System.Threading.Thread.Sleep(dur + 10);
                Stopwatch stopwatch = Stopwatch.StartNew();
                while (m_camera.IsPulseGuiding)
                {
                    if (stopwatch.ElapsedMilliseconds > 5000 + dur)
                    {
                        throw new ASCOM.DriverException("timed-out waiting for pulse guide to complete");
                    }
                    System.Threading.Thread.Sleep(10);
                }
                tl.LogMessage("TransformGuidePulse", String.Format("log: dir={0} dur={1} ms Tet={2:F3} sec", dir, dur, Platform.TrackingTimeElapsed));
            }

            // issue the resulting RA and Dec pulses by interleaving

            //GuideDirections ra_dir = st4ra >= 0.0 ? GuideDirections.guideEast : GuideDirections.guideWest;
            //GuideDirections dec_dir = st4dec >= 0.0 ? GuideDirections.guideNorth : GuideDirections.guideSouth;

            //int ra_tot = (int)(Math.Abs(st4ra) + 0.5);
            //int dec_tot = (int)(Math.Abs(st4dec) + 0.5);

            //const int nominal_pulse_ms = 500; // nominal pulse duration    TODO: make configurable?

            //int steps = Math.Max(1, Math.Min(ra_tot, dec_tot) / nominal_pulse_ms);

            //int ra_step = (ra_tot + steps - 1) / steps;
            //int dec_step = (dec_tot + steps - 1) / steps;
            //tl.LogMessage("Output", String.Format("log: ra_tot={0:F0} ms dec_tot={1:F0} ms ra_step={2:F0} ms dec_step={3:F0} ms", ra_tot, dec_tot, ra_step, dec_step));
            //while (ra_tot > 0 || dec_tot > 0)
            //{
            //{
            //int ra_dur = Math.Min(ra_step, ra_tot);
            //ra_tot -= ra_dur;

            //if (ra_dur > 0)
            //{
            //m_camera.PulseGuide(ra_dir, ra_dur);
            //tl.LogMessage("Output", String.Format("log: ra_dir={0:F0} ra_dur={1:F0} ms", ra_dir, ra_dur));
            //System.Threading.Thread.Sleep(ra_dur + 10);
            //Stopwatch stopwatch = Stopwatch.StartNew();
            //while (m_camera.IsPulseGuiding)
            //{
            //if (stopwatch.ElapsedMilliseconds > 5000 + ra_dur)
            //throw new ASCOM.DriverException("timed-out waiting for pulse guide to complete");
            //System.Threading.Thread.Sleep(10);
            //}
            //}
            //}

            //{
            //int dec_dur = Math.Min(dec_step, dec_tot);
            //dec_tot -= dec_dur;

            //if (dec_dur > 0)
            //{
            //m_camera.PulseGuide(dec_dir, dec_dur);
            //tl.LogMessage("Output", String.Format("log: dec_dir={0:F0} dec_dur={1:F0} ms", dec_dir, dec_dur));
            //System.Threading.Thread.Sleep(dec_dur + 10);
            //Stopwatch stopwatch = Stopwatch.StartNew();
            //while (m_camera.IsPulseGuiding)
            //{
            //if (stopwatch.ElapsedMilliseconds > 5000 + dec_dur)
            //throw new ASCOM.DriverException("timed-out waiting for pulse guide to complete");
            //System.Threading.Thread.Sleep(10);
            //}
            //}
            //}
            //}
        }