Added GPGST message

This commit is contained in:
mort5161 2015-03-20 15:16:38 -07:00
parent dfc02b986c
commit 61aa1ac833
3 changed files with 128 additions and 4 deletions

View file

@ -0,0 +1,105 @@
//
// Copyright (c) 2014 Morten Nielsen
//
// Licensed under the Microsoft Public License (Ms-PL) (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://opensource.org/licenses/Ms-PL.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NmeaParser.Nmea.Gps
{
/// <summary>
/// Position error statistics
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgst")]
[NmeaMessageType("GPGST")]
public class Gpgst : NmeaMessage
{
/// <summary>
/// Called when the message is being loaded.
/// </summary>
/// <param name="message">The NMEA message values.</param>
protected override void OnLoadMessage(string[] message)
{
if (message == null || message.Length < 8)
throw new ArgumentException("Invalid GPGST", "message");
if (message[0].Length >= 6)
{
FixTime = new TimeSpan(int.Parse(message[0].Substring(0, 2), CultureInfo.InvariantCulture),
int.Parse(message[0].Substring(2, 2), CultureInfo.InvariantCulture), 0)
.Add(TimeSpan.FromSeconds(double.Parse(message[0].Substring(4), CultureInfo.InvariantCulture)));
}
Rms = NmeaMessage.StringToDouble(message[1]);
SemiMajorError = NmeaMessage.StringToDouble(message[2]);
SemiMinorError = NmeaMessage.StringToDouble(message[3]);
ErrorOrientation = NmeaMessage.StringToDouble(message[4]);
SigmaLatitudeError = NmeaMessage.StringToDouble(message[5]);
SigmaLongitudeError = NmeaMessage.StringToDouble(message[6]);
SigmaHeightError = NmeaMessage.StringToDouble(message[7]);
}
/// <summary>
/// UTC of position fix
/// </summary>
public TimeSpan FixTime { get; private set; }
/// <summary>
/// RMS value of the pseudorange residuals; includes carrier phase residuals during periods of RTK (float) and RTK (fixed) processing
/// </summary>
public double Rms { get; private set; }
/// <summary>
/// Error ellipse semi-major axis 1 sigma error, in meters
/// </summary>
public double SemiMajorError { get; private set; }
/// <summary>
/// Error ellipse semi-minor axis 1 sigma error, in meters
/// </summary>
public double SemiMinorError { get; private set; }
/// <summary>
/// Error ellipse orientation, degrees from true north
/// </summary>
public double ErrorOrientation { get; private set; }
/// <summary>
/// Latitude 1 sigma error, in meters
/// </summary>
/// <remarks>
/// The error expressed as one standard deviation.
/// </remarks>
public double SigmaLatitudeError { get; private set; }
/// <summary >
/// Longitude 1 sigma error, in meters
/// </summary>
/// <remarks>
/// The error expressed as one standard deviation.
/// </remarks>
public double SigmaLongitudeError { get; private set; }
/// <summary >
/// Height 1 sigma error, in meters
/// </summary>
/// <remarks>
/// The error expressed as one standard deviation.
/// </remarks>
public double SigmaHeightError { get; private set; }
}
}

View file

@ -17,6 +17,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\Garmin\PGRME.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\GPGLL.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\GPBOD.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\GPGST.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\GPRTE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\GPGSV.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Nmea\Gps\GPGSA.cs" />

View file

@ -37,17 +37,17 @@ namespace NmeaParser.Tests
while(!reader.EndOfStream)
{
var line = reader.ReadLine();
if(line.StartsWith("$"))
if (line.StartsWith("$"))
{
var msg = NmeaMessage.Parse(line);
Assert.IsNotNull(msg);
var msg = NmeaMessage.Parse(line);
Assert.IsNotNull(msg);
var idx = line.IndexOf('*');
if (idx >= 0)
{
byte checksum = (byte)Convert.ToInt32(line.Substring(idx + 1), 16);
Assert.AreEqual(checksum, msg.Checksum);
}
Assert.IsNotInstanceOfType(msg, typeof(Nmea.UnknownMessage), "Type " + msg.MessageType + " not supported");
Assert.IsNotInstanceOfType(msg, typeof(Nmea.UnknownMessage), "Type " + msg.MessageType + " not supported");
}
}
}
@ -356,5 +356,23 @@ namespace NmeaParser.Tests
Assert.AreEqual("32BKLD", gsv.Waypoints[4]);
Assert.AreEqual("BW-198", gsv.Waypoints[8]);
}
[TestMethod]
public void TestGpgst()
{
string input = "$GPGST,172814.0,0.006,0.023,0.020,273.6,0.023,0.020,0.031*6A";
var msg = NmeaMessage.Parse(input);
Assert.IsInstanceOfType(msg, typeof(Gpgst));
Gpgst gst = (Gpgst)msg;
Assert.AreEqual(new TimeSpan(17, 28, 14), gst.FixTime);
Assert.AreEqual(0.006, gst.Rms);
Assert.AreEqual(0.023, gst.SemiMajorError);
Assert.AreEqual(0.02, gst.SemiMinorError);
Assert.AreEqual(273.6, gst.ErrorOrientation);
Assert.AreEqual(0.023, gst.SigmaLatitudeError);
Assert.AreEqual(0.020, gst.SigmaLongitudeError);
Assert.AreEqual(0.031, gst.SigmaHeightError);
}
}
}