private void moveAxis(SlewAxes axis, double rate, bool isFixed = false)
        {
            this.CheckPark();
            if (this.telescopeMode != TelescopeMode.Normal && this.telescopeMode != TelescopeMode.MovingAxis) return;

            this.tp.IsAtHome = false;
            if (axis == SlewAxes.DecAlt) this.tp.MovingAltAxes = !rate.Equals(0);
            if (axis == SlewAxes.RaAzm) this.tp.MovingAzmAxes = !rate.Equals(0);
            if (!rate.Equals(0))
            {
                if (axis == SlewAxes.RaAzm)
                {
                    if (this.telescopeMode != TelescopeMode.MovingAxis)
                        this.moveAxisTrackingMode = this.tp.TrackingMode;
                    this.checkRateTrackingState();
                    //SetTracking(TrackingMode.Off);
                    //tp.TrackingMode = TrackingMode.Off;
                }
                this.two.MoveAxis(axis, rate, isFixed);
                this.telescopeMode = TelescopeMode.MovingAxis;
            }
            else // rate == 0
            {
                if (axis == SlewAxes.RaAzm)
                {
                    this.setTrackingRate(this.tp.TrackingRate, this.moveAxisTrackingMode);
                    this.tp.TrackingMode = this.moveAxisTrackingMode;
                }
                else
                {
                    this.setTrackingDec();
                }
                if (!this.tp.MovingAltAxes && !this.tp.MovingAzmAxes)
                {
                    this.telescopeMode = TelescopeMode.Normal;
                }
            }
        }
 private void SlewingMode(bool Sync = false)
 {
     if (!this.isSlewSetteled)
     {
         try
         {
             if (!this.ti.IsGoToInProgress)
             {
                 this.slewEndTime = Environment.TickCount;
                 this.isSlewSetteled = true;
             }
         }
         catch
         {
             return;
         }
     }
     else if (this.slewEndTime + this.tp.SlewSteeleTime <= Environment.TickCount)
     {
         this.isSlewSetteled = false;
         SlewWaitHandle.Set();
         this.telescopeMode = TelescopeMode.Normal;
     }
     this.checkCoordinates();
 }
        private void InitialMode()
        {
            var isReady = false;
            for (int i = 0; i < 5; i++)
            {
                try
                {
                    this.tp.GetTelescopeProperties();
                    isReady = true;
                    break;
                }
                catch (Exception err)
                {

                }
                Thread.Sleep(1000);
            }
            if (!isReady) throw new DriverException("Can't get propertyes of telescope");
            this.checkCoordinates(true);
            this.telescopeMode = this.tp.SlewState == SlewState.Slewing ? TelescopeMode.Slewing : TelescopeMode.Normal;
            this.checkRateTrackingState();
            this.setTrackingRate(this.tp.TrackingRate, this.tp.TrackingMode);
        }
        private void GuidingMode()
        {
            if (this.ps.Ra != null && this.ps.Ra.isExpired)
            {
                this.ps.Ra = null;
                this.setTrackingRate(this.tp.TrackingRate, this.tp.TrackingMode);
            }

            if (this.ps.Dec != null && this.ps.Dec.isExpired)
            {
                this.ps.Dec = null;
                this.setTrackingDec();
            }

            if (this.ps.Dec == null && this.ps.Ra == null)
            {
                this.telescopeMode = TelescopeMode.Normal;
            }
        }
 public bool Slew(AltAzm coord)
 {
     this.CheckPark();
     if (this.telescopeMode != TelescopeMode.Normal) return false;
     this.tp.IsAtHome = false;
     lock (_sync)
     {
         SlewWaitHandle.Reset();
         this.ti.AltAzm = coord;
         this.telescopeMode = TelescopeMode.Slewing;
         Thread.Sleep(300);
     }
     return true;
 }
 public void PulseGuide(GuideDirections dir, int duration)
 {
     this.CheckPark();
     if(this.telescopeMode != TelescopeMode.Normal && this.telescopeMode != TelescopeMode.Guiding) return;
     lock (_sync)
     {
         this.tp.IsAtHome = false;
         this.two.PulseGuide(dir, duration, this.ps);
         this.telescopeMode = TelescopeMode.Guiding;
     }
 }
 public void Disconnect()
 {
     lock (_sync)
     {
         this.stopWorking();
         this.ti = null;
         this.telescopeMode = TelescopeMode.Initial;
     }
 }