Ejemplo n.º 1
0
        private static readonly double SIDEREAL_RATE = 0.004178;         // degrees per second

        public static JogRates DefaultJogRates()
        {
            JogRates rates = new JogRates
            {
                new JogRate {
                    Name = "16X Sidereal", Rate = 0.06685
                },
                new JogRate {
                    Name = "64X Sidereal", Rate = 0.26740
                },
                new JogRate {
                    Name = "2 deg/sec", Rate = 2.0
                }
            };

            return(rates);
        }
Ejemplo n.º 2
0
        private static JogRates CreateDiscreteJogRates(IRate[] axisRates)
        {
            JogRates jogRates = new JogRates();

            foreach (IRate rate in axisRates)
            {
                // This is a discrete rate value.

                JogRate jogRate = BuildJogRate(rate.Minimum);

                jogRates.Add(jogRate);
            }

            if (jogRates.Count == 0)
            {
                jogRates = null;
            }

            return(jogRates);
        }
Ejemplo n.º 3
0
        public static JogRates FromAxisRates(IRate[] axisRates)
        {
            JogRates rates = null;

            if (axisRates != null && axisRates.Length > 0)
            {
                rates = new JogRates();

                if (AreDiscreteRates(axisRates))
                {
                    rates = CreateDiscreteJogRates(axisRates);
                }
                else
                {
                    rates = CreateRangedJogRates(axisRates);
                }
            }

            return(rates);
        }
Ejemplo n.º 4
0
        private void BuildJogRatesList()
        {
            JogRates jogRates = null;

            if (Capabilities != null)
            {
                IRate[] primaryAxisRates = Capabilities.PrimaryAxisRates;
                jogRates = JogRates.FromAxisRates(primaryAxisRates);
            }

            if (jogRates == null)
            {
                JogRates        = null;
                SelectedJogRate = null;
            }
            else
            {
                JogRates        = jogRates;
                SelectedJogRate = jogRates[0];
            }
        }
Ejemplo n.º 5
0
        private static JogRates CreateRangedJogRates(IRate[] axisRates)
        {
            JogRates jogRates = null;

            if (axisRates == null || axisRates.Length == 0)
            {
                return(jogRates);
            }

            if (axisRates.Length == 1)
            {
                jogRates = DefaultJogRates();

                if (jogRates.First().Rate > axisRates[0].Minimum && jogRates.Last().Rate < axisRates[0].Maximum)
                {
                    // Here the default rates are valid, so use them.

                    return(jogRates);
                }
            }

            // We can't use the default jog rates, so build a valid list.
            // The provided list of valid axis rates consists of multiple ranges so just take the average of each range.

            jogRates = new JogRates();

            foreach (IRate axisRate in axisRates)
            {
                double rateValue = (axisRate.Minimum + axisRate.Maximum) / 2.0;

                JogRate jogRate = BuildJogRate(rateValue);

                jogRates.Add(jogRate);
            }

            return(jogRates);
        }
Ejemplo n.º 6
0
        private void BuildJogRatesLists()
        {
            JogRates jogRates          = null;
            JogRates secondaryJogRates = null;

            bool asymmetricRates = false;

            if (Capabilities != null)
            {
                // We need to be careful because the jog rates can be null if the telescope does
                // not support MoveAxis!

                IRate[] primaryAxisRates = Capabilities.PrimaryAxisRates;
                jogRates = JogRates.FromAxisRates(primaryAxisRates);

                IRate[] secondaryAxisRates = Capabilities.SecondaryAxisRates;
                secondaryJogRates = JogRates.FromAxisRates(secondaryAxisRates);

                // If we cannot move both primary and secondary axes then we cannot have asymmetric rates.
                // This shows up in the jog rates being null.

                if (jogRates != null && secondaryJogRates != null)
                {
                    if (jogRates.Count == secondaryJogRates.Count)
                    {
                        for (int i = 0; i < jogRates.Count; ++i)
                        {
                            if (jogRates[i].Rate != secondaryJogRates[i].Rate)
                            {
                                asymmetricRates = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        asymmetricRates = true;
                    }
                }
            }

            if (jogRates == null)
            {
                JogRates        = null;
                SelectedJogRate = null;

                SecondaryJogRates        = null;
                SelectedSecondaryJogRate = null;

                HasAsymmetricJogRates = false;
            }
            else
            {
                JogRates        = jogRates;
                SelectedJogRate = jogRates[0];

                if (asymmetricRates)
                {
                    SecondaryJogRates        = secondaryJogRates;
                    SelectedSecondaryJogRate = secondaryJogRates[0];
                }
                else
                {
                    SecondaryJogRates        = null;
                    SelectedSecondaryJogRate = null;
                }

                HasAsymmetricJogRates = asymmetricRates;
            }
        }