/// <summary> /// Method called when a GPS event occured. /// This is where we call the methods that parses each kind of NMEA sentence /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GpsDataEventHandler(object sender, SerialPort.GpsEventArgs e) { switch (e.TypeOfEvent) { case GpsEventType.GPRMC: ParseRMC(e.Sentence); break; case GpsEventType.GPGGA: ParseGGA(e.Sentence); break; case GpsEventType.GPGLL: ParseGLL(e.Sentence); break; case GpsEventType.GPGSA: ParseGSA(e.Sentence); break; case GpsEventType.GPGSV: ParseGSV(e.Sentence); break; case GpsEventType.PGRME: ParseRME(e.Sentence); break; case GpsEventType.TimeOut: FireTimeOut(); break; case GpsEventType.Unknown: GpsEventArgs e2 = new GpsEventArgs { TypeOfEvent = e.TypeOfEvent, Sentence = e.Sentence }; NewProcessedGpsFix(this, e2); break; default: break; } }
/// <summary> /// Disposes the GpsHandler and if nessesary calls Stop() /// </summary> public void Dispose() { if (!_disposed) { Stop(); GpsPort.Dispose(); GPGGA = null; GPGLL = null; GPGSA = null; GPRMC = null; PGRME = null; GpsPort = null; _disposed = true; } GC.SuppressFinalize(this); }