コード例 #1
0
        // Filled
        public CAT10(ref HelpDecode decode, ref CAT10Helper cat10Helper, string[] array, int id, string[] messageBinary)
        {
            try
            {
                //Decode FSPEC
                string FSPEC0      = decode.getFSPEC(array);
                int    octetsFSPEC = FSPEC0.Length / 7;
                int    index       = 3 + octetsFSPEC;
                this.FSPEC     = FSPEC0.ToCharArray(0, FSPEC0.Length);
                message        = messageBinary;
                this.Id        = id;
                this.numOctets = array.Length;
                if (id == 34)
                {
                    String ds = "";
                }

                /* From now on each function looks to see if the decoding parameter exists in the
                 * message (checking if the FSPEC in its position == 1) and if it exists calls the function to decode the parameter */

                if (FSPEC[0] == '1')
                {
                    index            = cat10Helper.Compute_Data_Source_Identifier(message, index);
                    this.SAC         = cat10Helper.SAC;
                    this.SIC         = cat10Helper.SIC;
                    this.airportCode = cat10Helper.airportCode;
                    this.TAR         = cat10Helper.TAR;
                } //
                if (FSPEC[1] == '1')
                {
                    index            = cat10Helper.Compute_Message_Type(message, index);
                    this.messageType = cat10Helper.MESSAGE_TYPE;
                } //
                if (FSPEC[2] == '1')
                {
                    index    = cat10Helper.Compute_Target_Report_Descriptor(message, index);
                    this.TYP = cat10Helper.TYP;
                    this.DCR = cat10Helper.DCR;
                    this.CHN = cat10Helper.CHN;
                    this.GBS = cat10Helper.GBS;
                    this.CRT = cat10Helper.CRT;
                    this.SIM = cat10Helper.SIM;
                    this.TST = cat10Helper.TST;
                    this.RAB = cat10Helper.RAB;
                    this.LOP = cat10Helper.LOP;
                    this.TOT = cat10Helper.TOT;
                    this.SPI = cat10Helper.SPI;
                } //
                if (FSPEC[3] == '1')
                {
                    index                   = cat10Helper.Compute_Time_of_Day(message, index);
                    this.TimeOfDay          = cat10Helper.Time_Of_Day;
                    this.TimeOfDayInSeconds = cat10Helper.Time_of_day_sec;
                } //
                if (FSPEC[4] == '1')
                {
                    index = cat10Helper.Compute_Position_in_WGS_84_Coordinates(message, index);
                    this.LatitudeWGS_84 = cat10Helper.Latitude_in_WGS_84;
                    this.LatitudeWGS_84 = cat10Helper.Longitude_in_WGS_84;
                } //
                if (FSPEC[5] == '1')
                {
                    index      = cat10Helper.Compute_Measured_Position_in_Polar_Coordinates(message, index);
                    this.RHO   = cat10Helper.RHO;
                    this.THETA = cat10Helper.THETA;
                }
                if (FSPEC[6] == '1')
                {
                    index                  = cat10Helper.Compute_Position_in_Cartesian_Coordinates(message, index);
                    this.X_Component       = cat10Helper.X_Component;
                    this.Y_Component       = cat10Helper.Y_Component;
                    this.Position_In_Polar = cat10Helper.Position_In_Polar;
                }  //
                if (FSPEC.Count() > 8)
                {
                    if (FSPEC[7] == '1')
                    {
                        index            = cat10Helper.Compute_Track_Velocity_in_Polar_Coordinates(message, index);
                        this.GroundSpeed = cat10Helper.Ground_Speed;
                        this.TrackAngle  = cat10Helper.Track_Angle;
                    }  //
                    if (FSPEC[8] == '1')
                    {
                        index   = cat10Helper.Compute_Track_Velocity_in_Cartesian_Coordinates(message, index);
                        this.Vx = cat10Helper.Vx;
                        this.Vy = cat10Helper.Vy;
                    }  //
                    if (FSPEC[9] == '1')
                    {
                        index            = cat10Helper.Compute_Track_Number(message, index);
                        this.TrackNumber = cat10Helper.Track_Number;
                    }  //
                    if (FSPEC[10] == '1')
                    {
                        index    = cat10Helper.Compute_Track_Status(message, index);
                        this.CNF = cat10Helper.CNF;
                        this.TRE = cat10Helper.TRE;
                        this.CST = cat10Helper.CST;
                        this.MAH = cat10Helper.MAH;
                        this.TCC = cat10Helper.TCC;
                        this.STH = cat10Helper.STH;
                        this.TOM = cat10Helper.TOM;
                        this.DOU = cat10Helper.DOU;
                        this.MRS = cat10Helper.MRS;
                        this.GHO = cat10Helper.GHO;
                    }  //
                    if (FSPEC[11] == '1')
                    {
                        index        = cat10Helper.Compute_Mode_3A_Code_in_Octal_Representation(message, index);
                        this.VMode3A = cat10Helper.V_Mode_3A;
                        this.GMode3A = cat10Helper.G_Mode_3A;
                        this.LMode3A = cat10Helper.L_Mode_3A;
                        this.Mode3A  = cat10Helper.Mode_3A;
                    }  //
                    if (FSPEC[12] == '1')
                    {
                        index = cat10Helper.Compute_Target_Address(message, index);
                        this.TargetAddress = cat10Helper.Target_Address;
                    }  //
                    if (FSPEC[13] == '1')
                    {
                        index    = cat10Helper.Compute_Target_Identification(message, index);
                        this.STI = cat10Helper.STI;
                    }  //
                }
                if (FSPEC.Count() > 16)
                {
                    if (FSPEC[14] == '1')
                    {
                        index         = cat10Helper.Compute_Mode_S_MB_Data(message, index);
                        this.MBData   = cat10Helper.MB_Data;
                        this.BDS1     = cat10Helper.BDS1;
                        this.BDS2     = cat10Helper.BDS2;
                        this.modeSrep = cat10Helper.modeS_rep;
                    }  //
                    if (FSPEC[15] == '1')
                    {
                        index    = cat10Helper.Compute_Vehicle_Fleet_Identificatior(message, index);
                        this.VFI = cat10Helper.VFI;
                    }  //
                    if (FSPEC[16] == '1')
                    {
                        index                  = cat10Helper.Compute_Flight_Level_in_Binary_Representaion(message, index);
                        this.VFlightLevel      = cat10Helper.V_Flight_Level;
                        this.GFlightLevel      = cat10Helper.G_Flight_Level;
                        this.FlightLevelBinary = cat10Helper.Flight_Level_Binary;
                        this.FlightLevel       = cat10Helper.Flight_Level;
                    }  //
                    if (FSPEC[17] == '1')
                    {
                        index = cat10Helper.Compute_Measured_Height(message, index);
                        this.MeasuredHeight = cat10Helper.Measured_Height;
                    }  //
                    if (FSPEC[18] == '1')
                    {
                        index            = cat10Helper.Compute_Target_Size_and_Orientation(message, index);
                        this.LENGHT      = cat10Helper.LENGHT;
                        this.ORIENTATION = cat10Helper.ORIENTATION;
                        this.WIDTH       = cat10Helper.WIDTH;
                    }  //
                    if (FSPEC[19] == '1')
                    {
                        index     = cat10Helper.Compute_System_Status(message, index);
                        this.NOGO = cat10Helper.NOGO;
                        this.OVL  = cat10Helper.OVL;
                        this.TSV  = cat10Helper.TSV;
                        this.DIV  = cat10Helper.DIV;
                        this.SAC  = cat10Helper.TIF;
                    }  //
                    if (FSPEC[20] == '1')
                    {
                        index    = cat10Helper.Compute_Preprogrammed_Message(message, index);
                        this.TRB = cat10Helper.TRB;
                        this.MSG = cat10Helper.MSG;
                    } //
                }
                if (FSPEC.Count() > 22)
                {
                    if (FSPEC[21] == '1')
                    {
                        index             = cat10Helper.Compute_Standard_Deviation_of_Position(message, index);
                        this.DeviationX   = cat10Helper.Deviation_X;
                        this.DeviationY   = cat10Helper.Deviation_Y;
                        this.CovarianceXY = cat10Helper.Covariance_XY;
                    }
                    if (FSPEC[22] == '1')
                    {
                        index       = cat10Helper.Compute_Presence(message, index);
                        this.REP    = cat10Helper.REP_Presence;
                        this.DRHO   = cat10Helper.DRHO;
                        this.DTHETA = cat10Helper.DTHETA;
                    }
                    if (FSPEC[23] == '1')
                    {
                        index    = cat10Helper.Compute_Amplitude_of_Primary_Plot(message, index);
                        this.PAM = cat10Helper.PAM;
                    }
                    if (FSPEC[24] == '1')
                    {
                        index   = cat10Helper.Compute_Calculated_Acceleration(message, index);
                        this.Ax = cat10Helper.Ax;
                        this.Ay = cat10Helper.Ay;
                    }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #2
0
        public void read(string path)
        {
            if (tablaCAT10.Columns.Count != 27)
            {
                StartTable10();
            }
            if (tablaCAT21.Columns.Count != 43)
            {
                StartTable21();
            }
            // Load file to RAM
            byte[] fileBytes = File.ReadAllBytes(path);
            // New Version Improvement by 0.673ms@4Ghz and 150MB ram usage only
            // Go over all of the packets and store them in a separate list of lists
            // First Octet Category
            List <Byte> fileBytesList = fileBytes.ToList();
            // 2nd*256 + 3rd Octet = Length in Bytes
            int messageCategory = fileBytes[0];
            int messageLength; // 2nd*256 + 3rd Octet
            List <List <Byte> > messages        = new List <List <Byte> >();
            List <String[]>     messagesHex     = new List <String[]>();
            List <String[]>     messagesBinary  = new List <String[]>();
            List <int>          messagesLengths = new List <int>();
            // Store messages from the fileBytes into packet size Blocks using messageLength
            int           currPointer = 0;
            int           lengthFile  = fileBytesList.Count;
            List <Byte>   message;
            List <string> messageHex    = new List <string>();
            List <string> messageBinary = new List <string>();

            while ((currPointer + 1) < lengthFile)
            {
                messageLength = (fileBytes[currPointer + 1] * 256) + fileBytes[currPointer + 2];
                message       = fileBytesList.GetRange(currPointer, messageLength);

                // Convert Message Byte to Messages of Hexadecimal
                messagesBinary.Add(message.Select(x => Convert.ToString(x, 2).PadLeft(8, '0')).ToArray());
                message.ForEach((b) =>
                {
                    messageHex.Add(b.ToString("X"));
                });
                // Store the Message and Message in Hex
                messages.Add(message); // (currentMessageByte)-LastByteIncluded
                messagesHex.Add(messageHex.ToArray());
                messageHex.Clear();
                messagesLengths.Add(messageLength);
                currPointer += messageLength;
            }

            // Messages separated --> Now we have to convert them according to CAT 10 or CAT 21
            HelpDecode decode = new HelpDecode();
            // To improve performance, just 1 object generated. For entire list
            CAT10Helper cat10Helper = new CAT10Helper(ref decode);
            CAT21Helper cat21Helper = new CAT21Helper(ref decode);
            //List<CAT10> arrCat10 = new List<CAT10>[listhex.Count];
            List <CAT10> arrCat10 = new List <CAT10>();
            List <CAT21> arrCat21 = new List <CAT21>();

            /*CAT10 newcat10 = new CAT10(decode, cat10Helper); */
            string[] arraystring;
            /*CAT21v21 newcat21 = new CAT21v21(decode, cat10Helper);*/
            CAT10 temp10; CAT21 temp21;

            for (int q = 0; q < messagesHex.Count; q++)
            {
                arraystring = messagesHex[q];
                /*int CAT = int.Parse(arraystring[0], System.Globalization.NumberStyles.HexNumber);*/

                if (arraystring[0] == "A")
                {
                    temp10 = new CAT10(ref decode, ref cat10Helper, arraystring, q, messagesBinary[q]);
                    arrCat10.Add(temp10);
                    AddRowTable10(temp10);
                }
                else if (arraystring[0] == "15")
                {
                    /*temp21 = new CAT21(ref decode, ref cat21Helper, arraystring, q, messagesBinary[q]);
                     * arrCat21.Add(temp21);
                     * AddRowTable21(temp21);*/
                }
            }
            string a = ";";
        }