/// <summary> /// Set any possible values for the given NMEA data. /// It will continue to replace /// the values so the last value is used as the final value. /// </summary> /// <param name="sentence">NMEA sentence containing data.</param> private void SetValues(NmeaSentence sentence) { /* * NMEA specification states that the first two letters of * a sentence may change. For example, for "$GPGSV" there may be variations such as * "$__GSV" where the first two letters change. As a result, we need only test the last three * characters. */ try { if (sentence.CommandWord.EndsWith("GGA", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGGA = new GpggaSentence(sentence.Sentence); // Set the Lat and Lon and time } if (sentence.CommandWord.EndsWith("VTG", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPVTG = new GpvtgSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("RMC", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPRMC = new GprmcSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("RMF", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor PGRMF = new PgrmfSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("GLL", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGLL = new GpgllSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("GSV", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGSV = new GpgsvSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("GSA", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGSA = new GpgsaSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("HDT", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPHDT = new GphdtSentence(sentence.Sentence); } } catch (Exception e) { log.Error("Error decoding a NMEA sentance.", e); } }
public void PgrmfSentenceFromString() { Latitude l = new Latitude(1, 0.5, LatitudeHemisphere.North); Longitude l2 = new Longitude(1, 23.0, LongitudeHemisphere.West); Position p = new Position(l, l2); DateTime dt = new DateTime(2003, 12, 4, 21, 59, 48); Azimuth a = new Azimuth(62.0); Speed s = new Speed(0, SpeedUnit.KilometersPerHour); PgrmfSentence sentence = new PgrmfSentence("$PGRMF,223,424801,041203,215948,13,0100.5000,N,00123.0000,W,A,2,0,62,2,1*35"); Assert.AreEqual("$PGRMF,223,424801,041203,215948,13,0100.5000,N,00123.0000,W,A,2,0,62,2,1*35", sentence.Sentence); Assert.AreEqual(dt, sentence.UtcDateTime); Assert.AreEqual(p, sentence.Position); Assert.AreEqual(FixMode.Automatic, sentence.FixMode); Assert.AreEqual(FixMethod.Fix3D, sentence.FixMethod); Assert.AreEqual(s, sentence.Speed); Assert.AreEqual(a, sentence.Bearing); Assert.AreEqual(new DilutionOfPrecision(2), sentence.PositionDilutionOfPrecision); /* * 2.2.3 * GPS Fix Data Sentence (PGRMF) * $PGRMF,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12>,<13>,<14>,<15>*hh<CR><LF> * <0> GPS week number (0 - 1023) * <1> GPS seconds (0 - 604799) * <2> UTC date of position fix, ddmmyy format * <3> UTC time of position fix, hhmmss format * <4> GPS leap second count * <5> Latitude, ddmm.mmmm format (leading zeros will be transmitted) * <6> Latitude hemisphere, N or S * <7> Longitude, dddmm.mmmm format (leading zeros will be transmitted) * <8> Longitude hemisphere, E or W * <9> Mode, M = manual, A = automatic * <10> Fix type, 0 = no fix, 1 = 2D fix, 2 = 3D fix * <11> Speed over ground, 0 to 1051 kilometers/hour * <12> Course over ground, 0 to 359 degrees, true * <13> Position dilution of precision, 0 to 9 (rounded to nearest integer value) * <14> Time dilution of precision, 0 to 9 (rounded to nearest integer value) * hh <CR><LF> * */ }
/// <summary> /// Set any possible values for the given NMEA data. /// It will continue to replace /// the values so the last value is used as the final value. /// </summary> /// <param name="sentence">NMEA sentence containing data.</param> private void SetValues(NmeaSentence sentence) { /* * NMEA specification states that the first two letters of * a sentence may change. For example, for "$GPGSV" there may be variations such as * "$__GSV" where the first two letters change. As a result, we need only test the last three * characters. */ if (sentence.CommandWord.EndsWith("GGA", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGGA = new GpggaSentence(sentence.Sentence); // Set the Lat and Lon and time } if (sentence.CommandWord.EndsWith("VTG", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPVTG = new GpvtgSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("RMC", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPRMC = new GprmcSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("RMF", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor PGRMF = new PgrmfSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("GLL", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGLL = new GpgllSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("GSV", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGSV = new GpgsvSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("GSA", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPGSA = new GpgsaSentence(sentence.Sentence); } if (sentence.CommandWord.EndsWith("HDT", StringComparison.Ordinal)) { // Yes. Convert it using the fast pre-parseed constructor GPHDT = new GphdtSentence(sentence.Sentence); } }