Esempio n. 1
0
 /// <summary>
 /// Encodes the data from the stored datetime as a string with the requested type.
 /// </summary>
 /// <param name="type">The APRS timestamp type. Read about the types in the documentation for Timestamp.Type.</param>
 /// <returns>String. 7-8 characters as defined by the APRS spec.</returns>
 public string Encode(Timestamp.Type type)
 {
     return(type switch
     {
         Type.DHMz => EncodeDHM(isZulu: true),
         Type.DHMl => EncodeDHM(isZulu: false),
         Type.HMS => EncodeHMS(),
         Type.MDHM => EncodeMDHM(),
         Type.NotDecoded => throw new ArgumentOutOfRangeException(nameof(type), $"Cannot deoce to type: {Type.NotDecoded}"),
         _ => throw new NotSupportedException(),
     });
Esempio n. 2
0
        /// <summary>
        /// Returns a string of the APRS Information Field (or the AX.25 Information Field) given the proper encoding.
        /// </summary>
        /// <param name="encodeType">The type of encoding to use.</param>
        /// <param name="timeType">The type of encoding for the timestamp to use.</param>
        /// <returns>APRS Information Field as a string.</returns>
        public string EncodeInformationField(Type encodeType, Timestamp.Type timeType)
        {
            string encodedInfoField = string.Empty;

            switch (encodeType)
            {
            case Type.PositionWithTimestampWithMessaging:
            case Type.PositionWithTimestampNoMessaging:
                encodedInfoField += GetTypeChar(encodeType);
                encodedInfoField += Timestamp !.Encode(timeType);
                encodedInfoField += Position !.Encode();
                encodedInfoField += Comment;
                break;

            case Type.PositionWithoutTimestampNoMessaging:
            case Type.PositionWithoutTimestampWithMessaging:
                encodedInfoField += GetTypeChar(encodeType);
                encodedInfoField += Position !.Encode();
                encodedInfoField += Comment;
                break;

            case Type.MaidenheadGridLocatorBeacon:
                encodedInfoField += GetTypeChar(encodeType);
                encodedInfoField += Position !.EncodeGridsquare(6, false);
                encodedInfoField += ']';
                if (Comment != null && Comment.Length > 0)
                {
                    encodedInfoField += ' ';
                    encodedInfoField += Comment;
                }

                break;

            case Type.Status:
                encodedInfoField += GetTypeChar(encodeType);
                encodedInfoField += Position !.EncodeGridsquare(6, true);
                if (Comment != null && Comment.Length > 0)
                {
                    encodedInfoField += ' ';
                    encodedInfoField += Comment;
                }

                break;

            default: throw new NotImplementedException();
            }

            return(encodedInfoField);
        }