private void Device_MessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs args) { Dispatcher.BeginInvoke((Action) delegate() { _dataFound = true; if (_liveData) { FileUtil.WriteToFile(args.Message, _dataTextSavePath); } switch (args.Message) { case Gpgga _: var newReading = args.Message as Gpgga; if (Navigatedisplay.IsGoodMessage(newReading)) { LoggingService.AddInfo(args.Message.ToString(), "nmea"); Navigatedisplay.ParseNmeaMessage(newReading); // Navigatedisplay.GetCourseCorrections(GpsCourse); } break; case GPRMC _: var newReadingt = args.Message as Gpvtg; break; } }); }
private void StartDevice(NmeaParser.NmeaDevice device) { //Clean up old device if (_currentDevice != null) { _currentDevice.MessageReceived -= Device_MessageReceived; _currentDevice.Dispose(); } _currentDevice = device; _currentDevice.MessageReceived += Device_MessageReceived; var _ = _currentDevice.OpenAsync(); if (device is NmeaParser.NmeaFileDevice) { _currentDeviceInfo = $"NmeaFileDevice( file={((NmeaParser.NmeaFileDevice)device).FileName} )"; } else if (device is NmeaParser.SerialPortDevice) { _currentDeviceInfo = $"SerialPortDevice( port={((NmeaParser.SerialPortDevice)device).Port.PortName}, baud={((NmeaParser.SerialPortDevice)device).Port.BaudRate} )"; } LoggingService.AddInfo(_currentDeviceInfo, "nmea"); }