Example #1
0
        private static int ADS_GetCountry(SendClass ADS_info)
        {
            int country = 0;

            for (int i = 0; i < countryCode.Count(); i++)
            {
                int tmp = Convert.ToInt32(ADS_info.adICAO) & countryMode[i];
                if ((tmp ^ countryCode[i]) == 0)
                {
                    string str = GetCountryName(countryCode[i]);
                    country = return_country_code(str);
                }
            }
            return(country);
        }
Example #2
0
        public static TargetIdentification Send14suo_ADS(SendClass info)
        {
            TargetIdentification target_info = new TargetIdentification();

            //byte[] array = new byte[112];
            target_info.head            = 0xa5a5a5a5;
            target_info.length          = 112;
            target_info.deviceNum       = 3979;
            target_info.PH              = 0;
            target_info.produceDate     = 0;
            target_info.produceTime     = 0;
            target_info.ICAO            = new char[6];
            target_info.planeType       = 0;
            target_info.flightNumber    = new char[8];
            target_info.registrationNum = new char[20];
            target_info.area            = 0;
            target_info.flyCode         = 0;
            target_info.bak1            = 0;
            target_info.bak2            = 0;
            target_info.bak3            = 0;
            target_info.bak             = new char[20];
            byte[] Btmp8 = new byte[info.AirPlaneID.Length];
            if (info.AirPlaneID != "")
            {
                Btmp8 = System.Text.Encoding.ASCII.GetBytes(info.AirPlaneID);
                Array.Copy(Btmp8, 0, target_info.flightNumber, 0, info.AirPlaneID.Length);
            }
            target_info.produceDate = (uint)DateDiff(Convert.ToDateTime("2000-01-01 00:00:00"), info.CreatDate);
            target_info.produceTime = (uint)getMSecond(info.dtDate);
            target_info.ICAO        = Convertchar(info.adICAO.ToString());
            if (info.adlongitude != "")
            {
                target_info.bak1 = Math.Round(double.Parse(info.adlongitude), 4);
            }
            if (info.adlatitude != "")
            {
                target_info.bak2 = Math.Round(double.Parse(info.adlatitude), 4);
            }
            target_info.bak3 = Convert.ToDouble(info.Height);
            target_info.PH   = (ushort)(info.adICAO & 0xFFFF);
            target_info.area = ADS_GetCountry(info);
            bool iRet = CheckRegion(target_info.bak2, target_info.bak1, 30.71, 122.82);

            if (iRet)
            {
                if (target_info.area == 4117)
                {
                    target_info.IFF = 2;
                }
                else
                {
                    target_info.IFF = 3;
                }
            }
            else
            {
                target_info.IFF = 2;
            }
            //target_info.flightNumber = info.AirPlaneID.ToCharArray();
            //array = StructToBytes(target_info);
            return(target_info);
        }