Skip to content

Commit

Permalink
Add support for parsing AIS Message Type 27
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardvanRooijen committed Oct 9, 2024
1 parent 0133806 commit a2e505b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Solutions/Ais.Net.Receiver/Ais.Net.Receiver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ais.Net.Models" Version="0.2.1" />
<PackageReference Include="Ais.Net.Models" Version="0.3.1" />
<PackageReference Include="Corvus.Retry" Version="1.0.7" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.13">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public void OnNext(in NmeaLineParser parsedLine, in ReadOnlySpan<byte> asciiPayl
this.ParseMessageType24(asciiPayload, padding);
return;
}

case 27:
{
this.ParseMessageType27(asciiPayload, padding);
return;
}
}
}
catch (Exception e)
Expand Down Expand Up @@ -92,7 +98,7 @@ private void ParseMessageTypes1Through3(ReadOnlySpan<byte> 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,
Expand Down Expand Up @@ -157,7 +163,7 @@ private void ParseMessageType18(ReadOnlySpan<byte> 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,
Expand All @@ -179,7 +185,7 @@ private void ParseMessageType19(ReadOnlySpan<byte> 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,
Expand Down Expand Up @@ -260,5 +266,23 @@ private void ParseMessageType24(ReadOnlySpan<byte> asciiPayload, uint padding)
break;
}
}
}

private void ParseMessageType27(ReadOnlySpan<byte> 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);
}
}

0 comments on commit a2e505b

Please sign in to comment.