Esempio n. 1
0
        // Static Decoder

        /// <summary>
        /// Decode a METAR Message
        /// </summary>
        /// <param name="raw">The raw message starting with the StationID</param>
        /// <param name="mdata">The MData record to fill</param>
        private static void DecodeMetar(string raw, MTData mdata)
        {
            raw = M_StationDecoder.Decode(raw, mdata.Station);
            if (!mdata.Station.Valid)
            {
                return;                   // ERROR must have
            }
            raw = M_ObsTimeDecoder.Decode(raw, mdata.ObsTime);
            if (!mdata.ObsTime.Valid)
            {
                return;                   // ERROR must have
            }
            raw = M_ModifierDecoder.Decode(raw, mdata.Modifier);
            if (mdata.Modifier.IsNil)
            {
                // cancelled - forget the rest and return
                return;
            }

            raw = M_WindDecoder.Decode(raw, mdata.Wind);
            raw = M_WindDecoder.Decode(raw, mdata.Wind); // optional variable part, will capture if there

            raw = M_VisibilityDecoder.Decode(raw, mdata.Visibility);

            while (M_RunwayVRDecoder.IsMatch(raw))// optional multiple
            {
                raw = M_RunwayVRDecoder.Decode(raw, mdata.RunwayVRs);
            }
            ;

            while (M_WeatherDecoder.IsMatch(raw))// optional multiple
            {
                raw = M_WeatherDecoder.Decode(raw, mdata.Weather);
            }

            while (M_SkyConditionDecoder.IsMatch(raw))// optional multiple
            {
                raw = M_SkyConditionDecoder.Decode(raw, mdata.SkyConditions);
            }
            ;

            raw = M_TempDecoder.Decode(raw, mdata.Temperature);
            raw = M_PressureDecoder.Decode(raw, mdata.Altimeter);

            // RMKs

            // Eval Category
            mdata.FlightCategory = M_CategoryDecoder.Decode(mdata);
        }
Esempio n. 2
0
        /// <summary>
        /// Decode a TAF Message
        /// </summary>
        /// <param name="raw">The raw message starting with the StationID</param>
        /// <param name="mdata">The MData record to fill</param>
        private static void DecodeTaf(string raw, MTData mdata)
        {
            raw = M_StationDecoder.Decode(raw, mdata.Station);
            if (!mdata.Station.Valid)
            {
                return;                   // ERROR must have
            }
            raw = M_ObsTimeDecoder.Decode(raw, mdata.ObsTime);
            if (!mdata.ObsTime.Valid)
            {
                return;                   // ERROR must have
            }
            raw = T_PeriodDecoder.Decode(raw, mdata.TafPeriod);
            if (!mdata.TafPeriod.Valid)
            {
                return;                     // ERROR must have
            }
            if (T_CancelDecoder.IsMatch(raw))
            {
                // cancelled - collect the flag, forget the rest and return
                raw = T_CancelDecoder.Decode(raw, mdata);
                return;
            }

            // add the basic FC record here as we go and process further parts
            mdata.Forecasts.Add(new T_Forecast( )
            {
                Valid = true, From = mdata.TafPeriod.From, To = mdata.TafPeriod.To, IsTimeSpan = true
            });

            raw = M_WindDecoder.Decode(raw, mdata.Forecasts.First( ).Wind);
            raw = M_WindDecoder.Decode(raw, mdata.Forecasts.First( ).Wind); // optional variable part, will capture if there

            raw = M_VisibilityDecoder.Decode(raw, mdata.Forecasts.First( ).Visibility);

            while (M_WeatherDecoder.IsMatch(raw))// optional multiple
            {
                raw = M_WeatherDecoder.Decode(raw, mdata.Forecasts.First( ).Weather);
            }

            while (M_SkyConditionDecoder.IsMatch(raw))// optional multiple
            {
                raw = M_SkyConditionDecoder.Decode(raw, mdata.Forecasts.First( ).SkyConditions);
            }
            ;

            while (T_TempMinMaxDecoder.IsMatch(raw))// optional multiple
            {
                raw = T_TempMinMaxDecoder.Decode(raw, mdata.Forecasts.First( ).TempMinMax);
            }
            ;
            // Eval Category
            mdata.Forecasts.First( ).FlightCategory = M_CategoryDecoder.Decode(mdata.Forecasts.First( ));

            // We should get into the additional forecast records now..
            while (T_ForecastDecoder.IsMatch(raw))
            {
                raw = T_ForecastDecoder.Decode(raw, mdata.Forecasts);
                // collect the allowed forecast records
                raw = M_WindDecoder.Decode(raw, mdata.Forecasts.Last( ).Wind);
                raw = M_WindDecoder.Decode(raw, mdata.Forecasts.Last( ).Wind); // optional variable part, will capture if there

                raw = M_VisibilityDecoder.Decode(raw, mdata.Forecasts.Last( ).Visibility);

                while (M_WeatherDecoder.IsMatch(raw))// optional multiple
                {
                    raw = M_WeatherDecoder.Decode(raw, mdata.Forecasts.Last( ).Weather);
                }

                while (M_SkyConditionDecoder.IsMatch(raw))// optional multiple
                {
                    raw = M_SkyConditionDecoder.Decode(raw, mdata.Forecasts.Last( ).SkyConditions);
                }
                ;
                // Eval Category
                mdata.Forecasts.Last( ).FlightCategory = M_CategoryDecoder.Decode(mdata.Forecasts.Last( ));
            }
        }