@@ -10,6 +10,11 @@ public abstract class AISMessage
1010
1111 protected UInt16 messageId6 ;
1212 protected UInt16 repeatIndicator2 ;
13+
14+ /// <summary>
15+ /// Sentence Formatter
16+ /// </summary>
17+ public SentenceFormatterEnum SentenceFormatter { get ; set ; }
1318
1419 /// <summary>
1520 /// Identifier for this Message
@@ -24,6 +29,7 @@ public abstract class AISMessage
2429
2530 protected AISMessage ( )
2631 {
32+ SentenceFormatter = SentenceFormatterEnum . VDM ;
2733 }
2834
2935 /// <summary>
@@ -39,10 +45,11 @@ public static AISMessage DecodeSentences(IList<String> sentences)
3945 IList < String > payloads = new List < String > ( ) ;
4046 String messageId = "@" ;
4147 String sequenceId = String . Empty ;
48+ String sentenceIdentifier = String . Empty ;
4249
4350 foreach ( String sentence in sentences )
4451 {
45- String sentenceIdentifier = sentence . Substring ( 3 , 3 ) ;
52+ sentenceIdentifier = sentence . Substring ( 3 , 3 ) ;
4653 if ( sentenceIdentifier != "VDM" && sentenceIdentifier != "VDO" )
4754 {
4855 throw new NotImplementedException ( "Sentence Identifier not recognised." ) ;
@@ -111,6 +118,15 @@ public static AISMessage DecodeSentences(IList<String> sentences)
111118 throw new NotImplementedException ( "Message Identifier not recognised." ) ;
112119 }
113120
121+ if ( sentenceIdentifier == "VDM" )
122+ {
123+ aisMessage . SentenceFormatter = SentenceFormatterEnum . VDM ;
124+ }
125+ else if ( sentenceIdentifier == "VDO" )
126+ {
127+ aisMessage . SentenceFormatter = SentenceFormatterEnum . VDO ;
128+ }
129+
114130 aisMessage . DecodePayloads ( payloads ) ;
115131
116132 return aisMessage ;
@@ -324,5 +340,17 @@ protected static Byte CalculateChecksum(Byte initial, Byte data)
324340 /// </summary>
325341 /// <param name="payloads">AIS Payloads</param>
326342 protected abstract void DecodePayloads ( IList < String > payloads ) ;
343+
344+ public enum SentenceFormatterEnum
345+ {
346+ /// <summary>
347+ /// UAIS VHF Data-link Message
348+ /// </summary>
349+ VDM ,
350+ /// <summary>
351+ /// UAIS VHF Data-link Own-vessel report
352+ /// </summary>
353+ VDO ,
354+ }
327355 }
328356}
0 commit comments