Skip to content

Commit 929da83

Browse files
committed
Additional AIS messages
Created the AISMessage05, to represent Message 5 : Static and voyage related data.
1 parent f1d1802 commit 929da83

File tree

7 files changed

+916
-93
lines changed

7 files changed

+916
-93
lines changed

.github/workflows/package-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: dotnet pack --configuration Release
4848

4949
- name: Push GitHub
50-
run: dotnet nuget push "NMEA0183/bin/Release/*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --no-symbols --skip-duplicate
50+
run: dotnet nuget push "AIS/bin/Release/*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --no-symbols --skip-duplicate
5151

5252
- name: Push NuGet
53-
run: dotnet nuget push "NMEA0183/bin/Release/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_TOKEN }} --no-symbols --skip-duplicate
53+
run: dotnet nuget push "AIS/bin/Release/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_TOKEN }} --no-symbols --skip-duplicate

AIS/AISMessage.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public static AISMessage DecodeSentences(IList<String> sentences)
8383
aisMessage = new AISMessage01();
8484
break;
8585

86+
case "5":
87+
aisMessage = new AISMessage05();
88+
break;
89+
8690
default:
8791
throw new NotImplementedException("Message Identifier not recognised.");
8892
}

AIS/AISMessage01.cs

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
namespace TensionDev.Maritime.AIS
66
{
77
/// <summary>
8-
/// Message 1: Position reports
8+
/// Message 1: Position report (Scheduled)
99
/// </summary>
1010
public class AISMessage01 : AISMessage
1111
{
12-
private UInt64 bitVector0_59;
13-
private UInt64 bitVector60_119;
14-
private UInt64 bitVector120_167;
12+
private UInt64 _bitVector0_59;
13+
private UInt64 _bitVector60_119;
14+
private UInt64 _bitVector120_167;
1515

1616
protected UInt32 userId30;
1717
protected UInt16 navigationalStatus4;
@@ -368,9 +368,9 @@ protected override void DecodePayloads(IList<String> payloads)
368368

369369
String payload = payloads[0];
370370

371-
bitVector0_59 = DecodePayload(payload, 0, 10);
372-
bitVector60_119 = DecodePayload(payload, 10, 10);
373-
bitVector120_167 = DecodePayload(payload, 20, 8);
371+
_bitVector0_59 = DecodePayload(payload, 0, 10);
372+
_bitVector60_119 = DecodePayload(payload, 10, 10);
373+
_bitVector120_167 = DecodePayload(payload, 20, 8);
374374

375375
SetBitVector0_59();
376376
SetBitVector60_119();
@@ -387,189 +387,189 @@ protected override IList<String> EncodePayloads()
387387
GetBitVector60_119();
388388
GetBitVector120_167();
389389

390-
payload.Append(EncodePayload(bitVector0_59, 60));
391-
payload.Append(EncodePayload(bitVector60_119, 60));
392-
payload.Append(EncodePayload(bitVector120_167, 48));
390+
payload.Append(EncodePayload(_bitVector0_59, 60));
391+
payload.Append(EncodePayload(_bitVector60_119, 60));
392+
payload.Append(EncodePayload(_bitVector120_167, 48));
393393

394394
payloads.Add(payload.ToString());
395395

396396
return payloads;
397397
}
398-
398+
399399
private void GetBitVector0_59()
400400
{
401-
bitVector0_59 = 0;
401+
_bitVector0_59 = 0;
402402

403-
bitVector0_59 = messageId6;
403+
_bitVector0_59 = messageId6;
404404

405-
bitVector0_59 <<= 2;
406-
bitVector0_59 |= repeatIndicator2;
405+
_bitVector0_59 <<= 2;
406+
_bitVector0_59 |= repeatIndicator2;
407407

408-
bitVector0_59 <<= 30;
409-
bitVector0_59 |= userId30;
408+
_bitVector0_59 <<= 30;
409+
_bitVector0_59 |= userId30;
410410

411-
bitVector0_59 <<= 4;
412-
bitVector0_59 |= navigationalStatus4;
411+
_bitVector0_59 <<= 4;
412+
_bitVector0_59 |= navigationalStatus4;
413413

414414
if (rateOfTurn8 < 0)
415415
{
416416
UInt64 tempRateOfTurn = (UInt64)(rateOfTurn8 + (Int32)0xFF);
417417

418-
bitVector0_59 <<= 8;
419-
bitVector0_59 |= tempRateOfTurn;
418+
_bitVector0_59 <<= 8;
419+
_bitVector0_59 |= tempRateOfTurn;
420420
}
421421
else
422422
{
423-
bitVector0_59 <<= 8;
424-
bitVector0_59 |= (UInt64)((UInt16)rateOfTurn8);
423+
_bitVector0_59 <<= 8;
424+
_bitVector0_59 |= (UInt64)((UInt16)rateOfTurn8);
425425
}
426426

427-
bitVector0_59 <<= 10;
428-
bitVector0_59 |= speedOverGround10;
427+
_bitVector0_59 <<= 10;
428+
_bitVector0_59 |= speedOverGround10;
429429
}
430430

431431
private void GetBitVector60_119()
432432
{
433-
bitVector60_119 = 0;
433+
_bitVector60_119 = 0;
434434

435435
if (positionAccuracy1)
436436
{
437-
bitVector60_119 |= 1;
437+
_bitVector60_119 |= 1;
438438
}
439439

440440
if (longitude28 < 0)
441441
{
442442
UInt64 tempLongitude = (UInt64)(longitude28 + (Int32)0xFFFFFFF);
443443

444-
bitVector60_119 <<= 28;
445-
bitVector60_119 |= tempLongitude;
444+
_bitVector60_119 <<= 28;
445+
_bitVector60_119 |= tempLongitude;
446446
}
447447
else
448448
{
449-
bitVector60_119 <<= 28;
450-
bitVector60_119 |= (UInt64)((UInt32)longitude28);
449+
_bitVector60_119 <<= 28;
450+
_bitVector60_119 |= (UInt64)((UInt32)longitude28);
451451
}
452452

453453
if (latitude27 < 0)
454454
{
455455
UInt64 tempLatitude = (UInt64)(latitude27 + (Int32)0x7FFFFFF);
456456

457-
bitVector60_119 <<= 27;
458-
bitVector60_119 |= tempLatitude;
457+
_bitVector60_119 <<= 27;
458+
_bitVector60_119 |= tempLatitude;
459459
}
460460
else
461461
{
462-
bitVector60_119 <<= 27;
463-
bitVector60_119 |= (UInt64)((UInt32)latitude27);
462+
_bitVector60_119 <<= 27;
463+
_bitVector60_119 |= (UInt64)((UInt32)latitude27);
464464
}
465465

466-
bitVector60_119 <<= 4;
467-
bitVector60_119 |= GetBitVector((UInt64)courseOverGround12, 12, 8);
466+
_bitVector60_119 <<= 4;
467+
_bitVector60_119 |= GetBitVector((UInt64)courseOverGround12, 12, 8);
468468
}
469469

470470
private void GetBitVector120_167()
471471
{
472-
bitVector120_167 = 0;
472+
_bitVector120_167 = 0;
473473

474-
bitVector120_167 = GetBitVector((UInt64)courseOverGround12, 8);
474+
_bitVector120_167 = GetBitVector((UInt64)courseOverGround12, 8);
475475

476-
bitVector120_167 <<= 9;
477-
bitVector120_167 |= trueHeading9;
476+
_bitVector120_167 <<= 9;
477+
_bitVector120_167 |= trueHeading9;
478478

479-
bitVector120_167 <<= 6;
480-
bitVector120_167 |= timestamp6;
479+
_bitVector120_167 <<= 6;
480+
_bitVector120_167 |= timestamp6;
481481

482-
bitVector120_167 <<= 2;
483-
bitVector120_167 |= specialManoeuvreIndicator2;
482+
_bitVector120_167 <<= 2;
483+
_bitVector120_167 |= specialManoeuvreIndicator2;
484484

485-
bitVector120_167 <<= 3;
486-
bitVector120_167 |= spare3;
485+
_bitVector120_167 <<= 3;
486+
_bitVector120_167 |= spare3;
487487

488-
bitVector120_167 <<= 1;
488+
_bitVector120_167 <<= 1;
489489
if (raim1)
490490
{
491-
bitVector120_167 |= 1;
491+
_bitVector120_167 |= 1;
492492
}
493493

494-
bitVector120_167 <<= 19;
495-
bitVector120_167 |= CommunicationState.CommunicationState;
494+
_bitVector120_167 <<= 19;
495+
_bitVector120_167 |= CommunicationState.CommunicationState;
496496
}
497497

498498
private void SetBitVector0_59()
499499
{
500-
speedOverGround10 = (UInt16)(bitVector0_59 & 0x3FF);
501-
bitVector0_59 >>= 10;
500+
speedOverGround10 = (UInt16)(_bitVector0_59 & 0x3FF);
501+
_bitVector0_59 >>= 10;
502502

503-
rateOfTurn8 = (Int16)(bitVector0_59 & 0xFF);
503+
rateOfTurn8 = (Int16)(_bitVector0_59 & 0xFF);
504504
if (rateOfTurn8 > 0x7F)
505505
{
506506
rateOfTurn8 -= 0xFF;
507507
}
508-
bitVector0_59 >>= 8;
508+
_bitVector0_59 >>= 8;
509509

510-
navigationalStatus4 = (UInt16)(bitVector0_59 & 0xF);
511-
bitVector0_59 >>= 4;
510+
navigationalStatus4 = (UInt16)(_bitVector0_59 & 0xF);
511+
_bitVector0_59 >>= 4;
512512

513-
userId30 = (UInt32)(bitVector0_59 & 0x7FFFFFFF);
514-
bitVector0_59 >>= 30;
513+
userId30 = (UInt32)(_bitVector0_59 & 0x7FFFFFFF);
514+
_bitVector0_59 >>= 30;
515515

516-
repeatIndicator2 = (UInt16)(bitVector0_59 & 0x3);
517-
bitVector0_59 >>= 2;
516+
repeatIndicator2 = (UInt16)(_bitVector0_59 & 0x3);
517+
_bitVector0_59 >>= 2;
518518

519-
messageId6 = (UInt16)(bitVector0_59 & 0x3F);
520-
bitVector0_59 >>= 6;
519+
messageId6 = (UInt16)(_bitVector0_59 & 0x3F);
520+
_bitVector0_59 >>= 6;
521521
}
522522

523523
private void SetBitVector60_119()
524524
{
525-
courseOverGround12 = (UInt16)(bitVector60_119 & 0xF);
525+
courseOverGround12 = (UInt16)(_bitVector60_119 & 0xF);
526526
courseOverGround12 <<= 8;
527-
bitVector60_119 >>= 4;
527+
_bitVector60_119 >>= 4;
528528

529-
latitude27 = (Int32)(bitVector60_119 & 0x7FFFFFF);
529+
latitude27 = (Int32)(_bitVector60_119 & 0x7FFFFFF);
530530
if (latitude27 > 0x3FFFFFF)
531531
{
532532
latitude27 -= 0x7FFFFFF;
533533
}
534-
bitVector60_119 >>= 27;
534+
_bitVector60_119 >>= 27;
535535

536-
longitude28 = (Int32)(bitVector60_119 & 0xFFFFFFF);
536+
longitude28 = (Int32)(_bitVector60_119 & 0xFFFFFFF);
537537
if (longitude28 > 0x7FFFFFF)
538538
{
539539
longitude28 -= 0xFFFFFFF;
540540
}
541-
bitVector60_119 >>= 28;
541+
_bitVector60_119 >>= 28;
542542

543-
positionAccuracy1 = ((bitVector60_119 & 0x1) != 0);
544-
bitVector60_119 >>= 1;
543+
positionAccuracy1 = ((_bitVector60_119 & 0x1) != 0);
544+
_bitVector60_119 >>= 1;
545545
}
546546

547547
private void SetBitVector120_167()
548548
{
549-
UInt32 communicationState = (UInt32)(bitVector120_167 & 0x7FFFF);
550-
bitVector120_167 >>= 19;
549+
UInt32 communicationState = (UInt32)(_bitVector120_167 & 0x7FFFF);
550+
_bitVector120_167 >>= 19;
551551
CommunicationState = new SOTDMACommunicationState()
552552
{
553553
CommunicationState = communicationState
554554
};
555555

556-
raim1 = ((bitVector120_167 & 0x1) != 0);
557-
bitVector120_167 >>= 1;
556+
raim1 = ((_bitVector120_167 & 0x1) != 0);
557+
_bitVector120_167 >>= 1;
558558

559-
spare3 = (UInt16)(bitVector120_167 & 0x7);
560-
bitVector120_167 >>= 3;
559+
spare3 = (UInt16)(_bitVector120_167 & 0x7);
560+
_bitVector120_167 >>= 3;
561561

562-
specialManoeuvreIndicator2 = (UInt16)(bitVector120_167 & 0x3);
563-
bitVector120_167 >>= 2;
562+
specialManoeuvreIndicator2 = (UInt16)(_bitVector120_167 & 0x3);
563+
_bitVector120_167 >>= 2;
564564

565-
timestamp6 = (UInt16)(bitVector120_167 & 0x3F);
566-
bitVector120_167 >>= 6;
565+
timestamp6 = (UInt16)(_bitVector120_167 & 0x3F);
566+
_bitVector120_167 >>= 6;
567567

568-
trueHeading9 = (UInt16)(bitVector120_167 & 0x1FF);
569-
bitVector120_167 >>= 9;
568+
trueHeading9 = (UInt16)(_bitVector120_167 & 0x1FF);
569+
_bitVector120_167 >>= 9;
570570

571-
courseOverGround12 |= (UInt16)(bitVector120_167 & 0xFF);
572-
bitVector120_167 >>= 8;
571+
courseOverGround12 |= (UInt16)(_bitVector120_167 & 0xFF);
572+
_bitVector120_167 >>= 8;
573573
}
574574

575575
public enum NavigationalStatusEnum

0 commit comments

Comments
 (0)