Add project files.

This commit is contained in:
2023-07-11 10:54:27 -05:00
parent bffa409ea4
commit 8b111f95d0
24 changed files with 1130 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GpsClient2.NmeaMessages {
public class GpggaMessage : NmeaMessage {
#region Description
// $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
// Where:
// GGA Global Positioning System Fix Data
// 123519 Fix taken at 12:35:19 UTC
// 4807.038,N Latitude 48 deg 07.038' N
// 01131.000,E Longitude 11 deg 31.000' E
// 1 Fix quality: 0 = invalid
// 1 = GPS fix(SPS)
// 2 = DGPS fix
// 3 = PPS fix
// 4 = Real Time Kinematic
// 5 = Float RTK
// 6 = estimated(dead reckoning) (2.3 feature)
// 7 = Manual input mode
// 8 = Simulation mode
// 08 Number of satellites being tracked
// 0.9 Horizontal dilution of position
// 545.4, M Altitude, Meters, above mean sea level
// 46.9, M Height of geoid(mean sea level) above WGS84
// ellipsoid
// (empty field) time in seconds since last DGPS update
// (empty field) DGPS station ID number
// *47 the checksum data, always begins with*
#endregion
#region Properties
/// <summary>
/// Fix taken
/// </summary>
public TimeSpan FixTime { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
public GpsFixQuality FixQuality { get; set; }
public int NumberOfSatellites { get; set; }
/// <summary>
/// Horizontal dilution of position
/// </summary>
public float Hdop { get; set; }
/// <summary>
/// Altitude, Meters, above mean sea level
/// </summary>
public float Altitude { get; set; }
/// <summary>
/// Altitude units ('M' for Meters)
/// </summary>
public string AltitudeUnits { get; set; }
/// <summary>
/// Height of geoid (mean sea level) above WGS84
/// </summary>
public float HeightOfGeoId { get; set; }
public string HeightOfGeoIdUnits { get; set; }
/// <summary>
/// Time in seconds since last DGPS update
/// </summary>
public int TimeSpanSinceDgpsUpdate { get; set; }
/// <summary>
/// DGPS station ID number
/// </summary>
public int? DgpsStationId { get; set; }
#endregion
#region Message parsing
public override void Parse(string[] messageParts) {
if (messageParts == null || messageParts.Length < 14) {
throw new ArgumentException("Invalid GPGGA message");
}
FixTime = messageParts[1].ToTimeSpan();
Latitude = messageParts[2].ToCoordinates(messageParts[3], CoordinateType.Latitude);
Longitude = messageParts[4].ToCoordinates(messageParts[5], CoordinateType.Longitude);
FixQuality = (GpsFixQuality)Enum.Parse(typeof(GpsFixQuality), messageParts[6]);
NumberOfSatellites = messageParts[7].ToInteger();
Hdop = messageParts[8].ToFloat();
Altitude = messageParts[9].ToFloat();
AltitudeUnits = messageParts[10];
HeightOfGeoId = messageParts[11].ToFloat();
HeightOfGeoIdUnits = messageParts[12];
TimeSpanSinceDgpsUpdate = messageParts[13].ToInteger();
DgpsStationId = messageParts[14].ToInteger();
}
#endregion
public override string ToString() {
return $"Latitude {Latitude} - Longitude {Longitude} - Hoogte {Altitude}";
}
}
}

View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GpsClient2.NmeaMessages {
public class GpgsaMessage : NmeaMessage {
#region Description
// $GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39
// Where:
// GSA Satellite status
// A Auto selection of 2D or 3D fix(M = manual)
// 3 3D fix - values include: 1 = no fix
// 2 = 2D fix
// 3 = 3D fix
// 04,05... PRNs of satellites used for fix(space for 12)
// 2.5 PDOP(dilution of precision)
// 1.3 Horizontal dilution of precision(HDOP)
// 2.1 Vertical dilution of precision(VDOP)
// *39 the checksum data, always begins with*
#endregion
#region Properties
/// <summary>
/// Auto selection of 2D or 3D fix(M = manual)
/// </summary>
public bool GpsStatusAuto { get; set; }
/// <summary>
/// 3D fix - values include: 1 = no fix
// 2 = 2D fix
// 3 = 3D fix
/// </summary>
public SatelliteFixType SatelliteFix { get; set; }
/// <summary>
/// PRNs of satellites used for fix(space for 12)
/// </summary>
public string Pnrs { get; set; }
/// <summary>
/// PDOP(dilution of precision)
/// </summary>
public float Pdop { get; set; }
/// <summary>
/// Horizontal dilution of precision(HDOP)
/// </summary>
public float Hdop { get; set; }
/// <summary>
/// Vertical dilution of precision(VDOP)
/// </summary>
public float Vdop { get; set; }
#endregion
#region Message parsing
public override void Parse(string[] messageParts) {
if (messageParts == null || messageParts.Length < 9) {
throw new ArgumentException("Invalid GPGSA message");
}
GpsStatusAuto = messageParts[1].ToBoolean("A");
SatelliteFix = (SatelliteFixType)Enum.Parse(typeof(SatelliteFixType), messageParts[2]);
for (var i = 0 + 3; i < 12 + 3; i++) {
Pnrs += $"{messageParts[i]},";
}
Pdop = messageParts[15].ToFloat();
Hdop = messageParts[16].ToFloat();
Vdop = messageParts[17].ToFloat();
}
#endregion
public override string ToString() {
return $"Status {GpsStatusAuto} - Satellite Fix Type {SatelliteFix}";
}
}
}

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GpsClient2.NmeaMessages {
public class GprmcMessage : NmeaMessage {
#region Description
// $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
//
// Where:
// RMC Recommended Minimum sentence C
// 123519 Fix taken at 12:35:19 UTC
// A Status A = active or V = Void.
// 4807.038, N Latitude 48 deg 07.038' N
// 01131.000,E Longitude 11 deg 31.000' E
// 022.4 Speed over the ground in knots
// 084.4 Track angle in degrees True
// 230394 Date - 23rd of March 1994
// 003.1,W Magnetic Variation
// *6A The checksum data, always begins with *
#endregion
#region Properties
public TimeSpan FixTime { get; set; }
/// <summary>
/// Status A = active or V = Void.
/// </summary>
public bool IsActive { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
/// <summary>
/// Speed over the ground in knots
/// </summary>
public float Speed { get; set; }
/// <summary>
/// Track angle in degrees True
/// </summary>
public float Course { get; set; }
/// <summary>
/// Date - 23rd of March 1994
/// </summary>
public DateTime UpdateDate { get; set; }
/// <summary>
/// Magnetic Variation
/// </summary>
public float MagneticVariation { get; set; }
/// <summary>
/// Magnetic Variation Unit
/// </summary>
public string MagneticVariationUnit { get; set; }
#endregion
#region Message parsing
public override void Parse(string[] messageParts) {
if (messageParts == null || messageParts.Length < 11) {
throw new ArgumentException("Invalid GPGGA message");
}
FixTime = messageParts[1].ToTimeSpan();
IsActive = messageParts[2].ToBoolean("A");
Latitude = messageParts[3].ToCoordinates(messageParts[4], CoordinateType.Latitude);
Longitude = messageParts[5].ToCoordinates(messageParts[6], CoordinateType.Longitude);
Speed = messageParts[7].ToFloat();
Course = messageParts[8].ToFloat();
UpdateDate = DateTime.ParseExact(messageParts[9], "ddMMyy", CultureInfo.InvariantCulture);
MagneticVariation = messageParts[10].ToFloat();
MagneticVariationUnit = messageParts[11];
}
#endregion
public override string ToString() {
return $"Latitude {Latitude} - Longitude {Longitude} - Speed {Speed}";
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GpsClient2.NmeaMessages {
public class GpvtgMessage : NmeaMessage {
#region Description
// $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48
// where:
// VTG Track made good and ground speed
// 054.7,T True track made good(degrees)
// 034.4,M Magnetic track made good
// 005.5,N Ground speed, knots
// 010.2,K Ground speed, Kilometers per hour
// *48 Checksum
#endregion
#region Properties
/// <summary>
/// True track made good(degrees)
/// </summary>
public float TrackDegrees { get; set; }
/// <summary>
/// Magnetic track made good
/// </summary>
public float MagneticTrack { get; set; }
/// <summary>
/// Ground speed, knots
/// </summary>
public float GroundSpeetKnots { get; set; }
/// <summary>
/// Ground speed, Kilometers per hour
/// </summary>
public float GroundSpeed { get; set; }
#endregion
#region Message parsing
public override void Parse(string[] messageParts) {
//$GPVTG,054.7,T,034.4,M,005.5,N,010.2,K * 48
if (messageParts == null || messageParts.Length < 9) {
throw new ArgumentException("Invalid GPVTG message");
}
TrackDegrees = messageParts[1].ToFloat();
MagneticTrack = messageParts[3].ToFloat();
GroundSpeetKnots = messageParts[5].ToFloat();
GroundSpeed = messageParts[7].ToFloat();
}
#endregion
public override string ToString() {
return $"Speed {GroundSpeed} - Track level {TrackDegrees}";
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GpsClient2.NmeaMessages {
public abstract class NmeaMessage {
public abstract void Parse(string[] messageParts);
}
}