public GPSHandler() { GpsPort = new SerialPort(); _disposed = false; //Link event from GPS receiver to process data function GpsPort.NewGPSData += GPSDataEventHandler; this.GPRMC = new NMEA.GPRMC(); this.GPGGA = new SharpGPS.NMEA.GPGGA(); this.GPGSA = new SharpGPS.NMEA.GPGSA(); this.GPRMC = new SharpGPS.NMEA.GPRMC(); this.PGRME = new SharpGPS.NMEA.GPRME(); this.GPGSV = new SharpGPS.NMEA.GPGSV(); }
/// <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(); e2.TypeOfEvent = e.TypeOfEvent; e2.Sentence = e.Sentence; _NewGPSFix(this, e2); break; default: break; } }
/// <summary> /// Disposes the GpsHandler and if nessesary calls Stop() /// </summary> public void Dispose() { if (!_disposed) { Stop(); GpsPort.Dispose(); this.GPGGA = null; this.GPGLL = null; this.GPGSA = null; this.GPRMC = null; this.PGRME = null; GpsPort = null; //this.GPGSV = null; _disposed = true; } GC.SuppressFinalize(this); }