Example #1
0
 /// <summary>
 /// Creates a new instance using the specified unique identifier, location around the horizon, and elevation up from the horizon.
 /// </summary>
 /// <param name="pseudorandomNumber">The pseudorandom number.</param>
 /// <param name="azimuth">The azimuth.</param>
 /// <param name="elevation">The elevation.</param>
 /// <param name="signalToNoiseRatio">The signal to noise ratio.</param>
 /// <param name="isFixed">if set to <c>true</c> [is fixed].</param>
 public Satellite(int pseudorandomNumber, Azimuth azimuth, Elevation elevation, SignalToNoiseRatio signalToNoiseRatio, bool isFixed)
 {
     _pseudorandomNumber = pseudorandomNumber;
     _azimuth            = azimuth;
     _elevation          = elevation;
     _signalToNoiseRatio = signalToNoiseRatio;
     _isFixed            = isFixed;
     _lastSignalReceived = DateTime.MinValue;
 }
Example #2
0
        /// <summary>
        /// Corrects this classes properties after the base sentence was changed.
        /// </summary>
        private new void SetPropertiesFromSentence()
        {
            // Cache the words
            string[] words     = Words;
            int      wordCount = words.Length;

            /*  $GPGSV
             *
             *  GPS Satellites in view
             *
             *  eg. $GPGSV, 3, 1, 11, 03, 03, 111, 00, 04, 15, 270, 00, 06, 01, 010, 00, 13, 06, 292, 00*74
             *  $GPGSV, 3, 2, 11, 14, 25, 170, 00, 16, 57, 208, 39, 18, 67, 296, 40, 19, 40, 246, 00*74
             *  $GPGSV, 3, 3, 11, 22, 42, 067, 42, 24, 14, 311, 43, 27, 05, 244, 00, ,, ,*4D
             *
             *
             *  $GPGSV, 1, 1, 13, 02, 02, 213, ,03, -3, 000, ,11, 00, 121, ,14, 13, 172, 05*62
             *
             *
             *  1    = Total number of messages of this type in this cycle
             *  2    = Message number
             *  3    = Total number of SVs in view
             *  4    = SV PRN number
             *  5    = Elevation in degrees, 90 maximum
             *  6    = Azimuth, degrees from true north, 000 to 359
             *  7    = SNR, 00-99 dB (null when not tracking)
             *  8-11 = Information about second SV, same as field 4-7
             *  12-15= Information about third SV, same as field 4-7
             *  16-19= Information about fourth SV, same as field 4-7
             */

            // Example (signal not acquired): $GPGSV, 1, 1, 01, 21, 00, 000, *4B
            // Example (signal acquired): $GPGSV, 3, 1, 10, 20, 78, 331, 45, 01, 59, 235, 47, 22, 41, 069, ,13, 32, 252, 45*70

            // Get the total message count
            if (wordCount > 0 && words[0].Length != 0)
            {
                TotalMessageCount = int.Parse(words[0], NmeaCultureInfo);
            }

            // Get the current message number
            if (wordCount > 1 && words[1].Length != 0)
            {
                CurrentMessageNumber = int.Parse(words[1], NmeaCultureInfo);
            }

            // Get the total message count
            if (wordCount > 2 && words[2].Length != 0)
            {
                SatellitesInView = int.Parse(words[2], NmeaCultureInfo);
            }

            // Make a new list of satellites
            Satellites = new List <Satellite>();

            // Now process each satellite
            for (int index = 0; index < 6; index++)
            {
                int currentWordIndex = index * 4 + 3;
                // Are we past the length of words?
                if (currentWordIndex > wordCount - 1)
                {
                    break;
                }
                // No.  Get the unique code for the satellite
                if (words[currentWordIndex].Length == 0)
                {
                    continue;
                }

                int                pseudorandomNumber = int.Parse(words[currentWordIndex], NmeaCultureInfo);
                Elevation          newElevation;
                Azimuth            newAzimuth;
                SignalToNoiseRatio newSignalToNoiseRatio;

                // Update the elevation
                if (wordCount > currentWordIndex + 1 && words[currentWordIndex + 1].Length != 0)
                {
                    newElevation = Elevation.Parse(words[currentWordIndex + 1], NmeaCultureInfo);
                }
                else
                {
                    newElevation = Elevation.Empty;
                }

                // Update the azimuth
                if (wordCount > currentWordIndex + 2 && words[currentWordIndex + 2].Length != 0)
                {
                    newAzimuth = Azimuth.Parse(words[currentWordIndex + 2], NmeaCultureInfo);
                }
                else
                {
                    newAzimuth = Azimuth.Empty;
                }

                // Update the signal strength
                if (wordCount > currentWordIndex + 3 && words[currentWordIndex + 3].Length != 0)
                {
                    newSignalToNoiseRatio = SignalToNoiseRatio.Parse(words[currentWordIndex + 3], NmeaCultureInfo);
                }
                else
                {
                    newSignalToNoiseRatio = SignalToNoiseRatio.Empty;
                }

                // Add the satellite to the collection
                Satellites.Add(new Satellite(pseudorandomNumber, newAzimuth, newElevation, newSignalToNoiseRatio, false));
            }
        }
Example #3
0
 /// <summary>
 /// Creates a new instance using the specified unique identifier, location around the horizon, and elevation up from the horizon.
 /// </summary>
 /// <param name="pseudorandomNumber">The pseudorandom number.</param>
 /// <param name="azimuth">The azimuth.</param>
 /// <param name="elevation">The elevation.</param>
 /// <param name="signalToNoiseRatio">The signal to noise ratio.</param>
 public Satellite(int pseudorandomNumber, Azimuth azimuth, Elevation elevation, SignalToNoiseRatio signalToNoiseRatio)
     : this(pseudorandomNumber, azimuth, elevation, signalToNoiseRatio, false)
 {
 }
Example #4
0
 /// <summary>
 /// Creates a new instance of the event args
 /// </summary>
 /// <param name="signalToNoiseRatio">The signal to noise ratio.</param>
 public SignalToNoiseRatioEventArgs(SignalToNoiseRatio signalToNoiseRatio)
 {
     _signalToNoiseRatio = signalToNoiseRatio;
 }