Skip to content

Commit

Permalink
Merge pull request #88 from Ocean-Signal/feature/safety-related-broad…
Browse files Browse the repository at this point in the history
…cast-test-message

Add support for message 14, Safety Related Broadcast
  • Loading branch information
chrisrichards authored Aug 2, 2024
2 parents 62272cd + 04d2a4e commit f1df26c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/AisParser/AisMessageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public AisMessage Create(Payload payload)
return new AddressedSafetyRelatedMessage(payload);
case AisMessageType.SafetyRelatedAcknowledgement:
return new SafetyRelatedAcknowledgementMessage(payload);
//case AisMessageType.SafetyRelatedBroadcastMessage:
case AisMessageType.SafetyRelatedBroadcastMessage:
return new SafetyRelatedBroadcastMessage(payload);
case AisMessageType.Interrogation:
return new InterrogationMessage(payload);
//case AisMessageType.AssignmentModeCommand:
Expand Down
21 changes: 21 additions & 0 deletions src/AisParser/Messages/SafetyRelatedBroadcastMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace AisParser.Messages
{
public class SafetyRelatedBroadcastMessage : AisMessage
{
public uint Spare { get; set; }

public string SafetyRelatedText { get; set; }

public SafetyRelatedBroadcastMessage()
: base(AisMessageType.SafetyRelatedBroadcastMessage)
{
}

public SafetyRelatedBroadcastMessage(Payload payload)
: base(AisMessageType.SafetyRelatedBroadcastMessage, payload)
{
Spare = payload.ReadUInt(38, 2);
SafetyRelatedText = payload.ReadString(40, 968);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using AisParser;
using AisParser.Messages;
using Shouldly;
using Xunit;

namespace AisParserTests.MessagesTests
{

public class SafetyRelatedBroadcastMessageTests : MessageTestBase
{
[Fact]
public void Should_parse_message()
{
const string sentence = "!AIVDM,1,1,,A,>>QK2khE0U8:1@E=@0,4*52"; // EPIRB test message

var message = Parser.Parse(sentence) as SafetyRelatedBroadcastMessage;
message.ShouldNotBeNull();
message.MessageType.ShouldBe(AisMessageType.SafetyRelatedBroadcastMessage);
message.Repeat.ShouldBe(0u);
message.Mmsi.ShouldBe(974570191u);
message.Spare.ShouldBe(0u);
message.SafetyRelatedText.ShouldBe("EPIRB TEST");
}
}
}

0 comments on commit f1df26c

Please sign in to comment.