Skip to content

Commit 66f24b7

Browse files
committed
Additional AIS messages
Fixed AISMessage19 encoding and decoding as messages in the wild is only 1 sentence.
1 parent e8319de commit 66f24b7

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

AIS/AIS.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
88
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
99
<PackageId>TensionDev.Maritime.AIS</PackageId>
10-
<Version>0.4.0</Version>
10+
<Version>0.4.1</Version>
1111
<Authors>TensionDev amsga</Authors>
1212
<Company>TensionDev</Company>
1313
<Product>TensionDev.Maritime.AIS</Product>
@@ -21,7 +21,7 @@
2121
<PackageReleaseNotes>Initial project release</PackageReleaseNotes>
2222
<NeutralLanguage>en-SG</NeutralLanguage>
2323
<AssemblyVersion>0.4.0.0</AssemblyVersion>
24-
<FileVersion>0.4.0.0</FileVersion>
24+
<FileVersion>0.4.1.0</FileVersion>
2525
<IncludeSymbols>true</IncludeSymbols>
2626
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2727
</PropertyGroup>

AIS/AISMessage19.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,34 +397,25 @@ public override IList<String> EncodeSentences()
397397
IList<String> sentences = new List<String>();
398398

399399
StringBuilder stringBuilder = new StringBuilder();
400-
StringBuilder stringBuilder2 = new StringBuilder();
401400
IList<String> payload = EncodePayloads();
402401

403-
stringBuilder.AppendFormat("!AI{0},2,1,{1},B,{2},0", SentenceFormatter.ToString(), s_groupId, payload[0]);
404-
stringBuilder2.AppendFormat("!AI{0},2,2,{1},B,{2},0", SentenceFormatter.ToString(), s_groupId, payload[1]);
402+
stringBuilder.AppendFormat("!AI{0},1,1,,B,{1},0", SentenceFormatter.ToString(), payload[0]);
405403

406404
Byte checksum = CalculateChecksum(stringBuilder.ToString());
407-
Byte checksum2 = CalculateChecksum(stringBuilder2.ToString());
408405

409406
stringBuilder.AppendFormat("*{0}\r\n", checksum.ToString("X2"));
410-
stringBuilder2.AppendFormat("*{0}\r\n", checksum2.ToString("X2"));
411407

412408
sentences.Add(stringBuilder.ToString());
413-
sentences.Add(stringBuilder2.ToString());
414-
415-
++s_groupId;
416-
if (s_groupId > 9)
417-
s_groupId = 0;
418409

419410
return sentences;
420411
}
421412

422413
protected override void DecodePayloads(IList<String> payloads)
423414
{
424-
if (payloads.Count != 2)
415+
if (payloads.Count != 1)
425416
throw new ArgumentOutOfRangeException(nameof(payloads));
426417

427-
String payload = payloads[0] + payloads[1];
418+
String payload = payloads[0];
428419

429420
_bitVector0_59 = DecodePayload(payload, 0, 10);
430421
_bitVector60_119 = DecodePayload(payload, 10, 10);
@@ -447,7 +438,6 @@ protected override IList<String> EncodePayloads()
447438
IList<String> payloads = new List<String>();
448439

449440
StringBuilder payload = new StringBuilder();
450-
StringBuilder payload2 = new StringBuilder();
451441

452442
GetBitVector0_59();
453443
GetBitVector60_119();
@@ -461,11 +451,9 @@ protected override IList<String> EncodePayloads()
461451
payload.Append(EncodePayload(_bitVector120_179, 60));
462452
payload.Append(EncodePayload(_bitVector180_239, 60));
463453
payload.Append(EncodePayload(_bitVector240_299, 60));
464-
465-
payload2.Append(EncodePayload(_bitVector300_311, 12));
454+
payload.Append(EncodePayload(_bitVector300_311, 12));
466455

467456
payloads.Add(payload.ToString());
468-
payloads.Add(payload2.ToString());
469457

470458
return payloads;
471459
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11+
## [v0.4.1] - 2022-05-26
12+
[v0.4.1](https://github.com/TensionDev/AutomaticIdentificationSystem/releases/tag/v0.4.1)
13+
14+
### Fixed
15+
- Fixed Message 19 encoding and decoding.
16+
1117

1218
## [v0.4.0] - 2022-05-22
1319
[v0.4.0](https://github.com/TensionDev/AutomaticIdentificationSystem/releases/tag/v0.4.0)

XUnitTestProjectAIS/UnitTestAISMessage19.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public void AIS19Decoding01()
1414
{
1515
IList<String> sentences = new List<String>()
1616
{
17-
"!AIVDM,2,1,0,B,C5N3SRgPEnJGEBT>NhWAwwo862PaLELTBJ:V00000000S0D:R2,0*3A",
18-
"!AIVDM,2,2,0,B,20,0*17"
17+
"!AIVDM,1,1,,B,C5N3SRgPEnJGEBT>NhWAwwo862PaLELTBJ:V00000000S0D:R220,0*0B"
1918
};
2019

2120
AISMessage aisMessage = AISMessage.DecodeSentences(sentences);

0 commit comments

Comments
 (0)