Esempio n. 1
0
        public override INmeaMessage ParseFields(string[] tokens)
        {
            DataTypeName = tokens[0].TrimStart('$');
            TimeSpan ts = TimeSpan.ParseExact(tokens[1], @"hhmmss\.FFF", CultureInfo.InvariantCulture);

            Status                     = StatusEnumExtensions.FromNmeaString(tokens[2]);
            Latitude                   = Latitude.Parse(tokens[3] + DELIM_FIELDS + tokens[4], GeoAngleFormat.DMM, GeoAngleFormatOptions.Compact);
            Longitude                  = Longitude.Parse(tokens[5] + DELIM_FIELDS + tokens[6], GeoAngleFormat.DMM, GeoAngleFormatOptions.Compact);
            SpeedAboveGroundKnots      = float.Parse(tokens[7]);
            TrackAngleTrueNorthDegrees = float.Parse(tokens[8]);
            DateTime date = DateTime.ParseExact(tokens[9], "ddMMyy", CultureInfo.InvariantCulture);

            _utc = new DateTime(date.Year, date.Month, date.Day, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

            if (!string.IsNullOrWhiteSpace(tokens[10]))
            {
                MagneticVariation = float.Parse(tokens[10]);
                if (!string.IsNullOrWhiteSpace(tokens[11]))
                {
                    int sign = tokens[11].Trim().ToUpper() == "W" ? -1 : 1;
                    MagneticVariation *= sign;
                }
            }
            if (tokens.Length > 12)
            {
                ExtraField = tokens[12];
            }
            return(this);
        }
Esempio n. 2
0
 public void FromNmeaString_Active_IsCorrect()
 {
     Assert.AreEqual(StatusEnumExtensions.FromNmeaString("A"), StatusEnum.Active);
     Assert.AreEqual(StatusEnumExtensions.FromNmeaString("a"), StatusEnum.Active);
 }
Esempio n. 3
0
 public void FromNmeaString_Active_IsIncorrect()
 {
     StatusEnumExtensions.FromNmeaString("x");
 }
Esempio n. 4
0
 public void FromNmeaString_Void_IsCorrect()
 {
     Assert.AreEqual(StatusEnumExtensions.FromNmeaString("V"), StatusEnum.Void);
     Assert.AreEqual(StatusEnumExtensions.FromNmeaString("v"), StatusEnum.Void);
 }