Example #1
0
        }// GetTrackingRate

        /// <summary>
        /// Sets the tracking rate and also starts tracking
        /// </summary>
        /// <param name="trackingRate"></param>
        /// <returns></returns>
        public bool SetTrackingRate(DriveRates trackingRate)
        {
            bool success      = false;
            char trackingChar = ' ';

            switch (trackingRate)
            {
            case DriveRates.driveSidereal:
                trackingChar = '0';
                break;

            case DriveRates.driveSolar:
                trackingChar = '1';
                break;

            case DriveRates.driveLunar:
                trackingChar = '2';
                break;
            }// switch
            if (trackingChar != ' ')
            {
                if (RequestReply(string.Format(":STR{0}#", trackingChar), out string setTrackingRateReply))
                {
                    success = setTrackingRateReply == "1";
                }
            }
            else
            {
                this.Error = "Invalid tracking rate";
            }
            return(success);
        }// SetTrackingRate
        /// <summary>
        /// Get rate on Azm axis in (deg/sec)
        /// </summary>
        /// <param name="rate">Curent DriveRate</param>
        /// <param name="mode">Current TrackingMode</param>
        /// <returns></returns>
        public double GetRateRa(DriveRates rate, TrackingMode mode)
        {
            if (mode <= TrackingMode.AltAzm)
            {
                return 0;
            }

            double Rate;
            switch (rate)
            {
                case DriveRates.driveSidereal:
                    Rate = Const.TRACKRATE_SIDEREAL;
                    break;
                case DriveRates.driveSolar:
                    Rate = Const.TRACKRATE_SOLAR;
                    break;
                case DriveRates.driveLunar:
                    Rate = Const.TRACKRATE_LUNAR;
                    break;
                default:
                    throw new ValueNotAvailableException("Wring tracking rate value");
            }

            Rate += this.tp.RightAscensionRateOffset * Const.SiderealRate;
            if (mode == TrackingMode.EQS) Rate = -Rate;
            return Rate;
        }
Example #3
0
        }// GetTracking

        #endregion move commands

        #region Rates and Speeds

        public bool GetTrackingRate(out DriveRates trackingRate)
        {
            bool success = false;

            trackingRate = DriveRates.driveSidereal;
            if (RequestReply(":GTR#", out string trackingRateReply))
            {
                switch (trackingRateReply)
                {
                case "0":
                    trackingRate = DriveRates.driveSidereal;
                    success      = true;
                    break;

                case "1":
                    trackingRate = DriveRates.driveSolar;
                    success      = true;
                    break;

                case "2":
                    trackingRate = DriveRates.driveLunar;
                    success      = true;
                    break;
                }// switch
            }
            return(success);
        }// GetTrackingRate
Example #4
0
        private void ApplyOffsetTrackingRate(DriveRates rate, double raOffset, double decOffset)
        {
            if (!IsConnected)
            {
                return;
            }

            if (Capabilities.CanSetRightAscensionRate)
            {
                TelescopeManager.SetRaOffsetTrackingRate(raOffset);
            }

            if (Capabilities.CanSetDeclinationRate)
            {
                TelescopeManager.SetDecOffsetTrackingRate(decOffset);
            }

            if (rate != Status.TrackingRate)
            {
                TelescopeManager.SetTrackingRate(rate);

                Status.TrackingRate = rate;
                UpdateTrackingRateText();
            }
        }
        public TelescopeParameters(TelescopeManager mgr)
        {
            DeviceManager = mgr;

            AlignmentMode    = mgr.AlignmentMode;
            ApertureArea     = mgr.ApertureArea;
            ApertureDiameter = mgr.ApertureDiameter;
            Description      = mgr.Description;
            DriverInfo       = mgr.DriverInfo;
            DoesRefraction   = mgr.DoesRefraction;
            DriverVersion    = mgr.DriverVersion;
            EquatorialSystem = mgr.EquatorialSystem;
            FocalLength      = mgr.FocalLength;
            InterfaceVersion = mgr.InterfaceVersion;
            SiteElevation    = mgr.SiteElevation;
            SiteLatitude     = mgr.SiteLatitude;
            SiteLongitude    = mgr.SiteLongitude;
            SlewSettleTime   = mgr.SlewSettleTime;

            ArrayList arr = mgr.SupportedActions;

            this.SupportedActions = (string[])arr.ToArray(typeof(string));

            List <TrackingRateItem> temp = new List <TrackingRateItem>();

            ITrackingRates rates = (ITrackingRates)mgr.TrackingRates;

            if (rates != null)
            {
                for (int i = 1; i <= rates.Count; ++i)
                {
                    DriveRates rate = rates[i];
                    string     name = "";

                    switch (rate)
                    {
                    case DriveRates.driveKing:
                        name = "King";
                        break;

                    case DriveRates.driveLunar:
                        name = "Lunar";
                        break;

                    case DriveRates.driveSidereal:
                        name = "Sidereal";
                        break;

                    case DriveRates.driveSolar:
                        name = "Solar";
                        break;
                    }

                    temp.Add(new TrackingRateItem(name, rate));
                }
            }

            TrackingRates = temp.ToArray();
        }
 public DriveRates this[int index]
 {
     get
     {
         DriveRates driveRates = (DriveRates)this.objTypeTrackingRates.InvokeMember("Item", BindingFlags.GetProperty, (Binder)null, this.objTrackingRatesLateBound, new object[1]
         {
             (object)index
         });
         this.TL.LogMessage("TrackingRates Class", "DriveRates[" + (object)index + "] " + driveRates.ToString());
         return(driveRates);
     }
 }
Example #7
0
        private void UpdateTrackingRateText()
        {
            if (!IsConnected)
            {
                TrackingRateText = "The tracking rate is not known.";
            }
            else
            {
                DriveRates driveRate = Status.TrackingRate;
                string     rate      = "Sidereal";

                switch (driveRate)
                {
                case DriveRates.driveSidereal:
                    if (Status.RightAscensionRate != 0.0 || Status.DeclinationRate != 0.0)
                    {
                        rate = "Offset";
                    }

                    break;

                case DriveRates.driveLunar:
                    rate = "Lunar";

                    break;

                case DriveRates.driveSolar:
                    rate = "Solar";

                    break;

                case DriveRates.driveKing:
                    rate = "King";

                    break;
                }

                TrackingRateText = String.Format("Currently tracking at the {0} rate.", rate);
            }
        }
 private void setTrackingRate(DriveRates rate, TrackingMode mode)
 {
     if (mode > TrackingMode.AltAzm) this.tp.IsAtHome = false;
     this.two.SetTrackingRate(rate, mode);
 }
 public void SetTrackingRate(DriveRates rate, TrackingMode mode)
 {
     lock (_sync)
     {
         setTrackingRate(rate, mode);
     }
 }
 /// <summary>
 /// Get rate on Azm axis in (deg/sec)
 /// </summary>
 /// <param name="rate">Curent DriveRate</param>
 /// <param name="mode">Current TrackingMode</param>
 /// <returns></returns>
 public double GetRateRa(DriveRates rate, TrackingMode mode)
 {
     return this.two.GetRateRa(rate, mode);
 }
Example #11
0
 public TrackingRateItem(string name, DriveRates rate)
 {
     Name = name;
     Rate = rate;
 }
Example #12
0
 private void ApplyStandardTrackingRate(DriveRates rate)
 {
     ApplyOffsetTrackingRate(rate, 0.0, 0.0);
 }
 public void SetTrackingRate(DriveRates rate, TrackingMode mode)
 {
     double Rate = this.GetRateRa(rate, mode);
     this.CheckRateTrackingState();
     this.ti.SlewHighRate(SlewAxes.RaAzm, Rate);
     this.tp.MovingAzmAxes = false;
 }
Example #14
0
        protected T GetServiceProperty <T>(Func <T> getCmd, T defaultValue
                                           , ActivityMessageTypes messageType = ActivityMessageTypes.Status
                                           , [System.Runtime.CompilerServices.CallerMemberName] string propName = "???")
        {
            T         retval = defaultValue;
            Exception xcp    = null;

            CheckDevice();

            try
            {
                retval = getCmd();
            }
            catch (Exception ex)
            {
                xcp = ex;
                string name = ex.GetType().Name;
            }

            if (xcp == null)
            {
                if (retval is ArrayList)
                {
                    LogActivityStart(messageType, "Get {0}: {1}", propName, retval);

                    StringBuilder sb   = new StringBuilder();
                    ArrayList     list = retval as ArrayList;

                    foreach (var item in list)
                    {
                        sb.Append((sb.Length > 0) ? ", " : "");
                        sb.Append(item.ToString());
                    }

                    LogActivityEnd(messageType, sb.ToString());
                }
                else if (retval is ITrackingRates)
                {
                    LogActivityStart(ActivityMessageTypes.Parameters, "Get {0}:", propName);
                    StringBuilder sb = new StringBuilder();

                    ITrackingRates rates = retval as ITrackingRates;

                    if (rates == null)
                    {
                        sb.Append(" Did not return expected ITrackingRates collection!");
                    }
                    else
                    {
                        foreach (DriveRates rate in rates)
                        {
                            DriveRates tempRate = rate;

                            if (sb.Length > 0)
                            {
                                sb.Append(", ");
                            }

                            sb.Append(tempRate.ToString());
                        }
                    }

                    LogActivityEnd(ActivityMessageTypes.Parameters, sb.ToString());
                }
                else
                {
                    LogActivityLine(messageType, "Get {0}: {1}", propName, retval);
                }
            }
            else
            {
                LogActivityLine(messageType, "Get {0} Exception: {1}", propName, xcp.Message);
            }

            Exceptions.SetException(propName, xcp);

            return(retval);
        }