From f392416cdde4e7dfb29e0d385ecb99aa34d011e4 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Mon, 25 Feb 2019 23:41:13 -0800 Subject: [PATCH] Very large refactoring moving from talker-specific classes to generic message classes, and instead expose talker-type on the base-class. --- src/NmeaParser/Nmea/{Gps/GPBOD.cs => Bod.cs} | 14 +- src/NmeaParser/Nmea/Galileo/Gagsv.cs | 41 --- src/NmeaParser/Nmea/{Gps => }/Garmin/PGRME.cs | 2 +- src/NmeaParser/Nmea/{Gps => }/Garmin/PGRMZ.cs | 0 src/NmeaParser/Nmea/Gga.cs | 40 ++- src/NmeaParser/Nmea/Gll.cs | 5 +- src/NmeaParser/Nmea/Glonass/Glgns.cs | 21 -- src/NmeaParser/Nmea/Glonass/Glgsv.cs | 41 --- src/NmeaParser/Nmea/Glonass/Glzda.cs | 17 -- src/NmeaParser/Nmea/Gns.cs | 5 +- src/NmeaParser/Nmea/Gnss/Gngga.cs | 40 --- src/NmeaParser/Nmea/Gnss/Gngll.cs | 40 --- src/NmeaParser/Nmea/Gnss/Gngns.cs | 21 -- src/NmeaParser/Nmea/Gnss/Gngsa.cs | 40 --- src/NmeaParser/Nmea/Gnss/Gngst.cs | 19 -- src/NmeaParser/Nmea/Gnss/Gnrmc.cs | 40 --- src/NmeaParser/Nmea/Gnss/Gnzda.cs | 17 -- src/NmeaParser/Nmea/Gps/GPGGA.cs | 69 ----- src/NmeaParser/Nmea/Gps/GPGLL.cs | 40 --- src/NmeaParser/Nmea/Gps/GPGSA.cs | 74 ----- src/NmeaParser/Nmea/Gps/GPGST.cs | 40 --- src/NmeaParser/Nmea/Gps/GPGSV.cs | 120 -------- src/NmeaParser/Nmea/Gps/GPRMC.cs | 40 --- src/NmeaParser/Nmea/Gps/GPZDA.cs | 17 -- src/NmeaParser/Nmea/Gps/Gpgns.cs | 21 -- src/NmeaParser/Nmea/Gsa.cs | 159 ++++++----- src/NmeaParser/Nmea/Gst.cs | 5 +- src/NmeaParser/Nmea/Gsv.cs | 205 +++++++++----- src/NmeaParser/Nmea/NmeaMessage.cs | 142 +++++----- src/NmeaParser/Nmea/{Gps/GPRMB.cs => Rmb.cs} | 10 +- src/NmeaParser/Nmea/Rmc.cs | 5 +- src/NmeaParser/Nmea/{Gps/GPRTE.cs => Rte.cs} | 15 +- src/NmeaParser/Nmea/Talker.cs | 257 ++++++++++++++++++ src/NmeaParser/Nmea/{Gps/GPVTG.cs => Vtg.cs} | 11 +- src/NmeaParser/Nmea/Zda.cs | 5 +- src/NmeaParser/NmeaParser.csproj | 7 +- .../Properties/AndroidManifest.xml | 2 +- src/SampleApp.Droid/SampleApp.Droid.csproj | 1 - src/SampleApp.WinDesktop/MainWindow.xaml.cs | 4 +- src/SampleApp.WinDesktop/PgrmeControl.xaml.cs | 3 +- src/UnitTests/NmeaParser.Tests/DeviceTests.cs | 22 +- .../NmeaParser.Tests/NmeaMessages.cs | 150 +++++----- 42 files changed, 757 insertions(+), 1070 deletions(-) rename src/NmeaParser/Nmea/{Gps/GPBOD.cs => Bod.cs} (84%) delete mode 100644 src/NmeaParser/Nmea/Galileo/Gagsv.cs rename src/NmeaParser/Nmea/{Gps => }/Garmin/PGRME.cs (98%) rename src/NmeaParser/Nmea/{Gps => }/Garmin/PGRMZ.cs (100%) delete mode 100644 src/NmeaParser/Nmea/Glonass/Glgns.cs delete mode 100644 src/NmeaParser/Nmea/Glonass/Glgsv.cs delete mode 100644 src/NmeaParser/Nmea/Glonass/Glzda.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gngga.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gngll.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gngns.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gngsa.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gngst.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gnrmc.cs delete mode 100644 src/NmeaParser/Nmea/Gnss/Gnzda.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPGGA.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPGLL.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPGSA.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPGST.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPGSV.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPRMC.cs delete mode 100644 src/NmeaParser/Nmea/Gps/GPZDA.cs delete mode 100644 src/NmeaParser/Nmea/Gps/Gpgns.cs rename src/NmeaParser/Nmea/{Gps/GPRMB.cs => Rmb.cs} (93%) rename src/NmeaParser/Nmea/{Gps/GPRTE.cs => Rte.cs} (82%) create mode 100644 src/NmeaParser/Nmea/Talker.cs rename src/NmeaParser/Nmea/{Gps/GPVTG.cs => Vtg.cs} (87%) diff --git a/src/NmeaParser/Nmea/Gps/GPBOD.cs b/src/NmeaParser/Nmea/Bod.cs similarity index 84% rename from src/NmeaParser/Nmea/Gps/GPBOD.cs rename to src/NmeaParser/Nmea/Bod.cs index 61feb75..f2468d8 100644 --- a/src/NmeaParser/Nmea/Gps/GPBOD.cs +++ b/src/NmeaParser/Nmea/Bod.cs @@ -21,21 +21,25 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NmeaParser.Nmea.Gps +namespace NmeaParser.Nmea { /// /// Bearing Origin to Destination /// + /// + /// Bearing angle of the line, calculated at the origin waypoint, extending to the destination waypoint from + /// the origin waypoint for the active navigation leg of the journey + /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpbod")] - [NmeaMessageType("GPBOD")] - public class Gpbod : NmeaMessage + [NmeaMessageType("--BOD")] + public class Bod : NmeaMessage { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - public Gpbod(string type, string[] message) : base(type, message) + public Bod(string type, string[] message) : base(type, message) { if (message == null || message.Length < 3) throw new ArgumentException("Invalid GPBOD", "message"); diff --git a/src/NmeaParser/Nmea/Galileo/Gagsv.cs b/src/NmeaParser/Nmea/Galileo/Gagsv.cs deleted file mode 100644 index a87ba9e..0000000 --- a/src/NmeaParser/Nmea/Galileo/Gagsv.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// 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.Galileo -{ - /// - /// GALILEO Satellites in view - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gagsv")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [NmeaMessageType("GAGSV")] - public sealed class Gagsv : Gsv - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gagsv(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/Garmin/PGRME.cs b/src/NmeaParser/Nmea/Garmin/PGRME.cs similarity index 98% rename from src/NmeaParser/Nmea/Gps/Garmin/PGRME.cs rename to src/NmeaParser/Nmea/Garmin/PGRME.cs index 649d9dd..b8f7d78 100644 --- a/src/NmeaParser/Nmea/Gps/Garmin/PGRME.cs +++ b/src/NmeaParser/Nmea/Garmin/PGRME.cs @@ -21,7 +21,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NmeaParser.Nmea.Gps.Garmin +namespace NmeaParser.Nmea.Garmin { /// /// Recommended Minimum diff --git a/src/NmeaParser/Nmea/Gps/Garmin/PGRMZ.cs b/src/NmeaParser/Nmea/Garmin/PGRMZ.cs similarity index 100% rename from src/NmeaParser/Nmea/Gps/Garmin/PGRMZ.cs rename to src/NmeaParser/Nmea/Garmin/PGRMZ.cs diff --git a/src/NmeaParser/Nmea/Gga.cs b/src/NmeaParser/Nmea/Gga.cs index 943c0bf..e163616 100644 --- a/src/NmeaParser/Nmea/Gga.cs +++ b/src/NmeaParser/Nmea/Gga.cs @@ -27,21 +27,22 @@ namespace NmeaParser.Nmea /// Global Positioning System Fix Data /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgga")] - public abstract class Gga : NmeaMessage + [NmeaMessageType("--GGA")] + public class Gga : NmeaMessage { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Gga(string type, string[] message) : base(type, message) + public Gga(string type, string[] message) : base(type, message) { if (message == null || message.Length < 14) throw new ArgumentException("Invalid GPGGA", "message"); FixTime = StringToTimeSpan(message[0]); Latitude = NmeaMessage.StringToLatitude(message[1], message[2]); Longitude = NmeaMessage.StringToLongitude(message[3], message[4]); - Quality = (Gps.Gpgga.FixQuality)int.Parse(message[5], CultureInfo.InvariantCulture); + Quality = (Gga.FixQuality)int.Parse(message[5], CultureInfo.InvariantCulture); NumberOfSatellites = int.Parse(message[6], CultureInfo.InvariantCulture); Hdop = NmeaMessage.StringToDouble(message[7]); Altitude = NmeaMessage.StringToDouble(message[8]); @@ -77,7 +78,7 @@ namespace NmeaParser.Nmea /// /// Fix Quality /// - public Gps.Gpgga.FixQuality Quality { get; } + public Gga.FixQuality Quality { get; } /// /// Number of satellites being tracked @@ -119,5 +120,34 @@ namespace NmeaParser.Nmea /// DGPS Station ID Number /// public int DgpsStationId { get; } - } + + /// + /// Fix quality + /// + public enum FixQuality : int + { + /// Invalid + Invalid = 0, + /// GPS + GpsFix = 1, + /// Differential GPS + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dgps")] + DgpsFix = 2, + /// Precise Positioning Service + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pps")] + PpsFix = 3, + /// Real Time Kinematic (Fixed) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rtk")] + Rtk = 4, + /// Real Time Kinematic (Floating) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rtk")] + FloatRtk = 5, + /// Estimated + Estimated = 6, + /// Manual input + ManualInput = 7, + /// Simulation + Simulation = 8 + } + } } diff --git a/src/NmeaParser/Nmea/Gll.cs b/src/NmeaParser/Nmea/Gll.cs index 56a2585..8c7843f 100644 --- a/src/NmeaParser/Nmea/Gll.cs +++ b/src/NmeaParser/Nmea/Gll.cs @@ -27,14 +27,15 @@ namespace NmeaParser.Nmea /// Geographic position, latitude / longitude /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gll")] - public abstract class Gll : NmeaMessage + [NmeaMessageType("--GLL")] + public class Gll : NmeaMessage { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Gll(string type, string[] message) : base(type, message) + public Gll(string type, string[] message) : base(type, message) { if (message == null || message.Length < 4) throw new ArgumentException("Invalid GPGLL", "message"); diff --git a/src/NmeaParser/Nmea/Glonass/Glgns.cs b/src/NmeaParser/Nmea/Glonass/Glgns.cs deleted file mode 100644 index 00d6891..0000000 --- a/src/NmeaParser/Nmea/Glonass/Glgns.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace NmeaParser.Nmea.Glonass -{ - /// - /// Fix data for GLONASS satellite navigation systems - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Glgns")] - [NmeaMessageType("GLGNS")] - public class Glgns : Gns - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Glgns(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Glonass/Glgsv.cs b/src/NmeaParser/Nmea/Glonass/Glgsv.cs deleted file mode 100644 index a54e1de..0000000 --- a/src/NmeaParser/Nmea/Glonass/Glgsv.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// 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.Glonass -{ - /// - /// GLONASS Satellites in view - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Glgsv")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [NmeaMessageType("GLGSV")] - public sealed class Glgsv : Gsv - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Glgsv(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Glonass/Glzda.cs b/src/NmeaParser/Nmea/Glonass/Glzda.cs deleted file mode 100644 index e1b5be3..0000000 --- a/src/NmeaParser/Nmea/Glonass/Glzda.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace NmeaParser.Nmea.Glonass -{ - /// - /// Date and time of fix - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Glzda")] - [NmeaMessageType("GLZDA")] - public class Glzda : Zda - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Glzda(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gns.cs b/src/NmeaParser/Nmea/Gns.cs index 4278c18..8ba1420 100644 --- a/src/NmeaParser/Nmea/Gns.cs +++ b/src/NmeaParser/Nmea/Gns.cs @@ -27,7 +27,8 @@ namespace NmeaParser.Nmea /// Fixes data for single or combined (GPS, GLONASS, possible future satellite systems, and systems combining these) satellite navigation systems /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gns")] - public abstract class Gns : NmeaMessage + [NmeaMessageType("--GNS")] + public class Gns : NmeaMessage { /* * Example of GNS messages: @@ -124,7 +125,7 @@ namespace NmeaParser.Nmea /// /// The message type /// The NMEA message values. - protected Gns(string type, string[] message) : base(type, message) + public Gns(string type, string[] message) : base(type, message) { if (message == null || message.Length < 12) throw new ArgumentException("Invalid GNS", "message"); diff --git a/src/NmeaParser/Nmea/Gnss/Gngga.cs b/src/NmeaParser/Nmea/Gnss/Gngga.cs deleted file mode 100644 index 2332652..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gngga.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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.Gnss -{ - /// - /// Global Positioning System Fix Data - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gngga")] - [NmeaMessageType("GNGGA")] - public class Gngga : Gga - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gngga(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gnss/Gngll.cs b/src/NmeaParser/Nmea/Gnss/Gngll.cs deleted file mode 100644 index 2417e82..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gngll.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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.Gnss -{ - /// - /// Geographic position, latitude / longitude - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gngll")] - [NmeaMessageType("GNGLL")] - public class Gngll : Gll - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gngll(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gnss/Gngns.cs b/src/NmeaParser/Nmea/Gnss/Gngns.cs deleted file mode 100644 index d1c1588..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gngns.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace NmeaParser.Nmea.Gps -{ - /// - /// Fixes data for single or combined (GPS, GLONASS, possible future satellite systems, and systems combining these) satellite navigation systems - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gngns")] - [NmeaMessageType("GNGNS")] - public class Gngns : Gns - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gngns(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gnss/Gngsa.cs b/src/NmeaParser/Nmea/Gnss/Gngsa.cs deleted file mode 100644 index 5ccd65e..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gngsa.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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.Gnss -{ - /// - /// Global Positioning System Fix Data - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gngsa")] - [NmeaMessageType("GNGSA")] - public class Gngsa : Gsa - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gngsa(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gnss/Gngst.cs b/src/NmeaParser/Nmea/Gnss/Gngst.cs deleted file mode 100644 index c69b74d..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gngst.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace NmeaParser.Nmea.Gnss -{ - /// - /// Position error statistics - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gngst")] - [NmeaMessageType("GNGST")] - public class Gngst : Gst - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gngst(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gnss/Gnrmc.cs b/src/NmeaParser/Nmea/Gnss/Gnrmc.cs deleted file mode 100644 index 9e6005b..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gnrmc.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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.Gnss -{ - /// - /// Recommended Minimum - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gnrmc")] - [NmeaMessageType("GNRMC")] - public class Gnrmc : Rmc - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gnrmc(string type, string[] message) : base(type, message) { } - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gnss/Gnzda.cs b/src/NmeaParser/Nmea/Gnss/Gnzda.cs deleted file mode 100644 index 15f4198..0000000 --- a/src/NmeaParser/Nmea/Gnss/Gnzda.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace NmeaParser.Nmea.Gnss -{ - /// - /// Date and time of fix - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gnzda")] - [NmeaMessageType("GNZDA")] - public class Gnzda : Zda - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gnzda(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/GPGGA.cs b/src/NmeaParser/Nmea/Gps/GPGGA.cs deleted file mode 100644 index 62a78a8..0000000 --- a/src/NmeaParser/Nmea/Gps/GPGGA.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// 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 -{ - /// - /// Global Positioning System Fix Data - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgga")] - [NmeaMessageType("GPGGA")] - public class Gpgga : Gga - { - /// - /// Fix quality - /// - public enum FixQuality : int - { - /// Invalid - Invalid = 0, - /// GPS - GpsFix = 1, - /// Differential GPS - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dgps")] - DgpsFix = 2, - /// Precise Positioning Service - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pps")] - PpsFix = 3, - /// Real Time Kinematic (Fixed) - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rtk")] - Rtk = 4, - /// Real Time Kinematic (Floating) - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rtk")] - FloatRtk = 5, - /// Estimated - Estimated = 6, - /// Manual input - ManualInput = 7, - /// Simulation - Simulation = 8 - } - - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpgga(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/GPGLL.cs b/src/NmeaParser/Nmea/Gps/GPGLL.cs deleted file mode 100644 index a8385b7..0000000 --- a/src/NmeaParser/Nmea/Gps/GPGLL.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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 -{ - /// - /// Geographic position, latitude / longitude - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgll")] - [NmeaMessageType("GPGLL")] - public class Gpgll : Gll - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpgll(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/GPGSA.cs b/src/NmeaParser/Nmea/Gps/GPGSA.cs deleted file mode 100644 index 7f9739f..0000000 --- a/src/NmeaParser/Nmea/Gps/GPGSA.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// 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 -{ - /// - /// Global Positioning System Fix Data - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgsa")] - [NmeaMessageType("GPGSA")] - public class Gpgsa : Gsa - { - /// - /// Mode selection - /// - public enum ModeSelection - { - /// - /// Auto - /// - Auto, - /// - /// Manual mode - /// - Manual, - } - /// - /// Fix Mode - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Justification = "Enum values matches NMEA spec")] - public enum Mode : int - { - /// - /// Not available - /// - NotAvailable = 1, - /// - /// 2D Fix - /// - Fix2D = 2, - /// - /// 3D Fix - /// - Fix3D = 3 - } - - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpgsa(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/GPGST.cs b/src/NmeaParser/Nmea/Gps/GPGST.cs deleted file mode 100644 index 6e4a329..0000000 --- a/src/NmeaParser/Nmea/Gps/GPGST.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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 -{ - /// - /// Position error statistics - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgst")] - [NmeaMessageType("GPGST")] - public class Gpgst : Gst - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpgst(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/GPGSV.cs b/src/NmeaParser/Nmea/Gps/GPGSV.cs deleted file mode 100644 index b094779..0000000 --- a/src/NmeaParser/Nmea/Gps/GPGSV.cs +++ /dev/null @@ -1,120 +0,0 @@ -// -// 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 -{ - /// - /// GLONASS Satellites in view - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgsv")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [NmeaMessageType("GPGSV")] - public sealed class Gpgsv : Gsv - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpgsv(string type, string[] message) : base(type, message) { } - } - - /// - /// Satellite vehicle - /// - public sealed class SatelliteVehicle - { - internal SatelliteVehicle(string[] message, int startIndex) - { - PrnNumber = int.Parse(message[startIndex], CultureInfo.InvariantCulture); - Elevation = double.Parse(message[startIndex + 1], CultureInfo.InvariantCulture); - Azimuth = double.Parse(message[startIndex + 2], CultureInfo.InvariantCulture); - int snr = -1; - if (int.TryParse(message[startIndex + 3], out snr)) - SignalToNoiseRatio = snr; - } - /// - /// SV PRN number - /// - public int PrnNumber { get; } - /// - /// Elevation in degrees, 90 maximum - /// - public double Elevation{ get; } - /// - /// Azimuth, degrees from true north, 000 to 359 - /// - public double Azimuth{ get; } - /// - /// Signal-to-Noise ratio, 0-99 dB (-1 when not tracking) - /// - public int SignalToNoiseRatio{ get; } - - /// - /// Satellite system - /// - public SatelliteSystem System - { - get - { - if (PrnNumber >= 1 && PrnNumber <= 32) - return SatelliteSystem.Gps; - if (PrnNumber >= 33 && PrnNumber <= 64) - return SatelliteSystem.Waas; - if (PrnNumber >= 65 && PrnNumber <= 96) - return SatelliteSystem.Glonass; - return SatelliteSystem.Unknown; - } - } - } - - /// - /// Satellite system - /// - public enum SatelliteSystem - { - /// - /// Unknown - /// - Unknown, - /// - /// GPS - Global Positioning System (NAVSTAR) - /// - Gps, - /// - /// WAAS - Wide Area Augmentation System - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Waas")] - Waas, - /// - /// GLONASS - Globalnaya navigatsionnaya sputnikovaya sistema - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Glonass")] - Glonass, - /// - /// Galileo - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Galileo")] - Galileo - } -} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gps/GPRMC.cs b/src/NmeaParser/Nmea/Gps/GPRMC.cs deleted file mode 100644 index 2f7f5c9..0000000 --- a/src/NmeaParser/Nmea/Gps/GPRMC.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// 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 -{ - /// - /// Recommended Minimum - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprmc")] - [NmeaMessageType("GPRMC")] - public class Gprmc : Rmc - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gprmc(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/GPZDA.cs b/src/NmeaParser/Nmea/Gps/GPZDA.cs deleted file mode 100644 index 28744dd..0000000 --- a/src/NmeaParser/Nmea/Gps/GPZDA.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace NmeaParser.Nmea.Gps -{ - /// - /// Date and time of fix - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpzda")] - [NmeaMessageType("GPZDA")] - public class Gpzda : Zda - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpzda(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gps/Gpgns.cs b/src/NmeaParser/Nmea/Gps/Gpgns.cs deleted file mode 100644 index 6cb7f18..0000000 --- a/src/NmeaParser/Nmea/Gps/Gpgns.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace NmeaParser.Nmea.Gps -{ - /// - /// Fixes data for GPS satellite navigation systems - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgns")] - [NmeaMessageType("GPGNS")] - public class Gpgns : Gns - { - /// - /// Initializes a new instance of the class. - /// - /// The message type - /// The NMEA message values. - public Gpgns(string type, string[] message) : base(type, message) { } - } -} diff --git a/src/NmeaParser/Nmea/Gsa.cs b/src/NmeaParser/Nmea/Gsa.cs index a908f1c..65829cf 100644 --- a/src/NmeaParser/Nmea/Gsa.cs +++ b/src/NmeaParser/Nmea/Gsa.cs @@ -23,82 +23,117 @@ using System.Threading.Tasks; namespace NmeaParser.Nmea { - /// - /// Global Positioning System Fix Data - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gsa")] - public abstract class Gsa : NmeaMessage - { + /// + /// Global Positioning System Fix Data + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gsa")] + [NmeaMessageType("--GSA")] + public class Gsa : NmeaMessage + { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Gsa(string type, string[] message) : base(type, message) + public Gsa(string type, string[] message) : base(type, message) { if (message == null || message.Length < 17) - throw new ArgumentException("Invalid GPGSA", "message"); - - GpsMode = message[0] == "A" ? Gps.Gpgsa.ModeSelection.Auto : Gps.Gpgsa.ModeSelection.Manual; - FixMode = (Gps.Gpgsa.Mode)int.Parse(message[1], CultureInfo.InvariantCulture); + throw new ArgumentException("Invalid GPGSA", "message"); - List svs = new List(); - for (int i = 2; i < 14; i++) - { - int id = -1; - if (message[i].Length > 0 && int.TryParse(message[i], out id)) - svs.Add(id); - } - SVs = svs.ToArray(); + GpsMode = message[0] == "A" ? Gsa.ModeSelection.Auto : Gsa.ModeSelection.Manual; + FixMode = (Gsa.Mode)int.Parse(message[1], CultureInfo.InvariantCulture); - double tmp; - if (double.TryParse(message[14], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) - Pdop = tmp; - else - Pdop = double.NaN; + List svs = new List(); + for (int i = 2; i < 14; i++) + { + int id = -1; + if (message[i].Length > 0 && int.TryParse(message[i], out id)) + svs.Add(id); + } + SVs = svs.ToArray(); - if (double.TryParse(message[15], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) - Hdop = tmp; - else - Hdop = double.NaN; + double tmp; + if (double.TryParse(message[14], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) + Pdop = tmp; + else + Pdop = double.NaN; - if (double.TryParse(message[16], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) - Vdop = tmp; - else - Vdop = double.NaN; - } + if (double.TryParse(message[15], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) + Hdop = tmp; + else + Hdop = double.NaN; - /// - /// Mode - /// - public Gps.Gpgsa.ModeSelection GpsMode { get; } + if (double.TryParse(message[16], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) + Vdop = tmp; + else + Vdop = double.NaN; + } - /// - /// Mode - /// - public Gps.Gpgsa.Mode FixMode { get; } + /// + /// Mode + /// + public ModeSelection GpsMode { get; } - /// - /// IDs of SVs used in position fix - /// - public IReadOnlyList SVs { get; } + /// + /// Mode + /// + public Mode FixMode { get; } - /// - /// Dilution of precision - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pdop")] - public double Pdop { get; } + /// + /// IDs of SVs used in position fix + /// + public IReadOnlyList SVs { get; } - /// - /// Horizontal dilution of precision - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hdop")] - public double Hdop { get; } + /// + /// Dilution of precision + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pdop")] + public double Pdop { get; } - /// - /// Vertical dilution of precision - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vdop")] - public double Vdop { get; } - } -} + /// + /// Horizontal dilution of precision + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hdop")] + public double Hdop { get; } + + /// + /// Vertical dilution of precision + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vdop")] + public double Vdop { get; } + + /// + /// Mode selection + /// + public enum ModeSelection + { + /// + /// Auto + /// + Auto, + /// + /// Manual mode + /// + Manual, + } + /// + /// Fix Mode + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Justification = "Enum values matches NMEA spec")] + public enum Mode : int + { + /// + /// Not available + /// + NotAvailable = 1, + /// + /// 2D Fix + /// + Fix2D = 2, + /// + /// 3D Fix + /// + Fix3D = 3 + } + } +} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/Gst.cs b/src/NmeaParser/Nmea/Gst.cs index 79e2e5e..0fbc62e 100644 --- a/src/NmeaParser/Nmea/Gst.cs +++ b/src/NmeaParser/Nmea/Gst.cs @@ -27,14 +27,15 @@ namespace NmeaParser.Nmea /// Position error statistics /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgst")] - public abstract class Gst : NmeaMessage + [NmeaMessageType("--GST")] + public class Gst : NmeaMessage { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Gst(string type, string[] message) : base(type, message) + public Gst(string type, string[] message) : base(type, message) { if (message == null || message.Length < 8) throw new ArgumentException("Invalid GPGST", "message"); diff --git a/src/NmeaParser/Nmea/Gsv.cs b/src/NmeaParser/Nmea/Gsv.cs index ba96b97..4bf575c 100644 --- a/src/NmeaParser/Nmea/Gsv.cs +++ b/src/NmeaParser/Nmea/Gsv.cs @@ -23,76 +23,155 @@ using System.Text; using System.Threading.Tasks; namespace NmeaParser.Nmea -{ - /// - /// GPS Satellites in view - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gsv")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - public abstract class Gsv : NmeaMessage, IMultiPartMessage - { +{ + /// + /// GPS Satellites in view + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gsv")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] + [NmeaMessageType("--GSV")] + public class Gsv : NmeaMessage, IMultiPartMessage + { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Gsv(string type, string[] message) : base(type, message) + public Gsv(string type, string[] message) : base(type, message) { - if (message == null || message.Length < 3) - throw new ArgumentException("Invalid GSV", "message"); - - TotalMessages = int.Parse(message[0], CultureInfo.InvariantCulture); - MessageNumber = int.Parse(message[1], CultureInfo.InvariantCulture); - SVsInView = int.Parse(message[2], CultureInfo.InvariantCulture); - - List svs = new List(); - for (int i = 3; i < message.Length - 3; i += 4) - { - if (message[i].Length == 0) - continue; - else - svs.Add(new SatelliteVehicle(message, i)); - } - this.SVs = svs.ToArray(); - } - - /// - /// Total number of messages of this type in this cycle - /// - public int TotalMessages { get; } - - /// - /// Message number - /// - public int MessageNumber { get; } - - /// - /// Total number of SVs in view - /// - public int SVsInView { get; } - - /// - /// Satellite vehicles in this message part. - /// - public IReadOnlyList SVs { get; } - + if (message == null || message.Length < 3) + throw new ArgumentException("Invalid GSV", "message"); + + TotalMessages = int.Parse(message[0], CultureInfo.InvariantCulture); + MessageNumber = int.Parse(message[1], CultureInfo.InvariantCulture); + SVsInView = int.Parse(message[2], CultureInfo.InvariantCulture); + + List svs = new List(); + for (int i = 3; i < message.Length - 3; i += 4) + { + if (message[i].Length == 0) + continue; + else + svs.Add(new SatelliteVehicle(message, i)); + } + this.SVs = svs.ToArray(); + } + + /// + /// Total number of messages of this type in this cycle + /// + public int TotalMessages { get; } + + /// + /// Message number + /// + public int MessageNumber { get; } + + /// + /// Total number of SVs in view + /// + public int SVsInView { get; } + + /// + /// Satellite vehicles in this message part. + /// + public IReadOnlyList SVs { get; } + /// /// Returns an enumerator that iterates through the collection. /// /// A System.Collections.Generic.IEnumerator{SatelliteVehicle} that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - foreach(var sv in SVs) - yield return sv; - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// An System.Collections.IEnumerator object that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} + public IEnumerator GetEnumerator() + { + foreach (var sv in SVs) + yield return sv; + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// An System.Collections.IEnumerator object that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } + /// + /// Satellite vehicle + /// + public sealed class SatelliteVehicle + { + internal SatelliteVehicle(string[] message, int startIndex) + { + PrnNumber = int.Parse(message[startIndex], CultureInfo.InvariantCulture); + Elevation = double.Parse(message[startIndex + 1], CultureInfo.InvariantCulture); + Azimuth = double.Parse(message[startIndex + 2], CultureInfo.InvariantCulture); + int snr = -1; + if (int.TryParse(message[startIndex + 3], out snr)) + SignalToNoiseRatio = snr; + } + /// + /// SV PRN number + /// + public int PrnNumber { get; } + /// + /// Elevation in degrees, 90 maximum + /// + public double Elevation { get; } + /// + /// Azimuth, degrees from true north, 000 to 359 + /// + public double Azimuth { get; } + /// + /// Signal-to-Noise ratio, 0-99 dB (-1 when not tracking) + /// + public int SignalToNoiseRatio { get; } + + /// + /// Satellite system + /// + public SatelliteSystem System + { + get + { + if (PrnNumber >= 1 && PrnNumber <= 32) + return SatelliteSystem.Gps; + if (PrnNumber >= 33 && PrnNumber <= 64) + return SatelliteSystem.Waas; + if (PrnNumber >= 65 && PrnNumber <= 96) + return SatelliteSystem.Glonass; + return SatelliteSystem.Unknown; + } + } + } + + /// + /// Satellite system + /// + public enum SatelliteSystem + { + /// + /// Unknown + /// + Unknown, + /// + /// GPS - Global Positioning System (NAVSTAR) + /// + Gps, + /// + /// WAAS - Wide Area Augmentation System + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Waas")] + Waas, + /// + /// GLONASS - Globalnaya navigatsionnaya sputnikovaya sistema + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Glonass")] + Glonass, + /// + /// Galileo + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Galileo")] + Galileo + } +} \ No newline at end of file diff --git a/src/NmeaParser/Nmea/NmeaMessage.cs b/src/NmeaParser/Nmea/NmeaMessage.cs index 39550b3..b3ec64c 100644 --- a/src/NmeaParser/Nmea/NmeaMessage.cs +++ b/src/NmeaParser/Nmea/NmeaMessage.cs @@ -44,11 +44,11 @@ namespace NmeaParser.Nmea public string NmeaType { get; private set; } } - /// - /// NMEA Message base class. - /// - public abstract class NmeaMessage - { + /// + /// NMEA Message base class. + /// + public abstract class NmeaMessage + { private readonly static Dictionary messageTypes; /// @@ -87,70 +87,84 @@ namespace NmeaParser.Nmea } } - /// - /// Parses the specified NMEA message. - /// - /// The NMEA message string. - /// - /// - /// Invalid nmea message: Missing starting character '$' - /// or checksum failure - /// - public static NmeaMessage Parse(string message) - { - if (string.IsNullOrEmpty(message)) - throw new ArgumentNullException("message"); - - int checksum = -1; - if (message[0] != '$') - throw new ArgumentException("Invalid nmea message: Missing starting character '$'"); - var idx = message.IndexOf('*'); - if (idx >= 0) - { - checksum = Convert.ToInt32(message.Substring(idx + 1), 16); - message = message.Substring(0, message.IndexOf('*')); - } - if (checksum > -1) - { - int checksumTest = 0; - for (int i = 1; i < message.Length; i++) - { - checksumTest ^= Convert.ToByte(message[i]); - } - if (checksum != checksumTest) - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid nmea message: Checksum failure. Got {0:X2}, Expected {1:X2}", checksum, checksumTest)); - } + /// + /// Parses the specified NMEA message. + /// + /// The NMEA message string. + /// + /// + /// Invalid nmea message: Missing starting character '$' + /// or checksum failure + /// + public static NmeaMessage Parse(string message) + { + if (string.IsNullOrEmpty(message)) + throw new ArgumentNullException("message"); - string[] parts = message.Split(new char[] { ',' }); - string MessageType = parts[0].Substring(1); - string[] MessageParts = parts.Skip(1).ToArray(); - if (messageTypes.ContainsKey(MessageType)) - { - return (NmeaMessage)messageTypes[MessageType].Invoke(new object[] { MessageType, MessageParts }); - } - else - { + int checksum = -1; + if (message[0] != '$') + throw new ArgumentException("Invalid nmea message: Missing starting character '$'"); + var idx = message.IndexOf('*'); + if (idx >= 0) + { + checksum = Convert.ToInt32(message.Substring(idx + 1), 16); + message = message.Substring(0, message.IndexOf('*')); + } + if (checksum > -1) + { + int checksumTest = 0; + for (int i = 1; i < message.Length; i++) + { + checksumTest ^= Convert.ToByte(message[i]); + } + if (checksum != checksumTest) + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid nmea message: Checksum failure. Got {0:X2}, Expected {1:X2}", checksum, checksumTest)); + } + + string[] parts = message.Split(new char[] { ',' }); + string MessageType = parts[0].Substring(1); + string[] MessageParts = parts.Skip(1).ToArray(); + if (messageTypes.ContainsKey(MessageType)) + { + return (NmeaMessage)messageTypes[MessageType].Invoke(new object[] { MessageType, MessageParts }); + } + else if (messageTypes.ContainsKey("--" + MessageType.Substring(2))) + { + return (NmeaMessage)messageTypes["--" + MessageType.Substring(2)].Invoke(new object[] { MessageType, MessageParts }); + } + else + { return new UnknownMessage(MessageType, MessageParts); - } - } + } + } - /// - /// Gets the NMEA message parts. - /// - protected IReadOnlyList MessageParts { get; } + /// + /// Gets the NMEA message parts. + /// + protected IReadOnlyList MessageParts { get; } - /// - /// Gets the NMEA type id for the message. - /// - public string MessageType { get; } + /// + /// Gets the NMEA type id for the message. + /// + public string MessageType { get; } - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() + /// + /// Gets the talker ID for this message ( + /// + public Talker TalkerId => TalkerHelper.GetTalker(MessageType); + + /// + /// Gets a value indicating whether this message type is proprietary + /// + public bool IsProprietary => MessageType[0] == 'P'; //Appendix B + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "${0},{1}*{2:X2}", MessageType, string.Join(",", MessageParts), Checksum); } diff --git a/src/NmeaParser/Nmea/Gps/GPRMB.cs b/src/NmeaParser/Nmea/Rmb.cs similarity index 93% rename from src/NmeaParser/Nmea/Gps/GPRMB.cs rename to src/NmeaParser/Nmea/Rmb.cs index 84964be..31679ab 100644 --- a/src/NmeaParser/Nmea/Gps/GPRMB.cs +++ b/src/NmeaParser/Nmea/Rmb.cs @@ -27,8 +27,8 @@ namespace NmeaParser.Nmea.Gps /// Recommended minimum navigation information /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprmb")] - [NmeaMessageType("GPRMB")] - public class Gprmb : NmeaMessage + [NmeaMessageType("--RMB")] + public class Rmb : NmeaMessage { /// /// Data status @@ -46,16 +46,16 @@ namespace NmeaParser.Nmea.Gps } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - public Gprmb(string type, string[] message) : base(type, message) + public Rmb(string type, string[] message) : base(type, message) { if (message == null || message.Length < 13) throw new ArgumentException("Invalid GPRMB", "message"); - Status = message[0] == "A" ? DataStatus.Ok : Gprmb.DataStatus.Warning; + Status = message[0] == "A" ? DataStatus.Ok : Rmb.DataStatus.Warning; double tmp; if (double.TryParse(message[1], NumberStyles.Float, CultureInfo.InvariantCulture, out tmp)) { diff --git a/src/NmeaParser/Nmea/Rmc.cs b/src/NmeaParser/Nmea/Rmc.cs index cc3095e..55ce989 100644 --- a/src/NmeaParser/Nmea/Rmc.cs +++ b/src/NmeaParser/Nmea/Rmc.cs @@ -27,14 +27,15 @@ namespace NmeaParser.Nmea /// Recommended Minimum /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprmc")] - public abstract class Rmc : NmeaMessage + [NmeaMessageType("--RMC")] + public class Rmc : NmeaMessage { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Rmc(string type, string[] message) : base(type, message) + public Rmc(string type, string[] message) : base(type, message) { if (message == null || message.Length < 11) throw new ArgumentException("Invalid GPRMC", "message"); diff --git a/src/NmeaParser/Nmea/Gps/GPRTE.cs b/src/NmeaParser/Nmea/Rte.cs similarity index 82% rename from src/NmeaParser/Nmea/Gps/GPRTE.cs rename to src/NmeaParser/Nmea/Rte.cs index d868c2e..94ce969 100644 --- a/src/NmeaParser/Nmea/Gps/GPRTE.cs +++ b/src/NmeaParser/Nmea/Rte.cs @@ -24,12 +24,19 @@ using System.Threading.Tasks; namespace NmeaParser.Nmea.Gps { /// - /// Routes + /// Routes /// + /// + /// Waypoint identifiers, listed in order with starting waypoint first, for the identified route. Two modes of + /// transmission are provided: 'c' indicates that the complete list of waypoints in the route are being + /// transmitted; 'w' indicates a working route where the first listed waypoint is always the last waypoint + /// that had been reached (FROM), while the second listed waypoint is always the waypoint that the vessel is + /// currently heading for (TO), the remaining list of waypoints represents the remainder of the route. + /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprte")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [NmeaMessageType("GPRTE")] - public sealed class Gprte : NmeaMessage, IMultiPartMessage + [NmeaMessageType("--RTE")] + public sealed class Rte : NmeaMessage, IMultiPartMessage { /// /// Waypoint tpe @@ -51,7 +58,7 @@ namespace NmeaParser.Nmea.Gps /// /// The message type /// The NMEA message values. - public Gprte(string type, string[] message) : base(type, message) + public Rte(string type, string[] message) : base(type, message) { if (message == null || message.Length < 4) throw new ArgumentException("Invalid GPRTE", "message"); diff --git a/src/NmeaParser/Nmea/Talker.cs b/src/NmeaParser/Nmea/Talker.cs new file mode 100644 index 0000000..8f757d6 --- /dev/null +++ b/src/NmeaParser/Nmea/Talker.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NmeaParser.Nmea +{ + internal static class TalkerHelper + { + internal static Talker GetTalker(string messageType) + { + if (messageType[0] == 'P') + return Talker.ProprietaryCode; + if (TalkerLookupTable.ContainsKey(messageType.Substring(0, 2))) + { + return TalkerLookupTable[messageType.Substring(0, 2)]; + } + return Talker.Unknown; + } + + private static readonly Dictionary TalkerLookupTable = new Dictionary() + { + {"AB", Talker.IndependentAISBaseStation }, + {"AD", Talker.DependentAISBaseStation }, + {"AG", Talker.HeadingTrackControllerGeneral }, + {"AP", Talker.HeadingTrackControllerMagnetic }, + {"AI", Talker.MobileClassAorBAISStation }, + {"AN", Talker.AISAidstoNavigationStation }, + {"AR", Talker.AISReceivingStation }, + {"AS", Talker.AISStation }, + {"AT", Talker.AISTransmittingStation }, + {"AX", Talker.AISSimplexRepeaterStation }, + {"BI", Talker.BilgeSystems }, + {"CD", Talker.DigitalSelectiveCalling }, + {"CR", Talker.DataReceiver }, + {"CS", Talker.Satellite }, + {"CT", Talker.RadioTelephoneMFHF }, + {"CV", Talker.RadioTelephoneVHF }, + {"CX", Talker.ScanningReceiver }, + {"DE", Talker.DECCANavigator }, + {"DF", Talker.DirectionFinder }, + {"DU", Talker.DuplexRepeaterStation }, + {"EC", Talker.ElectronicChartSystem }, + {"EI", Talker.ElectronicChartDisplayInformationSystem }, + {"EP", Talker.EmergencyPositionIndicatingBeacon }, + {"ER", Talker.EngineRoomMonitoringSystems }, + {"FD", Talker.FireDoorControllerMonitoringPoint }, + {"FE", Talker.FireExtinguisherSystem }, + {"FR", Talker.FireDetectionPoint }, + {"FS", Talker.FireSprinklerSystem }, + {"GA", Talker.GalileoPositioningSystem }, + {"GL", Talker.GlonassReceiver }, + {"GN", Talker.GlobalNavigationSatelliteSystem }, + {"GP", Talker.GlobalPositioningSystem }, + {"HC", Talker.CompassMagnetic }, + {"HE", Talker.GyroNorthSeeking }, + {"HF", Talker.Fluxgate }, + {"HN", Talker.GyroNonNorthSeeking }, + {"HD", Talker.HullDoorControllerMonitoringPanel }, + {"HS", Talker.HullStressMonitoring }, + {"II", Talker.IntegratedInstrumentation }, + {"IN", Talker.IntegratedNavigation }, + {"LC", Talker.LoranC }, + {"P ", Talker.ProprietaryCode }, + {"RA", Talker.RadarAndOrRadarPlotting }, + {"RC", Talker.PropulsionMachineryIncludingRemoteControl }, + {"SA", Talker.PhysicalShoreAISStation }, + {"SD", Talker.SounderDepth }, + {"SG", Talker.SteeringGearSteeringEngine }, + {"SN", Talker.ElectronicPositioningSystem }, + {"SS", Talker.SounderScanning }, + {"TI", Talker.TurnRateIndicator }, + {"UP", Talker.MicroprocessorController }, + {"U0", Talker.UserID0 }, + {"U1", Talker.UserID1 }, + {"U2", Talker.UserID2 }, + {"U3", Talker.UserID3 }, + {"U4", Talker.UserID4 }, + {"U5", Talker.UserID5 }, + {"U6", Talker.UserID6 }, + {"U7", Talker.UserID7 }, + {"U8", Talker.UserID8 }, + {"U9", Talker.UserID9 }, + {"VD", Talker.Doppler }, + {"VM", Talker.SpeedLogWaterMagnetic }, + {"VW", Talker.SpeedLogWaterMechanical }, + {"VR", Talker.VoyageDataRecorder }, + {"WD", Talker.WatertightDoorControllerMonitoringPanel }, + {"WI", Talker.WeatherInstruments }, + {"WL", Talker.WaterLevelDetectionSystems }, + {"YX", Talker.Transducer }, + {"ZA", Talker.AtomicsClock }, + {"ZC", Talker.Chronometer }, + {"ZQ", Talker.Quartz }, + {"ZV", Talker.RadioUpdate }, + + }; + + } + + /// + /// Talker Identifier + /// + public enum Talker + { + /// + /// Unrecognized Talker ID + /// + Unknown, + /// Independent AIS Base Station + IndependentAISBaseStation, // = AB + /// Dependent AIS Base Station + DependentAISBaseStation, // = AD + /// Heading Track Controller (Autopilot) - General + HeadingTrackControllerGeneral, // = AG + /// Heading Track Controller (Autopilot) - Magnetic + HeadingTrackControllerMagnetic, // = AP + /// Mobile Class A or B AIS Station + MobileClassAorBAISStation, // = AI + /// AIS Aids to Navigation Station + AISAidstoNavigationStation, // = AN + /// AIS Receiving Station + AISReceivingStation, // = AR + /// AIS Station (ITU_R M1371, (“Limited Base Station’) + AISStation, // = AS + /// AIS Transmitting Station + AISTransmittingStation, // = AT + /// AIS Simplex Repeater Station + AISSimplexRepeaterStation, // = AX + /// Bilge Systems + BilgeSystems, // = BI + /// + DigitalSelectiveCalling, // = CD + /// + DataReceiver, // = CR + /// + Satellite, // = CS + /// + RadioTelephoneMFHF, // = CT + /// + RadioTelephoneVHF, // = CV + /// + ScanningReceiver, // = CX + /// + DECCANavigator, // = DE + /// + DirectionFinder, // = DF + /// + DuplexRepeaterStation, // = DU + /// + ElectronicChartSystem, // = EC + /// + ElectronicChartDisplayInformationSystem, // = EI + /// + EmergencyPositionIndicatingBeacon, // = EP + /// + EngineRoomMonitoringSystems, // = ER + /// + FireDoorControllerMonitoringPoint, // = FD + /// + FireExtinguisherSystem, // = FE + /// + FireDetectionPoint, // = FR + /// + FireSprinklerSystem, // = FS + /// Galileo Positioning System + GalileoPositioningSystem, // = GA + /// GLONASS Receiver + GlonassReceiver, // = GL + /// Global Navigation Satellite System (GNSS + GlobalNavigationSatelliteSystem, // = GN + /// Global Positioning System (GPS) + GlobalPositioningSystem, // = GPS + /// Heading Sensor - Compass, Magnetic + CompassMagnetic, // = HC + /// Heading Sensor - Gyro, North Seeking + GyroNorthSeeking, // = HE + /// Heading Sensor - Fluxgate + Fluxgate, // = HF + /// Heading Sensor - Gyro, Non-North Seeking + GyroNonNorthSeeking, // = HN + /// Hull Door Controller/Monitoring Panel + HullDoorControllerMonitoringPanel, // = HD + /// Hull Stress Monitoring + HullStressMonitoring, // = HS + /// Integrated Instrumentation + IntegratedInstrumentation, // = II + /// Integrated Navigation + IntegratedNavigation, // = IN + /// Loran C + LoranC, // = LC + /// + ProprietaryCode, // = P + /// + RadarAndOrRadarPlotting, // = RA + /// + PropulsionMachineryIncludingRemoteControl, // = RC + /// + PhysicalShoreAISStation, // = SA + /// + SounderDepth, // = SD + /// + SteeringGearSteeringEngine, // = SG + /// + ElectronicPositioningSystem, // = SN + /// + SounderScanning, // = SS + /// + TurnRateIndicator, // = TI + /// + MicroprocessorController, // = UP + /// User configured talker identifier + UserID0, // = U0 + /// User configured talker identifier + UserID1, // = U1 + /// User configured talker identifier + UserID2, // = U2 + /// User configured talker identifier + UserID3, // = U3 + /// User configured talker identifier + UserID4, // = U4 + /// User configured talker identifier + UserID5, // = U5 + /// User configured talker identifier + UserID6, // = U6 + /// User configured talker identifier + UserID7, // = U7 + /// User configured talker identifier + UserID8, // = U8 + /// User configured talker identifier + UserID9, // = U9 + /// Velocity sensor - Doppler + Doppler, // = VD + /// Velocity sensor - Speed Log, Water, Magnetic + SpeedLogWaterMagnetic, // = VM + /// Velocity sensor - Speed Log, Water Mechanical + SpeedLogWaterMechanical, // = VW + /// Voyage Data Recorder + VoyageDataRecorder, // = VR + /// Watertight Door Controller/Monitoring Panel + WatertightDoorControllerMonitoringPanel, // = WD + /// Weather Instruments + WeatherInstruments, // = WI + /// Water Level Detection Systems + WaterLevelDetectionSystems, // = WL + /// Transducer + Transducer, // = YX + /// Time keeper - Atomics Clock + AtomicsClock, // = ZA + /// Time keeper - Chronometer + Chronometer, // = ZC + /// Time keeper - Quartz + Quartz, // = ZQ + /// Time keeper - Radio Update + RadioUpdate, // = ZV + + } +} diff --git a/src/NmeaParser/Nmea/Gps/GPVTG.cs b/src/NmeaParser/Nmea/Vtg.cs similarity index 87% rename from src/NmeaParser/Nmea/Gps/GPVTG.cs rename to src/NmeaParser/Nmea/Vtg.cs index 731a6fd..c2afca5 100644 --- a/src/NmeaParser/Nmea/Gps/GPVTG.cs +++ b/src/NmeaParser/Nmea/Vtg.cs @@ -23,16 +23,19 @@ namespace NmeaParser.Nmea.Gps /// /// Course over ground and ground speed /// + /// + /// The actual course and speed relative to the ground. + /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "GPVTG")] - [NmeaMessageType("GPVTG")] - public class Gpvtg : NmeaMessage + [NmeaMessageType("--VTG")] + public class Vtg : NmeaMessage { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - public Gpvtg(string type, string[] message) : base(type, message) + public Vtg(string type, string[] message) : base(type, message) { if (message == null || message.Length < 7) throw new ArgumentException("Invalid Gpvtg", "message"); diff --git a/src/NmeaParser/Nmea/Zda.cs b/src/NmeaParser/Nmea/Zda.cs index 53e4633..edbb8a9 100644 --- a/src/NmeaParser/Nmea/Zda.cs +++ b/src/NmeaParser/Nmea/Zda.cs @@ -7,14 +7,15 @@ namespace NmeaParser.Nmea /// Date and time of fix /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zda")] - public abstract class Zda : NmeaMessage + [NmeaMessageType("--ZDA")] + public class Zda : NmeaMessage { /// /// Initializes a new instance of the class. /// /// The message type /// The NMEA message values. - protected Zda(string type, string[] message) : base(type, message) + public Zda(string type, string[] message) : base(type, message) { if (message?.Length != 6) { diff --git a/src/NmeaParser/NmeaParser.csproj b/src/NmeaParser/NmeaParser.csproj index 0156347..2a40b91 100644 --- a/src/NmeaParser/NmeaParser.csproj +++ b/src/NmeaParser/NmeaParser.csproj @@ -11,7 +11,7 @@ An NMEA stream parser for serial port, bluetooth and file-based nmea simulation. nmea winrt wpf uwp xamarin gps serialport bluetooth SharpGIS.NmeaParser - 1.11 + 2.0-beta1 Apache-2.0 https://github.com/dotMorten/NmeaParser https://github.com/dotMorten/NmeaParser @@ -19,7 +19,10 @@ Copyright © Morten Nielsen 2015-2019 $(MSBuildThisFileDirectory)..\Bin\$(Configuration) $(OutDir) - Lots of API cleanup to avoid null-references. Simplify object model for creation (semi-breaking). Updated license to Apache 2.0 + Lots of API cleanup to avoid null-references. +Revamped talker-specific message to use same class, instead of having talker-specific types (breaking). +Simplify object model for creation (semi-breaking). +Updated license to Apache 2.0 true true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb diff --git a/src/SampleApp.Droid/Properties/AndroidManifest.xml b/src/SampleApp.Droid/Properties/AndroidManifest.xml index 65f8739..6a7f8b3 100644 --- a/src/SampleApp.Droid/Properties/AndroidManifest.xml +++ b/src/SampleApp.Droid/Properties/AndroidManifest.xml @@ -1,6 +1,6 @@  - + diff --git a/src/SampleApp.Droid/SampleApp.Droid.csproj b/src/SampleApp.Droid/SampleApp.Droid.csproj index 89789bc..8a9b45c 100644 --- a/src/SampleApp.Droid/SampleApp.Droid.csproj +++ b/src/SampleApp.Droid/SampleApp.Droid.csproj @@ -16,7 +16,6 @@ Resources\Resource.Designer.cs Resource Off - True v8.1 Properties\AndroidManifest.xml Resources diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml.cs b/src/SampleApp.WinDesktop/MainWindow.xaml.cs index cfebfff..71e24b9 100644 --- a/src/SampleApp.WinDesktop/MainWindow.xaml.cs +++ b/src/SampleApp.WinDesktop/MainWindow.xaml.cs @@ -110,8 +110,8 @@ namespace SampleApp.WinDesktop gpgsaView.Message = args.Message as NmeaParser.Nmea.Gsa; else if (args.Message is NmeaParser.Nmea.Gll) gpgllView.Message = args.Message as NmeaParser.Nmea.Gll; - else if (args.Message is NmeaParser.Nmea.Gps.Garmin.Pgrme) - pgrmeView.Message = args.Message as NmeaParser.Nmea.Gps.Garmin.Pgrme; + else if (args.Message is NmeaParser.Nmea.Garmin.Pgrme) + pgrmeView.Message = args.Message as NmeaParser.Nmea.Garmin.Pgrme; else { var ctrl = MessagePanel.Children.OfType().Where(c => c.Message.MessageType == args.Message.MessageType).FirstOrDefault(); diff --git a/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs b/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs index bbb3b4d..af78041 100644 --- a/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs +++ b/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs @@ -1,5 +1,4 @@ -using NmeaParser.Nmea.Gps; -using NmeaParser.Nmea.Gps.Garmin; +using NmeaParser.Nmea.Garmin; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/UnitTests/NmeaParser.Tests/DeviceTests.cs b/src/UnitTests/NmeaParser.Tests/DeviceTests.cs index b4a424c..d7702d3 100644 --- a/src/UnitTests/NmeaParser.Tests/DeviceTests.cs +++ b/src/UnitTests/NmeaParser.Tests/DeviceTests.cs @@ -1,4 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using NmeaParser.Nmea; using System; using System.Collections.Generic; using System.Linq; @@ -24,8 +25,8 @@ namespace NmeaParser.Tests try { Assert.IsTrue(e.IsMultipart, "IsMultiPart"); - Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gps.Gpgsv)); - var msg = e.Message as NmeaParser.Nmea.Gps.Gpgsv; + Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gsv)); + var msg = e.Message as NmeaParser.Nmea.Gsv; if (msg.TotalMessages == msg.MessageNumber) { Assert.IsNotNull(e.MessageParts); @@ -71,10 +72,15 @@ $GAGSV,4,4,14,19,82,349,40,1,44,220,40,4,24,314,38*5F"; { Assert.IsNotNull(e.MessageParts); Assert.AreEqual(e.MessageParts.Count, 4, "MessageParts.Length"); - Assert.IsInstanceOfType(e.MessageParts[0], typeof(NmeaParser.Nmea.Gps.Gpgsv)); - Assert.IsInstanceOfType(e.MessageParts[1], typeof(NmeaParser.Nmea.Gps.Gpgsv)); - Assert.IsInstanceOfType(e.MessageParts[2], typeof(NmeaParser.Nmea.Glonass.Glgsv)); - Assert.IsInstanceOfType(e.MessageParts[3], typeof(NmeaParser.Nmea.Galileo.Gagsv)); + Assert.IsInstanceOfType(e.MessageParts[0], typeof(NmeaParser.Nmea.Gsv)); + Assert.IsInstanceOfType(e.MessageParts[1], typeof(NmeaParser.Nmea.Gsv)); + Assert.IsInstanceOfType(e.MessageParts[2], typeof(NmeaParser.Nmea.Gsv)); + Assert.IsInstanceOfType(e.MessageParts[3], typeof(NmeaParser.Nmea.Gsv)); + Assert.AreEqual(Talker.GlobalPositioningSystem, e.MessageParts[0].TalkerId); + Assert.AreEqual(Talker.GlobalPositioningSystem, e.MessageParts[1].TalkerId); + Assert.AreEqual(Talker.GlonassReceiver, e.MessageParts[2].TalkerId); + Assert.AreEqual(Talker.GalileoPositioningSystem, e.MessageParts[3].TalkerId); + tcs.SetResult(true); } else @@ -106,8 +112,8 @@ $GAGSV,4,4,14,19,82,349,40,1,44,220,40,4,24,314,38*5F"; try { Assert.IsTrue(e.IsMultipart, "IsMultiPart"); - Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gps.Gpgsv)); - var msg = e.Message as NmeaParser.Nmea.Gps.Gpgsv; + Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gsv)); + var msg = e.Message as NmeaParser.Nmea.Gsv; Assert.IsNull(e.MessageParts); if (count > 6) tcs.SetResult(true); diff --git a/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs b/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs index 23a375d..199c6b2 100644 --- a/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs +++ b/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs @@ -22,8 +22,6 @@ using NmeaParser.Nmea; using NmeaParser.Nmea.Gps; using System.Threading.Tasks; using System.IO; -using NmeaParser.Nmea.Gnss; -using NmeaParser.Nmea.Glonass; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace NmeaParser.Tests @@ -91,8 +89,8 @@ namespace NmeaParser.Tests { string input = "$GPRMB,A,,,,,,,,,,,,A,A*0B"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gprmb)); - Gprmb rmb = (Gprmb)msg; + Assert.IsInstanceOfType(msg, typeof(Rmb)); + Rmb rmb = (Rmb)msg; Assert.AreEqual(true, rmb.Arrived); Assert.AreEqual(double.NaN, rmb.CrossTrackError); Assert.AreEqual(double.NaN, rmb.DestinationLatitude); @@ -100,7 +98,7 @@ namespace NmeaParser.Tests Assert.AreEqual(0, rmb.DestinationWaypointId); Assert.AreEqual(0, rmb.OriginWaypointId); Assert.AreEqual(double.NaN, rmb.RangeToDestination); - Assert.AreEqual(Gprmb.DataStatus.Ok, rmb.Status); + Assert.AreEqual(Rmb.DataStatus.Ok, rmb.Status); Assert.AreEqual(double.NaN, rmb.TrueBearing); Assert.AreEqual(double.NaN, rmb.Velocity); } @@ -110,9 +108,9 @@ namespace NmeaParser.Tests { string input = "$GPRMB,A,0.66,L,003,004,4917.24,S,12309.57,W,001.3,052.5,000.5,V*3D"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gprmb)); - Gprmb rmb = (Gprmb)msg; - Assert.AreEqual(Gprmb.DataStatus.Ok, rmb.Status); + Assert.IsInstanceOfType(msg, typeof(Rmb)); + Rmb rmb = (Rmb)msg; + Assert.AreEqual(Rmb.DataStatus.Ok, rmb.Status); Assert.AreEqual(-.66, rmb.CrossTrackError); Assert.AreEqual(3, rmb.OriginWaypointId); Assert.AreEqual(4, rmb.DestinationWaypointId); @@ -129,8 +127,8 @@ namespace NmeaParser.Tests { string input = "$GPRMC,123519,A,4807.038,S,01131.000,W,022.4,084.4,230313,003.1,W*6A"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gprmc)); - Gprmc rmc = (Gprmc)msg; + Assert.IsInstanceOfType(msg, typeof(Rmc)); + Rmc rmc = (Rmc)msg; Assert.AreEqual(new DateTime(2013, 03, 23, 12, 35, 19, DateTimeKind.Utc), rmc.FixTime); Assert.AreEqual(-48.1173, rmc.Latitude); Assert.AreEqual(-11.516666666666667, rmc.Longitude, 0.0000000001); @@ -141,8 +139,8 @@ namespace NmeaParser.Tests { string input = "$GNRMC,231011.00,A,3403.47163804,N,11711.80926595,W,0.019,11.218,201217,12.0187,E,D*01"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gnrmc)); - Gnrmc rmc = (Gnrmc)msg; + Assert.IsInstanceOfType(msg, typeof(Rmc)); + Rmc rmc = (Rmc)msg; Assert.AreEqual("GNRMC", rmc.MessageType); Assert.AreEqual(new DateTime(2017, 12, 20, 23, 10, 11, DateTimeKind.Utc), rmc.FixTime); Assert.AreEqual(34.057860634, rmc.Latitude, 0.0000000001); @@ -158,12 +156,12 @@ namespace NmeaParser.Tests { string input = "$GPGGA,235236,3925.9479,N,11945.9211,W,1,10,0.8,1378.0,M,-22.1,M,,*46"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgga)); - Gpgga gga = (Gpgga)msg; + Assert.IsInstanceOfType(msg, typeof(Gga)); + Gga gga = (Gga)msg; Assert.AreEqual(new TimeSpan(23, 52, 36), gga.FixTime); Assert.AreEqual(39.432465, gga.Latitude); Assert.AreEqual(-119.7653516666666667, gga.Longitude, 0.0000000001); - Assert.AreEqual(NmeaParser.Nmea.Gps.Gpgga.FixQuality.GpsFix, gga.Quality); + Assert.AreEqual(NmeaParser.Nmea.Gga.FixQuality.GpsFix, gga.Quality); Assert.AreEqual(10, gga.NumberOfSatellites); Assert.AreEqual(.8, gga.Hdop); Assert.AreEqual(1378, gga.Altitude); @@ -179,12 +177,12 @@ namespace NmeaParser.Tests { string input = "$GNGGA,231011.00,3403.47163804,N,11711.80926595,W,5,13,0.9,403.641,M,-32.133,M,1.0,0000*6D"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gngga)); - Gngga gga = (Gngga)msg; + Assert.IsInstanceOfType(msg, typeof(Gga)); + Gga gga = (Gga)msg; Assert.AreEqual(new TimeSpan(23, 10, 11), gga.FixTime); Assert.AreEqual(34.057860634, gga.Latitude); Assert.AreEqual(-117.19682109916667, gga.Longitude, 0.0000000001); - Assert.AreEqual(NmeaParser.Nmea.Gps.Gpgga.FixQuality.FloatRtk, gga.Quality); + Assert.AreEqual(NmeaParser.Nmea.Gga.FixQuality.FloatRtk, gga.Quality); Assert.AreEqual(13, gga.NumberOfSatellites); Assert.AreEqual(.9, gga.Hdop); Assert.AreEqual(403.641, gga.Altitude); @@ -201,6 +199,7 @@ namespace NmeaParser.Tests string input = "$PTNLA,HV,002.94,M,288.1,D,008.6,D,002.98,M*74"; var msg = NmeaMessage.Parse(input); Assert.IsInstanceOfType(msg, typeof(NmeaParser.Nmea.LaserRange.Trimble.Ptnla)); + Assert.AreEqual(Talker.ProprietaryCode, msg.TalkerId); NmeaParser.Nmea.LaserRange.Trimble.Ptnla ptlna = (NmeaParser.Nmea.LaserRange.Trimble.Ptnla)msg; Assert.AreEqual(2.94, ptlna.HorizontalDistance); Assert.AreEqual('M', ptlna.HorizontalDistanceUnits); @@ -217,8 +216,9 @@ namespace NmeaParser.Tests { string input = "$PGRME,2.3,M,3.3,M,4.0,M*2B"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(NmeaParser.Nmea.Gps.Garmin.Pgrme)); - NmeaParser.Nmea.Gps.Garmin.Pgrme rme = (NmeaParser.Nmea.Gps.Garmin.Pgrme)msg; + Assert.IsInstanceOfType(msg, typeof(NmeaParser.Nmea.Garmin.Pgrme)); + Assert.AreEqual(Talker.ProprietaryCode, msg.TalkerId); + NmeaParser.Nmea.Garmin.Pgrme rme = (NmeaParser.Nmea.Garmin.Pgrme)msg; Assert.AreEqual(2.3, rme.HorizontalError); Assert.AreEqual("M", rme.HorizontalErrorUnits); Assert.AreEqual(3.3, rme.VerticalError); @@ -232,10 +232,10 @@ namespace NmeaParser.Tests { string input = "$GPGSA,A,3,,,,,,16,18,,22,24,,,,,*14"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgsa)); - Gpgsa gsa = (Gpgsa)msg; - Assert.AreEqual(Gpgsa.ModeSelection.Auto, gsa.GpsMode); - Assert.AreEqual(Gpgsa.Mode.Fix3D, gsa.FixMode); + Assert.IsInstanceOfType(msg, typeof(Gsa)); + Gsa gsa = (Gsa)msg; + Assert.AreEqual(Gsa.ModeSelection.Auto, gsa.GpsMode); + Assert.AreEqual(Gsa.Mode.Fix3D, gsa.FixMode); Assert.AreEqual(4, gsa.SVs.Count); Assert.AreEqual(16, gsa.SVs[0]); Assert.AreEqual(18, gsa.SVs[1]); @@ -251,10 +251,10 @@ namespace NmeaParser.Tests { string input = "$GPGSA,M,2,19,28,14,18,27,22,31,39,40,42,43,44,1.7,1.0,1.3*3C"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgsa)); - Gpgsa gsa = (Gpgsa)msg; - Assert.AreEqual(Gpgsa.ModeSelection.Manual, gsa.GpsMode); - Assert.AreEqual(Gpgsa.Mode.Fix2D, gsa.FixMode); + Assert.IsInstanceOfType(msg, typeof(Gsa)); + Gsa gsa = (Gsa)msg; + Assert.AreEqual(Gsa.ModeSelection.Manual, gsa.GpsMode); + Assert.AreEqual(Gsa.Mode.Fix2D, gsa.FixMode); Assert.AreEqual(12, gsa.SVs.Count); Assert.AreEqual(19, gsa.SVs[0]); Assert.AreEqual(28, gsa.SVs[1]); @@ -278,10 +278,11 @@ namespace NmeaParser.Tests { string input = "$GNGSA,A,3,3,7,16,23,9,26,,,,,,,3.5,1.4,3.2*11"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gngsa)); - Gngsa gsa = (Gngsa)msg; - Assert.AreEqual(Gpgsa.ModeSelection.Auto, gsa.GpsMode); - Assert.AreEqual(Gpgsa.Mode.Fix3D, gsa.FixMode); + Assert.IsInstanceOfType(msg, typeof(Gsa)); + Assert.AreEqual("GNGSA", msg.MessageType); + Gsa gsa = (Gsa)msg; + Assert.AreEqual(Gsa.ModeSelection.Auto, gsa.GpsMode); + Assert.AreEqual(Gsa.Mode.Fix3D, gsa.FixMode); Assert.AreEqual(6, gsa.SVs.Count); Assert.AreEqual(3, gsa.SVs[0]); Assert.AreEqual(7, gsa.SVs[1]); @@ -299,8 +300,8 @@ namespace NmeaParser.Tests { string input = "$GPGSV,3,3,11,22,42,067,42,75,14,311,43,50,05,244,00,,,,*49"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgsv)); - Gpgsv gsv = (Gpgsv)msg; + Assert.IsInstanceOfType(msg, typeof(Gsv)); + Gsv gsv = (Gsv)msg; Assert.AreEqual(3, gsv.TotalMessages); Assert.AreEqual(3, gsv.MessageNumber); Assert.AreEqual(11, gsv.SVsInView); @@ -333,8 +334,8 @@ namespace NmeaParser.Tests { string input = "$GPGSV,1,1,0,,,,,,,,,,,,,,,,*49"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgsv)); - Gpgsv gsv = (Gpgsv)msg; + Assert.IsInstanceOfType(msg, typeof(Gsv)); + Gsv gsv = (Gsv)msg; Assert.AreEqual(1, gsv.TotalMessages); Assert.AreEqual(1, gsv.MessageNumber); Assert.AreEqual(0, gsv.SVsInView); @@ -347,8 +348,8 @@ namespace NmeaParser.Tests { string input = "$GPGLL,4916.45,N,12311.12,W,225444.12,A,*30"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgll)); - Gpgll gll = (Gpgll)msg; + Assert.IsInstanceOfType(msg, typeof(Gll)); + Gll gll = (Gll)msg; Assert.IsTrue(gll.DataActive); Assert.AreEqual(49.2741666666666666667, gll.Latitude); Assert.AreEqual(-123.18533333333333333, gll.Longitude); @@ -360,8 +361,8 @@ namespace NmeaParser.Tests { string input = "$GNGLL,3403.47121040,N,11711.80878910,W,235715.00,A,D*66"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gngll)); - Gngll gll = (Gngll)msg; + Assert.IsInstanceOfType(msg, typeof(Gll)); + Gll gll = (Gll)msg; Assert.IsTrue(gll.DataActive); Assert.AreEqual(34.0578535066667, gll.Latitude, .000000000001); Assert.AreEqual(-117.196813151667, gll.Longitude, .000000000001); @@ -375,8 +376,8 @@ namespace NmeaParser.Tests { string input = "$GPGNS,224749.00,3333.4268304,N,11153.3538273,W,D,19,0.6,406.110,-26.294,6.0,0138,S*6A"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgns)); - Gpgns gns = (Gpgns)msg; + Assert.IsInstanceOfType(msg, typeof(Gns)); + Gns gns = (Gns)msg; Assert.AreEqual(new TimeSpan(0, 22, 47, 49, 0), gns.FixTime); Assert.AreEqual(33.55711384, gns.Latitude, .000000000001); Assert.AreEqual(-111.889230455, gns.Longitude, .000000000001); @@ -397,8 +398,9 @@ namespace NmeaParser.Tests { string input = "$GPGNS,235720.00,,,,,,6,,,,2.0,0*48"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgns)); - Gpgns gns = (Gpgns)msg; + Assert.IsInstanceOfType(msg, typeof(Gns)); + Gns gns = (Gns)msg; + Assert.AreEqual(Talker.GlobalPositioningSystem, gns.TalkerId); Assert.AreEqual(new TimeSpan(0, 23, 57, 20, 0), gns.FixTime); Assert.AreEqual(double.NaN, gns.Latitude); Assert.AreEqual(double.NaN, gns.Longitude); @@ -418,8 +420,9 @@ namespace NmeaParser.Tests { string input = "$GNGNS,235719.00,3403.47068778,N,11711.80950154,W,DDNNN,10,1.4,402.411,-32.133,,*26"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gngns)); - Gngns gns = (Gngns)msg; + Assert.IsInstanceOfType(msg, typeof(Gns)); + Gns gns = (Gns)msg; + Assert.AreEqual(Talker.GlobalNavigationSatelliteSystem, gns.TalkerId); Assert.AreEqual(new TimeSpan(0, 23, 57, 19, 0), gns.FixTime); Assert.AreEqual(34.0578447963333, gns.Latitude, .000000000001); Assert.AreEqual(-117.196825025667, gns.Longitude, .00000000001); @@ -443,9 +446,10 @@ namespace NmeaParser.Tests { string input = "$GLGNS,235720.00,,,,,,4,,,,2.0,0*56"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Glgns)); - Glgns gns = (Glgns)msg; + Assert.IsInstanceOfType(msg, typeof(Gns)); + Gns gns = (Gns)msg; Assert.AreEqual(new TimeSpan(0, 23, 57, 20, 0), gns.FixTime); + Assert.AreEqual(Talker.GlonassReceiver, gns.TalkerId); Assert.AreEqual(double.NaN, gns.Latitude); Assert.AreEqual(double.NaN, gns.Longitude); Assert.AreEqual(Gns.Mode.NoFix, gns.GpsModeIndicator); @@ -463,8 +467,8 @@ namespace NmeaParser.Tests { string input = "$GPGLL,3751.65,S,14507.36,E*77"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpgll)); - Gpgll gll = (Gpgll)msg; + Assert.IsInstanceOfType(msg, typeof(Gll)); + Gll gll = (Gll)msg; Assert.IsTrue(gll.DataActive); Assert.AreEqual(-37.860833333333333333, gll.Latitude); Assert.AreEqual(145.1226666666666666667, gll.Longitude); @@ -477,8 +481,8 @@ namespace NmeaParser.Tests { string input = "$GPBOD,,T,,M,,*47"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpbod)); - Gpbod bod = (Gpbod)msg; + Assert.IsInstanceOfType(msg, typeof(Bod)); + Bod bod = (Bod)msg; Assert.AreEqual(double.NaN, bod.TrueBearing, "TrueBearing"); Assert.AreEqual(double.NaN, bod.MagneticBearing, "MagneticBearing"); Assert.IsNull(bod.OriginId, "OriginID"); @@ -490,8 +494,8 @@ namespace NmeaParser.Tests { string input = "$GPBOD,099.3,T,105.6,M,POINTB,*48"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpbod)); - Gpbod bod = (Gpbod)msg; + Assert.IsInstanceOfType(msg, typeof(Bod)); + Bod bod = (Bod)msg; Assert.AreEqual(99.3, bod.TrueBearing, "TrueBearing"); Assert.AreEqual(105.6, bod.MagneticBearing, "MagneticBearing"); Assert.AreEqual("POINTB", bod.DestinationId, "DestinationID"); @@ -504,8 +508,8 @@ namespace NmeaParser.Tests { string input = "$GPBOD,097.0,T,103.2,M,POINTB,POINTA*4A"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpbod)); - Gpbod bod = (Gpbod)msg; + Assert.IsInstanceOfType(msg, typeof(Bod)); + Bod bod = (Bod)msg; Assert.AreEqual(97d, bod.TrueBearing, "TrueBearing"); Assert.AreEqual(103.2, bod.MagneticBearing, "MagneticBearing"); Assert.AreEqual("POINTB", bod.DestinationId, "DestinationID"); @@ -542,11 +546,11 @@ namespace NmeaParser.Tests { string input = "$GPRTE,2,1,c,0,W3IWI,DRIVWY,32CEDR,32-29,32BKLD,32-I95,32-US1,BW-32,BW-198*69"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gprte)); - Gprte gsv = (Gprte)msg; + Assert.IsInstanceOfType(msg, typeof(Rte)); + Rte gsv = (Rte)msg; Assert.AreEqual(2, gsv.TotalMessages); Assert.AreEqual(1, gsv.MessageNumber); - Assert.AreEqual(NmeaParser.Nmea.Gps.Gprte.WaypointListType.CompleteWaypointsList, gsv.ListType); + Assert.AreEqual(Rte.WaypointListType.CompleteWaypointsList, gsv.ListType); Assert.AreEqual("0", gsv.RouteId); Assert.AreEqual("0", gsv.RouteId); Assert.AreEqual(9, gsv.Waypoints.Count); @@ -560,8 +564,8 @@ namespace NmeaParser.Tests { 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.IsInstanceOfType(msg, typeof(Gst)); + Gst gst = (Gst)msg; Assert.AreEqual(new TimeSpan(17, 28, 14), gst.FixTime); Assert.AreEqual(0.006, gst.Rms); Assert.AreEqual(0.023, gst.SemiMajorError); @@ -577,8 +581,8 @@ namespace NmeaParser.Tests { string input = "$GNGST,172814.0,0.006,0.023,0.020,273.6,0.023,0.020,0.031*74"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gngst)); - Gngst gst = (Gngst)msg; + Assert.IsInstanceOfType(msg, typeof(Gst)); + Gst gst = (Gst)msg; Assert.AreEqual(new TimeSpan(17, 28, 14), gst.FixTime); Assert.AreEqual(0.006, gst.Rms); Assert.AreEqual(0.023, gst.SemiMajorError); @@ -594,8 +598,8 @@ namespace NmeaParser.Tests { string input = "$GPVTG,103.85,T,92.79,M,0.14,N,0.25,K,D*1E"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpvtg)); - Gpvtg vtg = (Gpvtg)msg; + Assert.IsInstanceOfType(msg, typeof(Vtg)); + Vtg vtg = (Vtg)msg; Assert.AreEqual(103.85, vtg.TrueCourseOverGround); Assert.AreEqual(92.79, vtg.MagneticCourseOverGround); Assert.AreEqual(0.14, vtg.SpeedInKnots); @@ -607,8 +611,8 @@ namespace NmeaParser.Tests { string input = "$GPVTG,,T,,M,0.00,N,0.00,K*4E"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpvtg)); - Gpvtg vtg = (Gpvtg)msg; + Assert.IsInstanceOfType(msg, typeof(Vtg)); + Vtg vtg = (Vtg)msg; Assert.IsTrue(double.IsNaN(vtg.TrueCourseOverGround)); Assert.IsTrue(double.IsNaN(vtg.MagneticCourseOverGround)); Assert.AreEqual(0.0, vtg.SpeedInKnots); @@ -620,8 +624,8 @@ namespace NmeaParser.Tests { var input = "$GNZDA,075451.00,02,10,2018,00,00*72"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gnzda)); - var zda = (Gnzda)msg; + Assert.IsInstanceOfType(msg, typeof(Zda)); + var zda = (Zda)msg; Assert.AreEqual(new DateTime(2018, 10, 02, 07, 54, 51, 00, DateTimeKind.Utc), zda.FixDateTime); } @@ -630,8 +634,8 @@ namespace NmeaParser.Tests { var input = "$GPZDA,143042.00,25,08,2005,,*6E"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Gpzda)); - var zda = (Gpzda)msg; + Assert.IsInstanceOfType(msg, typeof(Zda)); + var zda = (Zda)msg; Assert.AreEqual(new DateTime(2005, 08, 25, 14, 30, 42, 00, DateTimeKind.Utc), zda.FixDateTime); } @@ -640,8 +644,8 @@ namespace NmeaParser.Tests { var input = "$GLZDA,225627.00,21,09,2015,00,00*70"; var msg = NmeaMessage.Parse(input); - Assert.IsInstanceOfType(msg, typeof(Glzda)); - var zda = (Glzda)msg; + Assert.IsInstanceOfType(msg, typeof(Zda)); + var zda = (Zda)msg; Assert.AreEqual(new DateTime(2015, 09, 21, 22, 56, 27, 00, DateTimeKind.Utc), zda.FixDateTime); } }