Beispiel #1
0
        /// <summary>
        /// Returns the message as parseable BaseStation message text.
        /// </summary>
        /// <returns>The properties of the message formatted up as a text string that can be sent to any application
        /// that can interpret BaseStation messages.</returns>
        public string ToBaseStationString()
        {
            StringBuilder result = new StringBuilder();

            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", BaseStationMessageHelper.ConvertToString(MessageType));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", MessageType == BaseStationMessageType.Transmission ? BaseStationMessageHelper.ConvertToString(TransmissionType) : "");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", SessionId);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", AircraftId);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Icao24);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", FlightId);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:yyyy/MM/dd},", MessageGenerated);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:HH:mm:ss.fff},", MessageGenerated);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:yyyy/MM/dd},", MessageLogged);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:HH:mm:ss.fff},", MessageLogged);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", MessageType == BaseStationMessageType.StatusChange ? BaseStationMessageHelper.ConvertToString(StatusCode) : Callsign);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Altitude);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.GroundSpeed(GroundSpeed));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.Track(Track));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.Coordinate(Latitude));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.Coordinate(Longitude));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", VerticalRate);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Squawk);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", SquawkHasChanged == null ? "" : SquawkHasChanged.Value ? "-1" : "0");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Emergency == null ? "" : Emergency.Value ? "-1" : "0");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", IdentActive == null ? "" : IdentActive.Value ? "-1" : "0");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0}", OnGround == null ? "" : OnGround.Value ? "-1" : "0");

            return(result.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Returns the message as parseable BaseStation message text.
        /// </summary>
        /// <param name="emitExtendedBaseStationFormat">True if MLAT-sourced messages should use a message type of MLAT, false if they should use MSG. Ignored for other message types.</param>
        /// <returns>The properties of the message formatted up as a text string that can be sent to any application
        /// that can interpret BaseStation messages.</returns>
        public string ToBaseStationString(bool emitExtendedBaseStationFormat = false)
        {
            StringBuilder result = new StringBuilder();
            var           messageGeneratedLocal = MessageGenerated.ToLocalTime();
            var           messageLoggedLocal    = MessageLogged.ToLocalTime();

            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", BaseStationMessageHelper.ConvertToString(MessageType, IsMlat, emitExtendedBaseStationFormat));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", MessageType == BaseStationMessageType.Transmission ? BaseStationMessageHelper.ConvertToString(TransmissionType) : "");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", SessionId);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", AircraftId);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Icao24);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", FlightId);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:yyyy/MM/dd},", messageGeneratedLocal);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:HH:mm:ss.fff},", messageGeneratedLocal);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:yyyy/MM/dd},", messageLoggedLocal);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0:HH:mm:ss.fff},", messageLoggedLocal);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", MessageType == BaseStationMessageType.StatusChange ? BaseStationMessageHelper.ConvertToString(StatusCode) : Callsign);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Altitude);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.GroundSpeed(GroundSpeed));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.Track(Track));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.Coordinate(Latitude));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Round.Coordinate(Longitude));
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", VerticalRate);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Squawk);
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", SquawkHasChanged == null ? "" : SquawkHasChanged.Value ? "-1" : "0");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", Emergency == null ? "" : Emergency.Value ? "-1" : "0");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0},", IdentActive == null ? "" : IdentActive.Value ? "-1" : "0");
            result.AppendFormat(CultureInfo.InvariantCulture, "{0}", OnGround.GetValueOrDefault() ? "-1" : "0");        // Turns out BaseStation never emits a null OnGround value...

            return(result.ToString());
        }