From a2e505b3ef28f8ff3832ddfa7402aa325b2a27ee Mon Sep 17 00:00:00 2001 From: Howard van Rooijen Date: Wed, 9 Oct 2024 20:08:01 +0100 Subject: [PATCH] Add support for parsing AIS Message Type 27 --- .../Ais.Net.Receiver/Ais.Net.Receiver.csproj | 2 +- .../Parser/NmeaToAisMessageTypeProcessor.cs | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Solutions/Ais.Net.Receiver/Ais.Net.Receiver.csproj b/Solutions/Ais.Net.Receiver/Ais.Net.Receiver.csproj index 95ea555..b750f8d 100644 --- a/Solutions/Ais.Net.Receiver/Ais.Net.Receiver.csproj +++ b/Solutions/Ais.Net.Receiver/Ais.Net.Receiver.csproj @@ -21,7 +21,7 @@ - + all diff --git a/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaToAisMessageTypeProcessor.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaToAisMessageTypeProcessor.cs index c0bc7f2..465796f 100644 --- a/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaToAisMessageTypeProcessor.cs +++ b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaToAisMessageTypeProcessor.cs @@ -57,6 +57,12 @@ public void OnNext(in NmeaLineParser parsedLine, in ReadOnlySpan asciiPayl this.ParseMessageType24(asciiPayload, padding); return; } + + case 27: + { + this.ParseMessageType27(asciiPayload, padding); + return; + } } } catch (Exception e) @@ -92,7 +98,7 @@ private void ParseMessageTypes1Through3(ReadOnlySpan asciiPayload, uint pa NmeaAisPositionReportClassAParser parser = new(asciiPayload, padding); AisMessageType1Through3 message = new( - CourseOverGroundDegrees: parser.CourseOverGround10thDegrees.FromTenthsToDegrees(), + CourseOverGround: parser.CourseOverGround10thDegrees.FromTenthsToDegrees(), ManoeuvreIndicator: parser.ManoeuvreIndicator, MessageType: messageType, Mmsi: parser.Mmsi, @@ -157,7 +163,7 @@ private void ParseMessageType18(ReadOnlySpan asciiPayload, uint padding) RadioStatusType: parser.RadioStatusType, RegionalReserved139: parser.RegionalReserved139, RegionalReserved38: parser.RegionalReserved38, - CourseOverGroundDegrees: parser.CourseOverGround10thDegrees.FromTenthsToDegrees(), + CourseOverGround: parser.CourseOverGround10thDegrees.FromTenthsToDegrees(), PositionAccuracy: parser.PositionAccuracy, SpeedOverGround: parser.SpeedOverGroundTenths.FromTenths(), TimeStampSecond: parser.TimeStampSecond, @@ -179,7 +185,7 @@ private void ParseMessageType19(ReadOnlySpan asciiPayload, uint padding) AisMessageType19 message = new( Mmsi: parser.Mmsi, ShipName: shipNameAscii.GetString(), - CourseOverGroundDegrees: parser.CourseOverGround10thDegrees.FromTenthsToDegrees(), + CourseOverGround: parser.CourseOverGround10thDegrees.FromTenthsToDegrees(), DimensionToBow: parser.DimensionToBow, DimensionToPort: parser.DimensionToPort, DimensionToStarboard: parser.DimensionToStarboard, @@ -260,5 +266,23 @@ private void ParseMessageType24(ReadOnlySpan asciiPayload, uint padding) break; } } + } + + private void ParseMessageType27(ReadOnlySpan asciiPayload, uint padding) + { + NmeaAisLongRangeAisBroadcastParser parser = new(asciiPayload, padding); + + AisMessageType27 message = new( + Mmsi: parser.Mmsi, + Position: Position.From10thMins(parser.Latitude10thMins, parser.Longitude10thMins), + CourseOverGround: parser.CourseOverGroundDegrees, + PositionAccuracy: parser.PositionAccuracy, + SpeedOverGround: parser.SpeedOverGroundTenths.FromTenths(), + RaimFlag: parser.RaimFlag, + RepeatIndicator: parser.RepeatIndicator, + GnssPositionStatus: parser.NotGnssPosition, + NavigationStatus: parser.NavigationStatus); + + this.messages.OnNext(message); } } \ No newline at end of file