private static void GsaDecoder_OnActiveSatelitesReceived(object sender, ActiveSatellites activeSatellites) { Console.WriteLine("Satellite information received."); Console.WriteLine("Number of satellites involved in fix: " + activeSatellites.SatellitesUsedForFix.Length); Console.WriteLine("Dilution of precision: " + activeSatellites.DilutionOfPrecision.ToString("f2")); Console.WriteLine("HDOP: " + activeSatellites.HorizontalDilutionOfPrecision.ToString("f2")); Console.WriteLine("VDOP: " + activeSatellites.VerticalDilutionOfPrecision.ToString("f2")); Console.WriteLine("*********************************************\n"); }
private static void gsaDecoder_OnActiveSatelitesReceived(object sender, ActiveSatellites activeSatellites) { gl.DrawText(0, 40, "#Sats:" + activeSatellites.SatellitesUsedForFix.Length); gl.Show(); Debug.Print("Satellite information received."); Debug.Print("Number of satellites involved in fix: " + activeSatellites.SatellitesUsedForFix.Length); Debug.Print("Dilution of precision: " + activeSatellites.DilutionOfPrecision.ToString("f2")); Debug.Print("HDOP: " + activeSatellites.HorizontalDilutionOfPrecision.ToString("f2")); Debug.Print("VDOP: " + activeSatellites.VerticalDilutionOfPrecision.ToString("f2")); Debug.Print("*********************************************\n"); }
/// <summary> /// Process the data from a GSA message. /// </summary> /// <param name="data">String array of the message components for a GSA message.</param> public override void Process(string[] data) { if (OnActiveSatellitesReceived != null) { var satellites = new ActiveSatellites(); switch (data[1].ToLower()) { case "a": satellites.SatelliteSelection = ActiveSatelliteSelection.Automatic; break; case "m": satellites.SatelliteSelection = ActiveSatelliteSelection.Manual; break; default: satellites.SatelliteSelection = ActiveSatelliteSelection.Unknown; break; } satellites.Demensions = (DimensionalFixType)int.Parse(data[2]); var satelliteCount = 0; for (var index = 3; index < 15; index++) { if ((data[index] != null) && (data[index] != "")) { satelliteCount++; } } if (satelliteCount > 0) { satellites.SatellitesUsedForFix = new string[satelliteCount]; var currentSatellite = 0; for (var index = 3; index < 15; index++) { if ((data[index] != null) && (data[index] != "")) { satellites.SatellitesUsedForFix[currentSatellite] = data[index]; currentSatellite++; } } } else { satellites.SatellitesUsedForFix = null; } satellites.DilutionOfPrecision = double.Parse(data[15]); satellites.HorizontalDilutionOfPrecision = double.Parse(data[16]); satellites.VerticalDilutionOfPrecision = double.Parse(data[17]); OnActiveSatellitesReceived(this, satellites); } }
/// <summary> /// Process the data from a GSA message. /// </summary> /// <param name="data">String array of the message components for a GSA message.</param> public void Process(NmeaSentence sentence) { //if (DebugMode) { Debug.WriteLine($"GSADecoder.Process"); } var satellites = new ActiveSatellites(); satellites.TalkerID = sentence.TalkerID; switch (sentence.DataElements[0].ToString().ToLower()) { case "a": satellites.SatelliteSelection = ActiveSatelliteSelection.Automatic; break; case "m": satellites.SatelliteSelection = ActiveSatelliteSelection.Manual; break; default: satellites.SatelliteSelection = ActiveSatelliteSelection.Unknown; break; } //if (DebugMode) { Debug.WriteLine($"satellite seletion:{satellites.SatelliteSelection}"); }; int dimensionalFixType; if (int.TryParse(sentence.DataElements[1].ToString(), out dimensionalFixType)) { satellites.Dimensions = (DimensionalFixType)dimensionalFixType; } //if (DebugMode) { Debug.WriteLine($"dimensional fix type:{satellites.Dimensions}"); }; var satelliteCount = 0; for (var index = 2; index < 14; index++) { if (!string.IsNullOrEmpty(sentence.DataElements[index].ToString())) { satelliteCount++; } } if (satelliteCount > 0) { satellites.SatellitesUsedForFix = new string[satelliteCount]; var currentSatellite = 0; for (var index = 2; index < 14; index++) { if (!string.IsNullOrEmpty(sentence.DataElements[index].ToString())) { satellites.SatellitesUsedForFix[currentSatellite] = sentence.DataElements[index].ToString(); currentSatellite++; } } } else { satellites.SatellitesUsedForFix = null; } double dilutionOfPrecision; if (double.TryParse(sentence.DataElements[14].ToString(), out dilutionOfPrecision)) { satellites.DilutionOfPrecision = dilutionOfPrecision; } double horizontalDilutionOfPrecision; if (double.TryParse(sentence.DataElements[15].ToString(), out horizontalDilutionOfPrecision)) { satellites.HorizontalDilutionOfPrecision = horizontalDilutionOfPrecision; } double verticalDilutionOfPrecision; if (double.TryParse(sentence.DataElements[16].ToString(), out verticalDilutionOfPrecision)) { satellites.VerticalDilutionOfPrecision = verticalDilutionOfPrecision; } //Debug.WriteLine($"GSADecoder.Process complete; satelliteCount:{satelliteCount}"); ActiveSatellitesReceived(this, satellites); }