Decode() public method

public Decode ( byte DataBlockBuffer, string Time, int &NumOfMessagesDecoded ) : string[]
DataBlockBuffer byte
Time string
NumOfMessagesDecoded int
return string[]
        private static void ExtractAndDecodeASTERIX_CAT_DataBlock(byte[] DataBlock, bool Is_Live_Data)
        {
            // First thing is to store the time of the reception regardless of the category received
            string Time = DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" +
                DateTime.Now.Second.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Millisecond.ToString().PadLeft(3, '0');

            // Save off the time of reception so decoders can use it
            TimeOfReception = DateTime.Now;

            // Extract ASTERIX category
            string Category = ASTERIX.ExtractCategory(DataBlock);

            // Extract lenght in Bytes, as indicated by the ASTERIX
            string LengthOfDataBlockInBytes = ASTERIX.ExtractLengthOfDataBlockInBytes(DataBlock);

            // Here format the lenght of bytes
            // to always use 3 characters for better alignement
            if (LengthOfDataBlockInBytes.Length < 3)
            {
                LengthOfDataBlockInBytes = "0" + LengthOfDataBlockInBytes;
            }
            else if (LengthOfDataBlockInBytes.Length < 2)
            {
                LengthOfDataBlockInBytes = "00" + LengthOfDataBlockInBytes;
            }

            // Define a string to store data not specific for all messages and add commond data
            // 1. TIME of reception
            // 2. Source IP address
            // 3. Multicast IP address
            // 4. Length of data block in bytes
            // 5. Asterix Category
            //
            // 6. Append Category specifc data, done just below

            string Common_Message_Data_String;
            if (Is_Live_Data == true)
                Common_Message_Data_String = Time + "     " + iep.ToString() + "        " + SharedData.CurrentMulticastAddress + ':' + SharedData.Current_Port.ToString() + "             " + LengthOfDataBlockInBytes.ToString() + "        " + Category + "           ";
            else
                Common_Message_Data_String = Time + "     " + "Recorded" + "        " + "Recorded" + ':' + "Recorded" + "             " + LengthOfDataBlockInBytes.ToString() + "        " + Category + "           ";
            // Hold individual records of the messages
            // from an individual data block
            string[] MessageData = new string[3000];

            byte[] DataBlockNoCATandLEN = new byte[DataBlock.Length - 3];

            // Now after we extracted Category and Lenght of the Data Block lets remove the first three octets from the data
            // buffer and pass it on to individual message handlers to do message decoding
            Array.Copy(DataBlock, 3, DataBlockNoCATandLEN, 0, (DataBlock.Length - 3));

            DataBlock = DataBlockNoCATandLEN;

            // Now do a switch based on the category received
            int NumOfMsgsDecoded = 0;
            switch (Category)
            {
                // Monoradar Data Target Reports, from a Radar Surveillance System to an SDPS
                // (plots and tracks from PSRs, SSRs, MSSRs, excluding Mode S and ground surveillance)
                case "001":
                    if (Properties.Settings.Default.CAT_001_Enabled == true)
                    {
                        CAT01 MyCAT01 = new CAT01();
                        MessageData = MyCAT01.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                    }
                    break;
                // Monoradar Service Messages (status, North marker, sector crossing messages)
                case "002":
                    if (Properties.Settings.Default.CAT_002_Enabled == true)
                    {
                        CAT02 MyCAT02 = new CAT02();
                        MessageData = MyCAT02.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                    }
                    break;
                // Monoradar Derived Weather Information
                case "008":
                    if (Properties.Settings.Default.CAT_008_Enabled == true)
                    {
                        CAT08 MyCAT08 = new CAT08();
                    }
                    break;
                // Next version of Category 002: PSR Radar, M-SSR Radar, Mode-S Station
                case "034":
                    if (Properties.Settings.Default.CAT_034_Enabled == true)
                    {
                        CAT34 MyCAT34 = new CAT34();
                        MessageData = MyCAT34.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                    }
                    break;
                // Next version of Category 001: PSR Radar, M-SSR Radar, Mode-S Station
                case "048":
                    if (Properties.Settings.Default.CAT_048_Enabled == true)
                    {
                        CAT48 MyCAT48 = new CAT48();
                        MessageData = MyCAT48.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                    }
                    break;
                // System Track Data(next version of Category 030 & 011, also applicable to non-ARTAS systems)
                case "062":
                    if (Properties.Settings.Default.CAT_062_Enabled == true)
                    {
                        CAT62 MyCAT62 = new CAT62();
                        MessageData = MyCAT62.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                    }
                    break;
                // Sensor Status Messages (SPDS)
                case "063":
                    if (Properties.Settings.Default.CAT_063_Enabled == true)
                    {
                        CAT63 MyCAT63 = new CAT63();
                    }
                    break;
                // SDPS Service Status Messages (SDPS)
                case "065":
                    if (Properties.Settings.Default.CAT_065_Enabled == true)
                    {
                        CAT65 MyCAT65 = new CAT65();
                    }
                    break;
                // Transmission of Reference Trajectory State Vectors
                case "244":
                    if (Properties.Settings.Default.CAT_244_Enabled == true)
                    {
                        CAT244 MyCAT244 = new CAT244();
                    }
                    break;
                // Handle unsupported data/categories
                default:
                    Common_Message_Data_String = Common_Message_Data_String + " Unsupported category " + Category + " has been received";
                    break;
            }

            if (Properties.Settings.Default.PopulateMainListBox == true)
            {
                for (int I = 0; I < NumOfMsgsDecoded; I++)
                    SharedData.DataBox.Items.Add(Common_Message_Data_String + MessageData[I]);
            }
        }
        private static void ExtractAndDecodeASTERIX_CAT_DataBlock(byte[] DataBlock, bool Is_Live_Data)
        {
            // First thing is to store the time of the reception regardless of the category received
            string Time = DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" +
                          DateTime.Now.Second.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Millisecond.ToString().PadLeft(3, '0');

            // Save off the time of reception so decoders can use it
            TimeOfReception = DateTime.Now;

            // Extract ASTERIX category
            string Category = ASTERIX.ExtractCategory(DataBlock);

            // Extract lenght in Bytes, as indicated by the ASTERIX
            string LengthOfDataBlockInBytes = ASTERIX.ExtractLengthOfDataBlockInBytes(DataBlock);

            // Here format the lenght of bytes
            // to always use 3 characters for better alignement
            if (LengthOfDataBlockInBytes.Length < 3)
            {
                LengthOfDataBlockInBytes = "0" + LengthOfDataBlockInBytes;
            }
            else if (LengthOfDataBlockInBytes.Length < 2)
            {
                LengthOfDataBlockInBytes = "00" + LengthOfDataBlockInBytes;
            }

            // Define a string to store data not specific for all messages and add commond data
            // 1. TIME of reception
            // 2. Source IP address
            // 3. Multicast IP address
            // 4. Length of data block in bytes
            // 5. Asterix Category
            //
            // 6. Append Category specifc data, done just below

            string Common_Message_Data_String;

            if (Is_Live_Data == true)
            {
                Common_Message_Data_String = Time + "     " + iep.ToString() + "        " + SharedData.CurrentMulticastAddress + ':' + SharedData.Current_Port.ToString() + "             " + LengthOfDataBlockInBytes.ToString() + "        " + Category + "           ";
            }
            else
            {
                Common_Message_Data_String = Time + "     " + "Recorded" + "        " + "Recorded" + ':' + "Recorded" + "             " + LengthOfDataBlockInBytes.ToString() + "        " + Category + "           ";
            }
            // Hold individual records of the messages
            // from an individual data block
            string[] MessageData = new string[3000];

            byte[] DataBlockNoCATandLEN = new byte[DataBlock.Length - 3];

            // Now after we extracted Category and Lenght of the Data Block lets remove the first three octets from the data
            // buffer and pass it on to individual message handlers to do message decoding
            Array.Copy(DataBlock, 3, DataBlockNoCATandLEN, 0, (DataBlock.Length - 3));

            DataBlock = DataBlockNoCATandLEN;

            // Now do a switch based on the category received
            int NumOfMsgsDecoded = 0;

            switch (Category)
            {
            // Monoradar Data Target Reports, from a Radar Surveillance System to an SDPS
            // (plots and tracks from PSRs, SSRs, MSSRs, excluding Mode S and ground surveillance)
            case "001":
                if (Properties.Settings.Default.CAT_001_Enabled == true)
                {
                    CAT01 MyCAT01 = new CAT01();
                    MessageData = MyCAT01.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                }
                break;

            // Monoradar Service Messages (status, North marker, sector crossing messages)
            case "002":
                if (Properties.Settings.Default.CAT_002_Enabled == true)
                {
                    CAT02 MyCAT02 = new CAT02();
                    MessageData = MyCAT02.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                }
                break;

            // Monoradar Derived Weather Information
            case "008":
                if (Properties.Settings.Default.CAT_008_Enabled == true)
                {
                    CAT08 MyCAT08 = new CAT08();
                }
                break;

            // Next version of Category 002: PSR Radar, M-SSR Radar, Mode-S Station
            case "034":
                if (Properties.Settings.Default.CAT_034_Enabled == true)
                {
                    CAT34 MyCAT34 = new CAT34();
                    MessageData = MyCAT34.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                }
                break;

            // Next version of Category 001: PSR Radar, M-SSR Radar, Mode-S Station
            case "048":
                if (Properties.Settings.Default.CAT_048_Enabled == true)
                {
                    CAT48 MyCAT48 = new CAT48();
                    MessageData = MyCAT48.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                }
                break;

            // System Track Data(next version of Category 030 & 011, also applicable to non-ARTAS systems)
            case "062":
                if (Properties.Settings.Default.CAT_062_Enabled == true)
                {
                    CAT62 MyCAT62 = new CAT62();
                    MessageData = MyCAT62.Decode(DataBlock, Time, out NumOfMsgsDecoded);
                }
                break;

            // Sensor Status Messages (SPDS)
            case "063":
                if (Properties.Settings.Default.CAT_063_Enabled == true)
                {
                    CAT63 MyCAT63 = new CAT63();
                }
                break;

            // SDPS Service Status Messages (SDPS)
            case "065":
                if (Properties.Settings.Default.CAT_065_Enabled == true)
                {
                    CAT65 MyCAT65 = new CAT65();
                }
                break;

            // Transmission of Reference Trajectory State Vectors
            case "244":
                if (Properties.Settings.Default.CAT_244_Enabled == true)
                {
                    CAT244 MyCAT244 = new CAT244();
                }
                break;

            // Handle unsupported data/categories
            default:
                Common_Message_Data_String = Common_Message_Data_String + " Unsupported category " + Category + " has been received";
                break;
            }

            if (Properties.Settings.Default.PopulateMainListBox == true)
            {
                for (int I = 0; I < NumOfMsgsDecoded; I++)
                {
                    SharedData.DataBox.Items.Add(Common_Message_Data_String + MessageData[I]);
                }
            }
        }