Ejemplo n.º 1
0
        /// <summary>
        /// Called when the message is being loaded.
        /// </summary>
        /// <param name="message">The NMEA message values.</param>
        protected override void OnLoadMessage(string[] message)
        {
            if (message == null || message.Length < 14)
            {
                throw new ArgumentException("Invalid GPGGA", "message");
            }

            int fixQuality;
            int numberOfSatellites;

            Latitude           = NmeaMessage.StringToLatitude(message[1], message[2]);
            Longitude          = NmeaMessage.StringToLongitude(message[3], message[4]);
            Quality            = int.TryParse(message[5], NumberStyles.Integer, CultureInfo.InvariantCulture, out fixQuality) ? (FixQuality)fixQuality : FixQuality.Invalid;
            NumberOfSatellites = int.TryParse(message[6], NumberStyles.Integer, CultureInfo.InvariantCulture, out numberOfSatellites) ? numberOfSatellites : 0;
            Hdop                    = NmeaMessage.StringToDouble(message[7]);
            Altitude                = NmeaMessage.StringToDouble(message[8]);
            AltitudeUnits           = message[9];
            HeightOfGeoid           = NmeaMessage.StringToDouble(message[10]);
            HeightOfGeoidUnits      = message[11];
            TimeSinceLastDgpsUpdate = StringToTimeSpan(message[0]);
            if (message[13].Length > 0)
            {
                DgpsStationId = int.Parse(message[13], CultureInfo.InvariantCulture);
            }
            else
            {
                DgpsStationId = -1;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the message is being loaded.
        /// </summary>
        /// <param name="message">The NMEA message values.</param>
        protected override void OnLoadMessage(string[] message)
        {
            if (message == null || message.Length < 14)
            {
                throw new ArgumentException("Invalid GPGGA", "message");
            }
            FixTime            = StringToTimeSpan(message[0]);
            Latitude           = NmeaMessage.StringToLatitude(message[1], message[2]);
            Longitude          = NmeaMessage.StringToLongitude(message[3], message[4]);
            Quality            = (FixQuality)int.Parse(message[5], CultureInfo.InvariantCulture);
            NumberOfSatellites = int.Parse(message[6], CultureInfo.InvariantCulture);
            Hdop               = NmeaMessage.StringToDouble(message[7]);
            Altitude           = NmeaMessage.StringToDouble(message[8]);
            AltitudeUnits      = message[9];
            HeightOfGeoid      = NmeaMessage.StringToDouble(message[10]);
            HeightOfGeoidUnits = message[11];
            var timeInSeconds = StringToDouble(message[12]);

            if (!double.IsNaN(timeInSeconds))
            {
                TimeSinceLastDgpsUpdate = TimeSpan.FromSeconds(timeInSeconds);
            }
            else
            {
                TimeSinceLastDgpsUpdate = TimeSpan.MaxValue;
            }
            if (message[13].Length > 0)
            {
                DgpsStationId = int.Parse(message[13], CultureInfo.InvariantCulture);
            }
            else
            {
                DgpsStationId = -1;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the message is being loaded.
        /// </summary>
        /// <param name="message">The NMEA message values.</param>
        protected override void OnLoadMessage(string[] message)
        {
            if (message == null || message.Length < 11)
            {
                throw new ArgumentException("Invalid GPRMC", "message");
            }

            if (message[8].Length == 6 && message[0].Length >= 6)
            {
                FixTime = new DateTime(int.Parse(message[8].Substring(4, 2), CultureInfo.InvariantCulture) + 2000,
                                       int.Parse(message[8].Substring(2, 2), CultureInfo.InvariantCulture),
                                       int.Parse(message[8].Substring(0, 2), CultureInfo.InvariantCulture),
                                       int.Parse(message[0].Substring(0, 2), CultureInfo.InvariantCulture),
                                       int.Parse(message[0].Substring(2, 2), CultureInfo.InvariantCulture),
                                       0, DateTimeKind.Utc).AddSeconds(double.Parse(message[0].Substring(4), CultureInfo.InvariantCulture));
            }
            Active            = (message[1] == "A");
            Latitude          = NmeaMessage.StringToLatitude(message[2], message[3]);
            Longitude         = NmeaMessage.StringToLongitude(message[4], message[5]);
            Speed             = NmeaMessage.StringToDouble(message[6]);
            Course            = NmeaMessage.StringToDouble(message[7]);
            MagneticVariation = NmeaMessage.StringToDouble(message[9]);
            if (!double.IsNaN(MagneticVariation) && message[10] == "W")
            {
                MagneticVariation *= -1;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Called when the message is being loaded.
 /// </summary>
 /// <param name="message">The NMEA message values.</param>
 protected override void OnLoadMessage(string[] message)
 {
     if (message == null || message.Length < 7)
     {
         throw new ArgumentException("Invalid Gpvtg", "message");
     }
     TrueCourseOverGround     = NmeaMessage.StringToDouble(message[0]);
     MagneticCourseOverGround = NmeaMessage.StringToDouble(message[2]);
     SpeedInKnots             = NmeaMessage.StringToDouble(message[4]);
     SpeedInKph = NmeaMessage.StringToDouble(message[6]);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Called when the message is being loaded.
        /// </summary>
        /// <param name="message">The NMEA message values.</param>
        protected override void OnLoadMessage(string[] message)
        {
            if (message == null || message.Length < 6)
            {
                throw new ArgumentException("Invalid PGRME", "message");
            }

            HorizontalError      = NmeaMessage.StringToDouble(message[0]);
            HorizontalErrorUnits = message[1];
            VerticalError        = NmeaMessage.StringToDouble(message[2]);
            VerticalErrorUnits   = message[3];
            SphericalError       = NmeaMessage.StringToDouble(message[4]);
            SphericalErrorUnits  = message[5];
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pgrme"/> class.
        /// </summary>
        /// <param name="type">The message type</param>
        /// <param name="message">The NMEA message values.</param>
        public Pgrme(string type, string[] message) : base(type, message)
        {
            if (message == null || message.Length < 6)
            {
                throw new ArgumentException("Invalid PGRME", "message");
            }

            HorizontalError      = NmeaMessage.StringToDouble(message[0]);
            HorizontalErrorUnits = message[1];
            VerticalError        = NmeaMessage.StringToDouble(message[2]);
            VerticalErrorUnits   = message[3];
            SphericalError       = NmeaMessage.StringToDouble(message[4]);
            SphericalErrorUnits  = message[5];
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Called when the message is being loaded.
 /// </summary>
 /// <param name="message">The NMEA message values.</param>
 protected override void OnLoadMessage(string[] message)
 {
     if (message == null || message.Length < 8)
     {
         throw new ArgumentException("Invalid GNGST", "message");
     }
     FixTime             = StringToTimeSpan(message[0]);
     Rms                 = NmeaMessage.StringToDouble(message[1]);
     SemiMajorError      = NmeaMessage.StringToDouble(message[2]);
     SemiMinorError      = NmeaMessage.StringToDouble(message[3]);
     ErrorOrientation    = NmeaMessage.StringToDouble(message[4]);
     SigmaLatitudeError  = NmeaMessage.StringToDouble(message[5]);
     SigmaLongitudeError = NmeaMessage.StringToDouble(message[6]);
     SigmaHeightError    = NmeaMessage.StringToDouble(message[7]);
 }