// Interprets a "Satellites in View" NMEA sentence private bool ParseGpgsv(string sentence) { bool result = false; try { string[] words = GetWords(sentence); string rawNumberOfMessages = words[1]; string rawSequenceNumber = words[2]; string rawSatellitesInView = words[3]; SatelliteCount = int.Parse(rawSatellitesInView, NmeaCultureInfo); if (rawSequenceNumber == "1") { Satellites.Clear(); _allSatellitesLoaded = false; } if (rawSequenceNumber == rawNumberOfMessages) { _allSatellitesLoaded = true; } int index = 4; if (words.Length < 16) { return(false); } while (index <= 16 && words.Length > index + 4 && words[index] != "") { Satellite tempSatellite = new Satellite(); string id = words[index]; if (id != "") { int.TryParse(id, NumberStyles.Integer, NmeaCultureInfo, out tempSatellite.Id); } string elevation = words[index + 1]; if (elevation != "") { tempSatellite.Elevation = double.Parse(elevation, NmeaCultureInfo); } string azimuth = words[index + 2]; if (azimuth != "") { tempSatellite.Azimuth = Convert.ToDouble(azimuth, CultureInfo.InvariantCulture); } string snr = words[index + 3]; tempSatellite.Snr = snr == "" ? 0 : Convert.ToDouble(snr, CultureInfo.InvariantCulture); index = index + 4; Satellites.Add(tempSatellite); } result = true; } catch { } // Indicate that the sentence was recognized return(result); }
// Interprets a "Satellites in View" NMEA sentence private bool ParseGpgsv(string sentence) { bool result = false; try { string[] words = GetWords(sentence); string rawNumberOfMessages = words[1]; string rawSequenceNumber = words[2]; string rawSatellitesInView = words[3]; SatelliteCount = int.Parse(rawSatellitesInView, NmeaCultureInfo); if (rawSequenceNumber == "1") { Satellites.Clear(); _allSatellitesLoaded = false; } if (rawSequenceNumber == rawNumberOfMessages) { _allSatellitesLoaded = true; } int index = 4; if (words.Length < 16) { return false; } while (index <= 16 && words.Length > index + 4 && words[index] != "") { Satellite tempSatellite = new Satellite(); string id = words[index]; if (id != "") { int.TryParse(id, NumberStyles.Integer, NmeaCultureInfo, out tempSatellite.Id); } string elevation = words[index + 1]; if (elevation != "") { tempSatellite.Elevation = double.Parse(elevation, NmeaCultureInfo); } string azimuth = words[index + 2]; if (azimuth != "") { tempSatellite.Azimuth = Convert.ToDouble(azimuth, CultureInfo.InvariantCulture); } string snr = words[index + 3]; tempSatellite.Snr = snr == "" ? 0 : Convert.ToDouble(snr, CultureInfo.InvariantCulture); index = index + 4; Satellites.Add(tempSatellite); } result = true; } catch { } // Indicate that the sentence was recognized return result; }