예제 #1
0
        //获取:空中速度消息
        public static ADS_MessageInfo GetAirSpeed(byte[] ADSData)
        {
            ADS_MessageInfo info = new ADS_MessageInfo();

            try
            {
                info.SubType = (int)(ADSData[4]);
                if (info.SubType == 1 || info.SubType == 2)
                {
                    byte   west_east_flag    = ADSData[8];
                    byte   nouth_south_flag  = ADSData[11];
                    UInt16 west_east_speed   = (UInt16)((ADSData[9] & 0xFF) | (ADSData[10] & 0xFF) << 8);
                    UInt16 nouth_south_speed = (UInt16)((ADSData[12] & 0xFF) | (ADSData[13] & 0xFF) << 8);
                    info.AirDirection = ADS_DicMessage.GetDirectionofSpeed(info.SubType, west_east_flag, nouth_south_flag, west_east_speed, nouth_south_speed);
                    info.AirSpeed     = ADS_DicMessage.GetAirSpeed(info.SubType, info.AirDirection, west_east_speed, nouth_south_speed);
                }
                else if (info.SubType == 3 || info.SubType == 4)
                {
                    byte   direction_flag = ADSData[14];
                    int    speed_flag     = (int)ADSData[17];
                    UInt16 direction      = (UInt16)((ADSData[15] & 0xFF) | (ADSData[16] & 0xFF) << 8);
                    UInt16 speed          = (UInt16)((ADSData[18] & 0xFF) | (ADSData[19] & 0xFF) << 8);

                    info.AirDirection = ADS_DicMessage.GetDirectionFor34(direction_flag, direction);
                    info.AirSpeedType = ADS_DicMessage.GetAirSpeedType(speed_flag);
                    info.AirSpeed     = ADS_DicMessage.GetAirSpeedFor34(info.SubType, speed);
                }
                else
                {
                    return(info);
                }
                info.ICAO = (uint)((ADSData[0] & 0xFF) << 16 | (ADSData[1] & 0xFF) << 8 | (ADSData[2] & 0xFF));
                info.Type = (int)(ADSData[3]);

                info.AimChange = ADS_DicMessage.GetAimChange((int)(ADSData[5]));
                info.IFR       = ADS_DicMessage.GetIFR((int)(ADSData[6]));

                info.VerticalSpeedSource = ADS_DicMessage.GetVerticalSpeedSource((int)(ADSData[20]));
                info.VerticalSpeedFlag   = ADS_DicMessage.GetVerticalSpeedFlag((int)(ADSData[21]));
                info.VerticalSpeed       = ADS_DicMessage.GetVerticalSpeed((int)((ADSData[22] & 0xFF) | (ADSData[23] & 0xFF) << 8));

                info.AtmosphereFlag = ADS_DicMessage.GetAtmosphereFlag((int)(ADSData[25]));
                info.Atmosphere     = ADS_DicMessage.GetAtmosphere((int)(ADSData[26]));
            }
            catch (System.Exception ex)
            {
                // ErrorRecord.ProcessError(ex.ToString());
            }
            return(info);
        }