/// <summary> /// Event handler for the SerialGPS, parses the NMEA message and updates CurrentGeopoint. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _serialGPSDevice_MessageReceived(object sender, NmeaMessageReceivedEventArgs e) { if (!_serialGPSDeviceFound) { _serialGPSDeviceFound = true; } double Latitude = 0.0, Longitude = 0.0; NMEAMessage = e.Message.ToString(); //Parse all NMEA messages supported by BU353-s4. //Only GGA, RMC, and GLL support location switch (e.Message.MessageType) { case "GPGGA": Gpgga gga = (Gpgga)e.Message; Latitude = gga.Latitude; Longitude = gga.Longitude; break; case "GPRMC": Gprmc rmc = (Gprmc)e.Message; Latitude = rmc.Latitude; Longitude = rmc.Longitude; break; case "GPGLL": Gpgll gll = (Gpgll)e.Message; Latitude = gll.Latitude; Longitude = gll.Longitude; break; case "GPGSA": Gpgsa gsa = (Gpgsa)e.Message; break; case "GPGSV": Gpgsv gsv = (Gpgsv)e.Message; break; } //make sure the delta-p is above a threshold if (Latitude != 0.0 && Longitude != 0.0) { double distance = Haversine(Latitude, Longitude, CurrentGeopoint.Position.Latitude, CurrentGeopoint.Position.Longitude); if (distance > 0) //2.5m is minimum accuracy of BU-353 S4 and WAAS/SBAS corrections { CurrentGeopoint = CreateGeopoint(Latitude, Longitude); } } }
private void NmeaStreamDevice_MessageReceived(object sender, NmeaMessageReceivedEventArgs e) { if (!messageStats.ContainsKey(e.Message.MessageType)) { messageStats.Add(e.Message.MessageType, 0); } messageStats[e.Message.MessageType]++; switch (e.Message.MessageType) { case "GPGSV": Gpgsv gpgsv = (Gpgsv)e.Message; numSattelites = gpgsv.SVsInView; break; case "GPGLL": //enthält GPS Daten Gpgll gpgll = (Gpgll)e.Message; if (gpgll.DataActive) { lon = gpgll.Longitude; lat = gpgll.Latitude; validGpsSignal = true; gpsLlTimestamp = DateTime.Now; } break; case "GPGSA": Gpgsa gpgsa = (Gpgsa)e.Message; fixMode = gpgsa.FixMode; break; case "GPRMC": //enthält GPS Daten Gprmc gprmc = (Gprmc)e.Message; break; case "GPVTG": break; case "GPZDA": break; case "GPGGA": //enthält GPS Daten Gpgga gpgga = (Gpgga)e.Message; altitude = gpgga.Altitude; break; default: lock (lockVictim) { tourStreamWriter.WriteLine(String.Format("UNIMP_GPS;", e.Message.ToString())); } break; } }
public void TestGpgll_NoFixTime_OrActiveIndicator() { string input = "$GPGLL,3751.65,S,14507.36,E*77"; var msg = NmeaMessage.Parse(input); Assert.IsInstanceOfType(msg, typeof(Gpgll)); Gpgll gll = (Gpgll)msg; Assert.IsTrue(gll.DataActive); Assert.AreEqual(-37.860833333333333333, gll.Latitude); Assert.AreEqual(145.1226666666666666667, gll.Longitude); Assert.AreEqual(TimeSpan.Zero, gll.FixTime); }
public void TestGpgll() { string input = "$GPGLL,4916.45,N,12311.12,W,225444.12,A,*30"; var msg = NmeaMessage.Parse(input); Assert.IsInstanceOfType(msg, typeof(Gpgll)); Gpgll gll = (Gpgll)msg; Assert.IsTrue(gll.DataActive); Assert.AreEqual(49.2741666666666666667, gll.Latitude); Assert.AreEqual(-123.18533333333333333, gll.Longitude); Assert.AreEqual(new TimeSpan(0, 22, 54, 44, 120), gll.FixTime); }