/// <summary> /// Process the data from a VTG message. /// </summary> /// <param name="sentence">String array of the message components for a VTG message.</param> public void Process(NmeaSentence sentence) { //Debug.WriteLine($"VTGDecoder.Process"); var course = new CourseOverGround(); course.TalkerID = sentence.TalkerID; double trueHeading; if (double.TryParse(sentence.DataElements[0].ToString(), out trueHeading)) { course.TrueHeading = trueHeading; } double magneticHeading; if (double.TryParse(sentence.DataElements[2].ToString(), out magneticHeading)) { course.MagneticHeading = magneticHeading; } double knots; if (double.TryParse(sentence.DataElements[4].ToString(), out knots)) { course.Knots = knots; } double kph; if (double.TryParse(sentence.DataElements[6].ToString(), out kph)) { course.Kph = kph; } //Debug.WriteLine($"VTG process finished: trueHeading:{course.TrueHeading}, magneticHeading:{course.MagneticHeading}, knots:{course.Knots}, kph:{course.Kph}"); CourseAndVelocityReceived(this, course); }
private static void VtgDecoder_OnCourseAndVelocityReceived(object sender, CourseOverGround courseAndVelocity) { Console.WriteLine("Satellite information received."); Console.WriteLine("True heading: " + courseAndVelocity.TrueHeading.ToString("f2")); Console.WriteLine("Magnetic heading: " + courseAndVelocity.MagneticHeading.ToString("f2")); Console.WriteLine("Knots: " + courseAndVelocity.Knots.ToString("f2")); Console.WriteLine("KPH: " + courseAndVelocity.KPH.ToString("f2")); Console.WriteLine("*********************************************\n"); }
static void vtgDecoder_OnCourseAndVelocityReceived(object sender, CourseOverGround courseAndVelocity) { Debug.Print("Satellite information received."); Debug.Print("True heading: " + courseAndVelocity.TrueHeading.ToString("f2")); Debug.Print("Magnetic heading: " + courseAndVelocity.MagneticHeading.ToString("f2")); Debug.Print("Knots: " + courseAndVelocity.Knots.ToString("f2")); Debug.Print("KPH: " + courseAndVelocity.KPH.ToString("f2")); Debug.Print("*********************************************\n"); }
/// <summary> /// Process the data from a VTG message. /// </summary> /// <param name="data">String array of the message components for a VTG message.</param> public override void Process(string[] data) { if (OnCourseAndVelocityReceived != null) { var course = new CourseOverGround(); course.TrueHeading = Converters.Double(data[1]); course.MagneticHeading = Converters.Double(data[3]); course.Knots = Converters.Double(data[5]); course.KPH = Converters.Double(data[7]); OnCourseAndVelocityReceived(this, course); } }