Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AIS Message Type 27 #3

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ $tf/
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
*.DotSettings

# TeamCity is a build add-in
_TeamCity*
Expand Down Expand Up @@ -400,4 +401,4 @@ FodyWeavers.xsd
# Build outputs
_codeCoverage/
_packages/
*.sbom.*
*.sbom.*
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 Endjin Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
126 changes: 64 additions & 62 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
[Binding]
public class AisMessageType18StepDefinitions
{
private AisMessageType18 sut;

Check warning on line 12 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable field 'sut' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 12 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable field 'sut' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
private AisMessageType18Data data;

Check warning on line 13 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable field 'data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 13 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable field 'data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

[Given("a new AisMessageType18 record with the following properties:")]
public void GivenANewAisMessageTypeRecordWithTheFollowingProperties(DataTable table)
Expand All @@ -31,7 +31,7 @@
this.sut = new AisMessageType18(
CanAcceptMessage22ChannelAssignment: this.data.CanAcceptMessage22ChannelAssignment,
CanSwitchBands: this.data.CanSwitchBands,
CourseOverGroundDegrees: this.data.CourseOverGroundDegrees,
CourseOverGround: this.data.CourseOverGroundDegrees,
CsUnit: Enum.Parse<ClassBUnit>(this.data.CsUnit),
HasDisplay: this.data.HasDisplay,
IsAssigned: this.data.IsAssigned,
Expand All @@ -56,7 +56,7 @@
this.sut.ShouldNotBeNull();
this.sut.CanAcceptMessage22ChannelAssignment.ShouldBeTrue();
this.sut.CanSwitchBands.ShouldBeTrue();
this.sut.CourseOverGroundDegrees.ShouldBe(123.45f);
this.sut.CourseOverGround.ShouldBe(123.45f);
this.sut.CsUnit.ShouldBe(ClassBUnit.Cstdma);
this.sut.HasDisplay.ShouldBeTrue();
this.sut.IsAssigned.ShouldBeTrue();
Expand All @@ -79,14 +79,14 @@
public bool CanAcceptMessage22ChannelAssignment { get; set; }
public bool CanSwitchBands { get; set; }
public float? CourseOverGroundDegrees { get; set; }
public string CsUnit { get; set; }

Check warning on line 82 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable property 'CsUnit' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 82 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable property 'CsUnit' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public bool HasDisplay { get; set; }
public bool IsAssigned { get; set; }
public bool IsDscAttached { get; set; }
public uint Mmsi { get; set; }
public PositionData Position { get; set; }

Check warning on line 87 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable property 'Position' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 87 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable property 'Position' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public bool PositionAccuracy { get; set; }
public string RadioStatusType { get; set; }

Check warning on line 89 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable property 'RadioStatusType' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 89 in Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs

View workflow job for this annotation

GitHub Actions / build / Build

Non-nullable property 'RadioStatusType' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public bool RaimFlag { get; set; }
public int RegionalReserved139 { get; set; }
public int RegionalReserved38 { get; set; }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Solutions/Ais.Net.Models.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\GitVersion.yml = ..\GitVersion.yml
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ais.Net.Models", "Ais.Net.Models\Ais.Net.Models.csproj", "{5B090F5E-28EA-4394-83DB-8C2764970FDC}"
Expand Down
3 changes: 0 additions & 3 deletions Solutions/Ais.Net.Models.sln.DotSettings

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public interface IAisMessageType1to3
{
ManoeuvreIndicator ManoeuvreIndicator { get; }

NavigationStatus NavigationStatus { get; }

uint RadioSlotTimeout { get; }

uint RadioSubMessage { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// <copyright file="IAisMessageType27.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public interface IAisMessageType27
{
bool GnssPositionStatus { get; }

Position? Position { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// <copyright file="IVesselCourseOverGround.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public interface IVesselCourseOverGround
{
float? CourseOverGround { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

namespace Ais.Net.Models.Abstractions;

public interface IVesselNavigation
public interface IVesselNavigation: IVesselPositionAccuracy, IVesselSpeedOverGround, IVesselCourseOverGround
{
float? CourseOverGroundDegrees { get; }

Position? Position { get; }

bool PositionAccuracy { get; }

float? SpeedOverGround { get; }

uint TimeStampSecond { get; }

uint TrueHeadingDegrees { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// <copyright file="IVesselNavigationStatus.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public interface IVesselNavigationStatus
{
NavigationStatus NavigationStatus { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// <copyright file="IVesselPositionAccuracy.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public interface IVesselPositionAccuracy
{
bool PositionAccuracy { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// <copyright file="IVesselSpeedOverGround.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public interface IVesselSpeedOverGround
{
float? SpeedOverGround { get; }
}
23 changes: 13 additions & 10 deletions Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/Position.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// <copyright file="Position.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public record Position(double Latitude, double Longitude)
{
public static Position From10000thMins(int latitude, int longitude) =>
new (latitude.From10000thMinsToDegrees(), longitude.From10000thMinsToDegrees());
// <copyright file="Position.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Ais.Net.Models.Abstractions;

public record Position(double Latitude, double Longitude)
{
public static Position From10000thMins(int latitude, int longitude) =>
new (latitude.From10000thMinsToDegrees(), longitude.From10000thMinsToDegrees());

public static Position From10thMins(int latitude, int longitude) =>
new(latitude.From10thMinsToDegrees(), longitude.From10thMinsToDegrees());
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum ShipTypeGroup

Fishing,
Towing,
TowingLengthOver200OmrBreadthOver25m,
TowingLengthOver200MOrBreadthOver25M,
DredgingOrUnderwaterOps,
DivingOps,
MilitaryOps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public static double From10000thMinsToDegrees(this int value)
return value / 600000.0;
}

public static double From10thMinsToDegrees(this int value)
{
return value / 600.0;
}

public static float? FromTenths(this uint value)
{
return value == 1023 ? null : (value / 10.0f);
Expand Down Expand Up @@ -59,7 +64,7 @@ public static ShipTypeCategory ToShipTypeCategory(this ShipTypeGroup shipTypeGro
ShipTypeGroup.WingInGroundReserved => ShipTypeCategory.WingInGround,
ShipTypeGroup.Fishing => ShipTypeCategory.SpecialCategory3,
ShipTypeGroup.Towing => ShipTypeCategory.SpecialCategory3,
ShipTypeGroup.TowingLengthOver200OmrBreadthOver25m => ShipTypeCategory.SpecialCategory3,
ShipTypeGroup.TowingLengthOver200MOrBreadthOver25M => ShipTypeCategory.SpecialCategory3,
ShipTypeGroup.DredgingOrUnderwaterOps => ShipTypeCategory.SpecialCategory3,
ShipTypeGroup.DivingOps => ShipTypeCategory.SpecialCategory3,
ShipTypeGroup.MilitaryOps => ShipTypeCategory.SpecialCategory3,
Expand Down Expand Up @@ -204,7 +209,7 @@ public static ShipTypeGroup ToShipTypeGroup(this int shipType)
case >= 25 and <= 29: return ShipTypeGroup.WingInGroundReserved;
case 30: return ShipTypeGroup.Fishing;
case 31: return ShipTypeGroup.Towing;
case 32: return ShipTypeGroup.TowingLengthOver200OmrBreadthOver25m;
case 32: return ShipTypeGroup.TowingLengthOver200MOrBreadthOver25M;
case 33: return ShipTypeGroup.DredgingOrUnderwaterOps;
case 34: return ShipTypeGroup.DivingOps;
case 35: return ShipTypeGroup.MilitaryOps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Ais.Net.Models;
public record AisMessageType18(
bool CanAcceptMessage22ChannelAssignment,
bool CanSwitchBands,
float? CourseOverGroundDegrees,
float? CourseOverGround,
ClassBUnit CsUnit,
bool HasDisplay,
bool IsAssigned,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Ais.Net.Models;

public record AisMessageType19(
float? CourseOverGroundDegrees,
float? CourseOverGround,
uint DimensionToBow,
uint DimensionToPort,
uint DimensionToStarboard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Ais.Net.Models;

public record AisMessageType1Through3(
float? CourseOverGroundDegrees,
float? CourseOverGround,
ManoeuvreIndicator ManoeuvreIndicator,
int MessageType,
uint Mmsi,
Expand All @@ -28,4 +28,5 @@ public record AisMessageType1Through3(
IAisMessageType1to3,
IRaimFlag,
IRepeatIndicator,
IVesselNavigation;
IVesselNavigation,
IVesselNavigationStatus;
25 changes: 25 additions & 0 deletions Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType27.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <copyright file="AisMessageType27.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

using Ais.Net.Models.Abstractions;

namespace Ais.Net.Models;

public record AisMessageType27(
float? CourseOverGround,
bool GnssPositionStatus,
uint Mmsi,
NavigationStatus NavigationStatus,
Position? Position,
bool PositionAccuracy,
bool RaimFlag,
uint RepeatIndicator,
float? SpeedOverGround) :
AisMessageBase(MessageType: 27, Mmsi),
IAisMessageType27,
IRaimFlag,
IRepeatIndicator,
IVesselCourseOverGround,
IVesselNavigationStatus,
IVesselPositionAccuracy;
Loading