Added ModeIndicator to GLL

This commit is contained in:
Morten Nielsen 2019-02-26 00:31:15 -08:00
parent 0c19f097c5
commit 95fea42930
2 changed files with 39 additions and 1 deletions

View file

@ -44,7 +44,20 @@ namespace NmeaParser.Nmea
FixTime = StringToTimeSpan(message[4]);
}
DataActive = (message.Length < 6 || message[5] == "A");
}
ModeIndicator = DataActive ? Mode.Autonomous : Mode.DataNotValid;
if (message.Length > 6)
{
switch (message[6])
{
case "A": ModeIndicator = Mode.Autonomous; break;
case "D": ModeIndicator = Mode.DataNotValid; break;
case "E": ModeIndicator = Mode.EstimatedDeadReckoning; break;
case "M": ModeIndicator = Mode.Manual; break;
case "S": ModeIndicator = Mode.Simulator; break;
case "N": ModeIndicator = Mode.DataNotValid; break;
}
}
}
/// <summary>
/// Latitude
@ -69,5 +82,16 @@ namespace NmeaParser.Nmea
/// </value>
public bool DataActive { get; }
public Mode ModeIndicator { get; }
public enum Mode
{
Autonomous,
Differential,
EstimatedDeadReckoning,
Manual,
Simulator,
DataNotValid
}
}
}

View file

@ -368,6 +368,20 @@ namespace NmeaParser.Tests
Assert.AreEqual(-117.196813151667, gll.Longitude, .000000000001);
Assert.AreEqual(new TimeSpan(0, 23, 57, 15, 0), gll.FixTime);
}
[TestMethod]
public void TestLcgll()
{
string input = "$LCGLL,4728.31,N,12254.25,W,091342,A,A*4C";
var msg = NmeaMessage.Parse(input);
Assert.IsInstanceOfType(msg, typeof(Gll));
Gll gll = (Gll)msg;
Assert.AreEqual(Talker.LoranC, gll.TalkerId);
Assert.IsTrue(gll.DataActive);
Assert.AreEqual(47.471833333333336, gll.Latitude);
Assert.AreEqual(-122.90416666666667, gll.Longitude);
Assert.AreEqual(new TimeSpan(0, 9, 13, 42, 0), gll.FixTime);
Assert.AreEqual(Gll.Mode.Autonomous, gll.ModeIndicator);
}