From 9f2e8735f95486e42fa2e55fedee6a193978c9ef Mon Sep 17 00:00:00 2001 From: Howard van Rooijen Date: Sun, 14 Mar 2021 11:47:00 +0000 Subject: [PATCH] Refactor file locations (#101) * Refactor file locations Add new ShipTypeCategory and ShipTypeGroup types to allow a "roll up" of vessel types. Add extension methods from converting from ShipType to ShipTypeCategory and ShipTypeGroup Move IStorageClient into the Ais.Net.Receiver project. * Fix missing reference --- .../Models}/Abstractions/IAisIsAssigned.cs | 0 .../Models}/Abstractions/IAisIsDteNotReady.cs | 0 .../Net/Models}/Abstractions/IAisMessage.cs | 0 .../Models}/Abstractions/IAisMessageType.cs | 0 .../Models}/Abstractions/IAisMessageType18.cs | 0 .../Models}/Abstractions/IAisMessageType19.cs | 0 .../Abstractions/IAisMessageType1to3.cs | 0 .../Abstractions/IAisMessageType24Part0.cs | 0 .../Abstractions/IAisMessageType24Part1.cs | 0 .../Models}/Abstractions/IAisMessageType5.cs | 0 .../Abstractions/IAisMultipartMessage.cs | 0 .../Abstractions/IAisPositionFixType.cs | 0 .../Net/Models}/Abstractions/ICallSign.cs | 0 .../Net/Models}/Abstractions/IRaimFlag.cs | 0 .../Models}/Abstractions/IRepeatIndicator.cs | 0 .../Net/Models}/Abstractions/IShipType.cs | 0 .../Models}/Abstractions/IVesselDimensions.cs | 0 .../Models}/Abstractions/IVesselIdentity.cs | 0 .../Net/Models}/Abstractions/IVesselName.cs | 0 .../Models}/Abstractions/IVesselNavigation.cs | 0 .../Net/Models/Abstractions}/Position.cs | 2 +- .../Models/Abstractions/ShipTypeCategory.cs | 20 ++ .../Net/Models/Abstractions/ShipTypeGroup.cs | 59 +++++ .../{ => Ais/Net/Models}/AisMessageBase.cs | 0 .../Ais/Net/Models/AisMessageExtensions.cs | 246 ++++++++++++++++++ .../{ => Ais/Net/Models}/AisMessageType18.cs | 0 .../{ => Ais/Net/Models}/AisMessageType19.cs | 0 .../Net/Models}/AisMessageType1Through3.cs | 0 .../Net/Models}/AisMessageType24Part0.cs | 0 .../Net/Models}/AisMessageType24Part1.cs | 0 .../{ => Ais/Net/Models}/AisMessageType5.cs | 0 .../Ais.Net.Models/AisMessageExtensions.cs | 45 ---- .../Ais.Net.Receiver.Host.Console/Program.cs | 1 + ...Ais.Net.Receiver.Storage.Azure.Blob.csproj | 4 + .../Blob}/AzureAppendBlobStorageClient.cs | 0 .../Blob}/Configuration/StorageConfig.cs | 0 .../Net/Receiver}/Configuration/AisConfig.cs | 0 .../Receiver}/Parser/NmeaMessageExtensions.cs | 0 .../Parser/NmeaToAisMessageTypeProcessor.cs | 0 .../Net/Receiver}/Receiver/NmeaReceiver.cs | 0 .../Net/Receiver}/Receiver/ReceiverHost.cs | 0 .../Net/Receiver/Storage}/IStorageClient.cs | 2 +- 42 files changed, 332 insertions(+), 47 deletions(-) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisIsAssigned.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisIsDteNotReady.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessage.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType18.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType19.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType1to3.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType24Part0.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType24Part1.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMessageType5.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisMultipartMessage.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IAisPositionFixType.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/ICallSign.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IRaimFlag.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IRepeatIndicator.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IShipType.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IVesselDimensions.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IVesselIdentity.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IVesselName.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/Abstractions/IVesselNavigation.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models/Abstractions}/Position.cs (90%) create mode 100644 Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeCategory.cs create mode 100644 Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeGroup.cs rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageBase.cs (100%) create mode 100644 Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageExtensions.cs rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageType18.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageType19.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageType1Through3.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageType24Part0.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageType24Part1.cs (100%) rename Solutions/Ais.Net.Models/{ => Ais/Net/Models}/AisMessageType5.cs (100%) delete mode 100644 Solutions/Ais.Net.Models/AisMessageExtensions.cs rename Solutions/Ais.Net.Receiver.Storage.Azure.Blob/{ => Ais/Net/Receiver/Storage/Azure/Blob}/AzureAppendBlobStorageClient.cs (100%) rename Solutions/Ais.Net.Receiver.Storage.Azure.Blob/{ => Ais/Net/Receiver/Storage/Azure/Blob}/Configuration/StorageConfig.cs (100%) rename Solutions/Ais.Net.Receiver/{ => Ais/Net/Receiver}/Configuration/AisConfig.cs (100%) rename Solutions/Ais.Net.Receiver/{ => Ais/Net/Receiver}/Parser/NmeaMessageExtensions.cs (100%) rename Solutions/Ais.Net.Receiver/{ => Ais/Net/Receiver}/Parser/NmeaToAisMessageTypeProcessor.cs (100%) rename Solutions/Ais.Net.Receiver/{ => Ais/Net/Receiver}/Receiver/NmeaReceiver.cs (100%) rename Solutions/Ais.Net.Receiver/{ => Ais/Net/Receiver}/Receiver/ReceiverHost.cs (100%) rename Solutions/{Ais.Net.Receiver.Storage.Azure.Blob => Ais.Net.Receiver/Ais/Net/Receiver/Storage}/IStorageClient.cs (87%) diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisIsAssigned.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisIsAssigned.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisIsAssigned.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisIsAssigned.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisIsDteNotReady.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisIsDteNotReady.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisIsDteNotReady.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisIsDteNotReady.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessage.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessage.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessage.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessage.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType18.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType18.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType18.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType18.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType19.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType19.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType19.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType19.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType1to3.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType1to3.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType1to3.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType1to3.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType24Part0.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType24Part0.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType24Part0.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType24Part0.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType24Part1.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType24Part1.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType24Part1.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType24Part1.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMessageType5.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType5.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMessageType5.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMessageType5.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisMultipartMessage.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMultipartMessage.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisMultipartMessage.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisMultipartMessage.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IAisPositionFixType.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisPositionFixType.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IAisPositionFixType.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IAisPositionFixType.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/ICallSign.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ICallSign.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/ICallSign.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ICallSign.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IRaimFlag.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IRaimFlag.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IRaimFlag.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IRaimFlag.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IRepeatIndicator.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IRepeatIndicator.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IRepeatIndicator.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IRepeatIndicator.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IShipType.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IShipType.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IShipType.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IShipType.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IVesselDimensions.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselDimensions.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IVesselDimensions.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselDimensions.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IVesselIdentity.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselIdentity.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IVesselIdentity.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselIdentity.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IVesselName.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselName.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IVesselName.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselName.cs diff --git a/Solutions/Ais.Net.Models/Abstractions/IVesselNavigation.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselNavigation.cs similarity index 100% rename from Solutions/Ais.Net.Models/Abstractions/IVesselNavigation.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/IVesselNavigation.cs diff --git a/Solutions/Ais.Net.Models/Position.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/Position.cs similarity index 90% rename from Solutions/Ais.Net.Models/Position.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/Position.cs index f685189..443423f 100644 --- a/Solutions/Ais.Net.Models/Position.cs +++ b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/Position.cs @@ -2,7 +2,7 @@ // Copyright (c) Endjin Limited. All rights reserved. // -namespace Ais.Net.Models +namespace Ais.Net.Models.Abstractions { public record Position(double Latitude, double Longitude) { diff --git a/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeCategory.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeCategory.cs new file mode 100644 index 0000000..bd49872 --- /dev/null +++ b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeCategory.cs @@ -0,0 +1,20 @@ +// +// Copyright (c) Endjin Limited. All rights reserved. +// + +namespace Ais.Net.Models.Abstractions +{ + public enum ShipTypeCategory + { + NotAvailable = 0, + Reserved = 1, + WingInGround = 2, + SpecialCategory3 = 3, + HighSpeedCraft = 4, + SpecialCategory5 = 5, + Passenger = 6, + Cargo = 7, + Tanker = 8, + Other = 9 + } +} \ No newline at end of file diff --git a/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeGroup.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeGroup.cs new file mode 100644 index 0000000..8c48d8e --- /dev/null +++ b/Solutions/Ais.Net.Models/Ais/Net/Models/Abstractions/ShipTypeGroup.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Endjin Limited. All rights reserved. +// + +namespace Ais.Net.Models.Abstractions +{ + public enum ShipTypeGroup + { + NotAvailable, + Reserved, + WingInGroundAll, + WingInGroundHazardous, + WingInGroundReserved, + + Fishing, + Towing, + TowingLengthOver200OmrBreadthOver25m, + DredgingOrUnderwaterOps, + DivingOps, + MilitaryOps, + Sailing, + PleasureCraft, + + HighSpeedCraftAll, + HighSpeedCraftHazardous, + HighSpeedCraftReserved, + HighSpeedCraftNoAdditionalInformation, + + PilotVessel, + SearchAndRescueVessel, + Tug, + PortTender, + AntiPollutionEquipment, + LawEnforcement, + SpareLocalVessel, + MedicalTransport, + NoncombatantShip, + + PassengerAll, + PassengerHazardous, + PassengerReserved, + PassengerNoAdditionalInformation, + + CargoAll, + CargoHazardous, + CargoReserved, + CargoNoAdditionalInformation, + + TankerAll, + TankerHazardous, + TankerReserved, + TankerNoAdditionalInformation, + + OtherAll, + OtherHazardous, + OtherReserved, + OtherNoAdditionalInformation, + } +} \ No newline at end of file diff --git a/Solutions/Ais.Net.Models/AisMessageBase.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageBase.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageBase.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageBase.cs diff --git a/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageExtensions.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageExtensions.cs new file mode 100644 index 0000000..d85a1a2 --- /dev/null +++ b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageExtensions.cs @@ -0,0 +1,246 @@ +// +// Copyright (c) Endjin Limited. All rights reserved. +// + +namespace Ais.Net.Models +{ + using System; + using System.Text; + using Ais.Net.Models.Abstractions; + + public static class AisMessageExtensions + { + public static double From10000thMinsToDegrees(this int value) + { + return value / 600000.0; + } + + public static float? FromTenths(this uint value) + { + return value == 1023 ? null : (value / 10.0f); + } + + public static float? FromTenthsToDegrees(this uint value) + { + return value == 3600 ? null : (value / 10.0f); + } + + public static string CleanVesselName(this string value) + { + return value.Trim('@').Trim().Replace(" ", " "); + } + + public static string GetString(this Span value) + { + return Encoding.ASCII.GetString(value); + } + + public static string TextFieldToString(this NmeaAisTextFieldParser field) + { + Span ascii = stackalloc byte[(int)field.CharacterCount]; + field.WriteAsAscii(ascii); + + return Encoding.ASCII.GetString(ascii); + } + + public static ShipTypeCategory ToShipTypeCategory(this ShipType shipType) + { + return shipType.ToShipTypeGroup().ToShipTypeCategory(); + } + + public static ShipTypeCategory ToShipTypeCategory(this ShipTypeGroup shipTypeGroup) + { + return shipTypeGroup switch + { + ShipTypeGroup.NotAvailable => ShipTypeCategory.NotAvailable, + ShipTypeGroup.Reserved => ShipTypeCategory.Reserved, + ShipTypeGroup.WingInGroundAll => ShipTypeCategory.WingInGround, + ShipTypeGroup.WingInGroundHazardous => ShipTypeCategory.WingInGround, + ShipTypeGroup.WingInGroundReserved => ShipTypeCategory.WingInGround, + ShipTypeGroup.Fishing => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.Towing => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.TowingLengthOver200OmrBreadthOver25m => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.DredgingOrUnderwaterOps => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.DivingOps => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.MilitaryOps => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.Sailing => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.PleasureCraft => ShipTypeCategory.SpecialCategory3, + ShipTypeGroup.HighSpeedCraftAll => ShipTypeCategory.HighSpeedCraft, + ShipTypeGroup.HighSpeedCraftHazardous => ShipTypeCategory.HighSpeedCraft, + ShipTypeGroup.HighSpeedCraftReserved => ShipTypeCategory.HighSpeedCraft, + ShipTypeGroup.HighSpeedCraftNoAdditionalInformation => ShipTypeCategory.HighSpeedCraft, + ShipTypeGroup.PilotVessel => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.SearchAndRescueVessel => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.Tug => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.PortTender => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.AntiPollutionEquipment => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.LawEnforcement => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.SpareLocalVessel => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.MedicalTransport => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.NoncombatantShip => ShipTypeCategory.SpecialCategory5, + ShipTypeGroup.PassengerAll => ShipTypeCategory.Passenger, + ShipTypeGroup.PassengerHazardous => ShipTypeCategory.Passenger, + ShipTypeGroup.PassengerReserved => ShipTypeCategory.Passenger, + ShipTypeGroup.PassengerNoAdditionalInformation => ShipTypeCategory.Passenger, + ShipTypeGroup.CargoAll => ShipTypeCategory.Cargo, + ShipTypeGroup.CargoHazardous => ShipTypeCategory.Cargo, + ShipTypeGroup.CargoReserved => ShipTypeCategory.Cargo, + ShipTypeGroup.CargoNoAdditionalInformation => ShipTypeCategory.Cargo, + ShipTypeGroup.TankerAll => ShipTypeCategory.Tanker, + ShipTypeGroup.TankerHazardous => ShipTypeCategory.Tanker, + ShipTypeGroup.TankerReserved => ShipTypeCategory.Tanker, + ShipTypeGroup.TankerNoAdditionalInformation => ShipTypeCategory.Tanker, + ShipTypeGroup.OtherAll => ShipTypeCategory.Other, + ShipTypeGroup.OtherHazardous => ShipTypeCategory.Other, + ShipTypeGroup.OtherReserved => ShipTypeCategory.Other, + ShipTypeGroup.OtherNoAdditionalInformation => ShipTypeCategory.Other, + _ => ShipTypeCategory.NotAvailable, + }; + } + + public static string ToShipTypeDescription(this int shipType) + { + switch (shipType) + { + case 0: goto default; + case >= 1 and <= 19: return "Reserved for future use"; + case 20: return "Wing in ground(WIG), all ships of this type"; + case 21: return "Wing in ground(WIG), Hazardous category A"; + case 22: return "Wing in ground(WIG), Hazardous category B"; + case 23: return "Wing in ground(WIG), Hazardous category C"; + case 24: return "Wing in ground(WIG), Hazardous category D"; + case 25: return "Wing in ground(WIG), Reserved for future use"; + case 26: return "Wing in ground(WIG), Reserved for future use"; + case 27: return "Wing in ground(WIG), Reserved for future use"; + case 28: return "Wing in ground(WIG), Reserved for future use"; + case 29: return "Wing in ground(WIG), Reserved for future use"; + case 30: return "Fishing"; + case 31: return "Towing"; + case 32: return "Towing: length exceeds 200m or breadth exceeds 25m"; + case 33: return "Dredging or underwater ops"; + case 34: return "Diving ops"; + case 35: return "Military ops"; + case 36: return "Sailing"; + case 37: return "Pleasure Craft"; + case 38: return "Reserved"; + case 39: return "Reserved"; + case 40: return "High speed craft(HSC), all ships of this type"; + case 41: return "High speed craft(HSC), Hazardous category A"; + case 42: return "High speed craft(HSC), Hazardous category B"; + case 43: return "High speed craft(HSC), Hazardous category C"; + case 44: return "High speed craft(HSC), Hazardous category D"; + case 45: return "High speed craft(HSC), Reserved for future use"; + case 46: return "High speed craft(HSC), Reserved for future use"; + case 47: return "High speed craft(HSC), Reserved for future use"; + case 48: return "High speed craft(HSC), Reserved for future use"; + case 49: return "High speed craft(HSC), No additional information"; + case 50: return "Pilot Vessel"; + case 51: return "Search and Rescue vessel"; + case 52: return "Tug"; + case 53: return "Port Tender"; + case 54: return "Anti - pollution equipment"; + case 55: return "Law Enforcement"; + case 56: return "Spare - Local Vessel"; + case 57: return "Spare - Local Vessel"; + case 58: return "Medical Transport"; + case 59: return "Noncombatant ship according to RR Resolution No. 18"; + case 60: return "Passenger, all ships of this type"; + case 61: return "Passenger, Hazardous category A"; + case 62: return "Passenger, Hazardous category B"; + case 63: return "Passenger, Hazardous category C"; + case 64: return "Passenger, Hazardous category D"; + case 65: return "Passenger, Reserved for future use"; + case 66: return "Passenger, Reserved for future use"; + case 67: return "Passenger, Reserved for future use"; + case 68: return "Passenger, Reserved for future use"; + case 69: return "Passenger, No additional information"; + case 70: return "Cargo, all ships of this type"; + case 71: return "Cargo, Hazardous category A"; + case 72: return "Cargo, Hazardous category B"; + case 73: return "Cargo, Hazardous category C"; + case 74: return "Cargo, Hazardous category D"; + case 75: return "Cargo, Reserved for future use"; + case 76: return "Cargo, Reserved for future use"; + case 77: return "Cargo, Reserved for future use"; + case 78: return "Cargo, Reserved for future use"; + case 79: return "Cargo, No additional information"; + case 80: return "Tanker, all ships of this type"; + case 81: return "Tanker, Hazardous category A"; + case 82: return "Tanker, Hazardous category B"; + case 83: return "Tanker, Hazardous category C"; + case 84: return "Tanker, Hazardous category D"; + case 85: return "Tanker, Reserved for future use"; + case 86: return "Tanker, Reserved for future use"; + case 87: return "Tanker, Reserved for future use"; + case 88: return "Tanker, Reserved for future use"; + case 89: return "Tanker, No additional information"; + case 90: return "Other Type, all ships of this type"; + case 91: return "Other Type, Hazardous category A"; + case 92: return "Other Type, Hazardous category B"; + case 93: return "Other Type, Hazardous category C"; + case 94: return "Other Type, Hazardous category D"; + case 95: return "Other Type, Reserved for future use"; + case 96: return "Other Type, Reserved for future use"; + case 97: return "Other Type, Reserved for future use"; + case 98: return "Other Type, Reserved for future use"; + case 99: return "Other Type, no additional information"; + default: return "Not available"; + } + } + + public static ShipTypeGroup ToShipTypeGroup(this ShipType shipType) + { + return ToShipTypeGroup((int)shipType); + } + + public static ShipTypeGroup ToShipTypeGroup(this int shipType) + { + switch (shipType) + { + case 0: goto default; + case >= 1 and <= 19: return ShipTypeGroup.Reserved; + case 20: return ShipTypeGroup.WingInGroundAll; + case >= 21 and <= 24: return ShipTypeGroup.WingInGroundHazardous; + case >= 25 and <= 29: return ShipTypeGroup.WingInGroundReserved; + case 30: return ShipTypeGroup.Fishing; + case 31: return ShipTypeGroup.Towing; + case 32: return ShipTypeGroup.TowingLengthOver200OmrBreadthOver25m; + case 33: return ShipTypeGroup.DredgingOrUnderwaterOps; + case 34: return ShipTypeGroup.DivingOps; + case 35: return ShipTypeGroup.MilitaryOps; + case 36: return ShipTypeGroup.Sailing; + case 37: return ShipTypeGroup.PleasureCraft; + case >= 38 and <= 39: return ShipTypeGroup.Reserved; + case 40: return ShipTypeGroup.HighSpeedCraftAll; + case >= 41 and <= 44: return ShipTypeGroup.HighSpeedCraftHazardous; + case >= 45 and <= 49: return ShipTypeGroup.HighSpeedCraftReserved; + case 50: return ShipTypeGroup.PilotVessel; + case 51: return ShipTypeGroup.SearchAndRescueVessel; + case 52: return ShipTypeGroup.Tug; + case 53: return ShipTypeGroup.PortTender; + case 54: return ShipTypeGroup.AntiPollutionEquipment; + case 55: return ShipTypeGroup.LawEnforcement; + case >= 56 and <= 57: return ShipTypeGroup.SpareLocalVessel; + case 58: return ShipTypeGroup.MedicalTransport; + case 59: return ShipTypeGroup.NoncombatantShip; + case 60: return ShipTypeGroup.PassengerAll; + case >= 61 and <= 64: return ShipTypeGroup.PassengerHazardous; + case >= 65 and <= 68: return ShipTypeGroup.PassengerReserved; + case 69: return ShipTypeGroup.PassengerNoAdditionalInformation; + case 70: return ShipTypeGroup.CargoAll; + case >= 71 and <= 74: return ShipTypeGroup.CargoHazardous; + case >= 75 and <= 78: return ShipTypeGroup.CargoReserved; + case 79: return ShipTypeGroup.CargoNoAdditionalInformation; + case 80: return ShipTypeGroup.TankerAll; + case >= 81 and <= 84: return ShipTypeGroup.TankerHazardous; + case >= 85 and <= 88: return ShipTypeGroup.TankerReserved; + case 89: return ShipTypeGroup.TankerNoAdditionalInformation; + case 90: return ShipTypeGroup.OtherAll; + case >= 91 and <= 94: return ShipTypeGroup.OtherHazardous; + case >= 95 and <= 98: return ShipTypeGroup.OtherReserved; + case 99: return ShipTypeGroup.OtherNoAdditionalInformation; + default: return ShipTypeGroup.NotAvailable; + } + } + } +} \ No newline at end of file diff --git a/Solutions/Ais.Net.Models/AisMessageType18.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType18.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageType18.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType18.cs diff --git a/Solutions/Ais.Net.Models/AisMessageType19.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType19.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageType19.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType19.cs diff --git a/Solutions/Ais.Net.Models/AisMessageType1Through3.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType1Through3.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageType1Through3.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType1Through3.cs diff --git a/Solutions/Ais.Net.Models/AisMessageType24Part0.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType24Part0.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageType24Part0.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType24Part0.cs diff --git a/Solutions/Ais.Net.Models/AisMessageType24Part1.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType24Part1.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageType24Part1.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType24Part1.cs diff --git a/Solutions/Ais.Net.Models/AisMessageType5.cs b/Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType5.cs similarity index 100% rename from Solutions/Ais.Net.Models/AisMessageType5.cs rename to Solutions/Ais.Net.Models/Ais/Net/Models/AisMessageType5.cs diff --git a/Solutions/Ais.Net.Models/AisMessageExtensions.cs b/Solutions/Ais.Net.Models/AisMessageExtensions.cs deleted file mode 100644 index 219cb15..0000000 --- a/Solutions/Ais.Net.Models/AisMessageExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) Endjin Limited. All rights reserved. -// - -namespace Ais.Net.Models -{ - using System; - using System.Text; - - public static class AisMessageExtensions - { - public static double From10000thMinsToDegrees(this int value) - { - return value / 600000.0; - } - - public static float? FromTenths(this uint value) - { - return value == 1023 ? null : (value / 10.0f); - } - - public static float? FromTenthsToDegrees(this uint value) - { - return value == 3600 ? null : (value / 10.0f); - } - - public static string CleanVesselName(this string value) - { - return value.Trim('@').Trim().Replace(" ", " "); - } - - public static string GetString(this Span value) - { - return Encoding.ASCII.GetString(value); - } - - public static string TextFieldToString(this NmeaAisTextFieldParser field) - { - Span ascii = stackalloc byte[(int)field.CharacterCount]; - field.WriteAsAscii(ascii); - - return Encoding.ASCII.GetString(ascii); - } - } -} \ No newline at end of file diff --git a/Solutions/Ais.Net.Receiver.Host.Console/Program.cs b/Solutions/Ais.Net.Receiver.Host.Console/Program.cs index 3bdc0ac..de72e49 100644 --- a/Solutions/Ais.Net.Receiver.Host.Console/Program.cs +++ b/Solutions/Ais.Net.Receiver.Host.Console/Program.cs @@ -15,6 +15,7 @@ namespace Ais.Net.Receiver.Host.Console using Ais.Net.Models.Abstractions; using Ais.Net.Receiver.Configuration; using Ais.Net.Receiver.Receiver; + using Ais.Net.Receiver.Storage; using Ais.Net.Receiver.Storage.Azure.Blob; using Ais.Net.Receiver.Storage.Azure.Blob.Configuration; diff --git a/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais.Net.Receiver.Storage.Azure.Blob.csproj b/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais.Net.Receiver.Storage.Azure.Blob.csproj index 41394e8..a3333c3 100644 --- a/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais.Net.Receiver.Storage.Azure.Blob.csproj +++ b/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais.Net.Receiver.Storage.Azure.Blob.csproj @@ -32,4 +32,8 @@ + + + + \ No newline at end of file diff --git a/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/AzureAppendBlobStorageClient.cs b/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais/Net/Receiver/Storage/Azure/Blob/AzureAppendBlobStorageClient.cs similarity index 100% rename from Solutions/Ais.Net.Receiver.Storage.Azure.Blob/AzureAppendBlobStorageClient.cs rename to Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais/Net/Receiver/Storage/Azure/Blob/AzureAppendBlobStorageClient.cs diff --git a/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Configuration/StorageConfig.cs b/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais/Net/Receiver/Storage/Azure/Blob/Configuration/StorageConfig.cs similarity index 100% rename from Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Configuration/StorageConfig.cs rename to Solutions/Ais.Net.Receiver.Storage.Azure.Blob/Ais/Net/Receiver/Storage/Azure/Blob/Configuration/StorageConfig.cs diff --git a/Solutions/Ais.Net.Receiver/Configuration/AisConfig.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Configuration/AisConfig.cs similarity index 100% rename from Solutions/Ais.Net.Receiver/Configuration/AisConfig.cs rename to Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Configuration/AisConfig.cs diff --git a/Solutions/Ais.Net.Receiver/Parser/NmeaMessageExtensions.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaMessageExtensions.cs similarity index 100% rename from Solutions/Ais.Net.Receiver/Parser/NmeaMessageExtensions.cs rename to Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaMessageExtensions.cs diff --git a/Solutions/Ais.Net.Receiver/Parser/NmeaToAisMessageTypeProcessor.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaToAisMessageTypeProcessor.cs similarity index 100% rename from Solutions/Ais.Net.Receiver/Parser/NmeaToAisMessageTypeProcessor.cs rename to Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Parser/NmeaToAisMessageTypeProcessor.cs diff --git a/Solutions/Ais.Net.Receiver/Receiver/NmeaReceiver.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Receiver/NmeaReceiver.cs similarity index 100% rename from Solutions/Ais.Net.Receiver/Receiver/NmeaReceiver.cs rename to Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Receiver/NmeaReceiver.cs diff --git a/Solutions/Ais.Net.Receiver/Receiver/ReceiverHost.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Receiver/ReceiverHost.cs similarity index 100% rename from Solutions/Ais.Net.Receiver/Receiver/ReceiverHost.cs rename to Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Receiver/ReceiverHost.cs diff --git a/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/IStorageClient.cs b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Storage/IStorageClient.cs similarity index 87% rename from Solutions/Ais.Net.Receiver.Storage.Azure.Blob/IStorageClient.cs rename to Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Storage/IStorageClient.cs index 8e222fa..7f3a2f1 100644 --- a/Solutions/Ais.Net.Receiver.Storage.Azure.Blob/IStorageClient.cs +++ b/Solutions/Ais.Net.Receiver/Ais/Net/Receiver/Storage/IStorageClient.cs @@ -2,7 +2,7 @@ // Copyright (c) Endjin Limited. All rights reserved. // -namespace Ais.Net.Receiver.Storage.Azure.Blob +namespace Ais.Net.Receiver.Storage { using System.Collections.Generic; using System.Threading.Tasks;