Skip to content

Commit

Permalink
Add support for parsing AIS Message Type 27 (#233)
Browse files Browse the repository at this point in the history
* Add support for parsing AIS Message Type 27

* Update field name
  • Loading branch information
HowardvanRooijen authored Oct 9, 2024
1 parent 0133806 commit 393bac3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static async Task Main()
string positionText = navigation.Position is null ? "unknown position" : $"{navigation.Position.Latitude},{navigation.Position.Longitude}";

System.Console.ForegroundColor = ConsoleColor.Green;
System.Console.WriteLine($"[{mmsi}: '{name.VesselName.CleanVesselName()}'] - [{positionText}] - [{navigation.CourseOverGroundDegrees ?? 0}]");
System.Console.WriteLine($"[{mmsi}: '{name.VesselName.CleanVesselName()}'] - [{positionText}] - [{navigation.CourseOverGround ?? 0}]");
System.Console.ResetColor();
});
}
Expand Down
26 changes: 23 additions & 3 deletions Solutions/Ais.Net.Receiver.Host.Console/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@
"Microsoft.Extensions.FileProviders.Abstractions": "8.0.0"
}
},
"Roslynator.Analyzers": {
"type": "Direct",
"requested": "[4.12.4, )",
"resolved": "4.12.4",
"contentHash": "isl8hAh7yFNjyBEC4YlTSi+xGBblqBUC/2MCMmnBPwuXPewb7XYnMRzT3vXbP/gOGwT8hZUOy1g/aRH3lAF/NQ=="
},
"StyleCop.Analyzers": {
"type": "Direct",
"requested": "[1.2.0-beta.556, )",
"resolved": "1.2.0-beta.556",
"contentHash": "llRPgmA1fhC0I0QyFLEcjvtM2239QzKr/tcnbsjArLMJxJlu0AA5G7Fft0OI30pHF3MW63Gf4aSSsjc5m82J1Q==",
"dependencies": {
"StyleCop.Analyzers.Unstable": "1.2.0.556"
}
},
"System.Threading.Tasks.Dataflow": {
"type": "Direct",
"requested": "[8.0.1, )",
Expand All @@ -72,8 +87,8 @@
},
"Ais.Net.Models": {
"type": "Transitive",
"resolved": "0.2.1",
"contentHash": "JKW8/2Vf7D3sfCBnl7Z7hCtH4gOgfOGZNbPLitpEjNKq1EH+jikmPsXthyX9w9nQ6w6mbphsZ0wJV3oXgCkgxA==",
"resolved": "0.3.1",
"contentHash": "HcqGkzYW9BVZ4s9Jny87cH1c4fDkt3FpYtklH/T+vNFnncJmLDFNbAIOqFnO+JqvygBP6qDWo6WyEylAIFrgwQ==",
"dependencies": {
"Ais.Net": "0.4.2"
}
Expand Down Expand Up @@ -184,6 +199,11 @@
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"StyleCop.Analyzers.Unstable": {
"type": "Transitive",
"resolved": "1.2.0.556",
"contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ=="
},
"System.ClientModel": {
"type": "Transitive",
"resolved": "1.0.0",
Expand Down Expand Up @@ -268,7 +288,7 @@
"ais.net.receiver": {
"type": "Project",
"dependencies": {
"Ais.Net.Models": "[0.2.1, )",
"Ais.Net.Models": "[0.3.1, )",
"Corvus.Retry": "[1.0.7, )",
"System.Linq.Async": "[6.0.*, )",
"System.Reactive": "[6.0.1, )"
Expand Down
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 393bac3

Please sign in to comment.