示例#1
0
文件: CAT65.cs 项目: tanxulong/MUAC
        public string Decode(byte[] Data, string Time)
        {
            // Define output data buffer
            string DataOut;

            // Determine Length of FSPEC fields in bytes
            int FSPEC_Length = ASTERIX.DetermineLenghtOfFSPEC(Data);

            // Determine SIC/SAC Index
            int SIC_Index = 3 + FSPEC_Length;
            int SAC_Index = SIC_Index + 1;

            // Extract SIC/SAC Indexes.
            DataOut = Data[SIC_Index].ToString() + '/' + Data[SAC_Index].ToString();

            // Creates and initializes a BitVector32 with all bit flags set to FALSE.
            BitVector32 FourFSPECOctets = ASTERIX.GetFourFSPECOctets(Data);

            // Loop for each FSPEC and determine what data item is present
            for (int FSPEC_Index = 1; FSPEC_Index <= FSPEC_Length; FSPEC_Index++)
            {
                switch (FSPEC_Index)
                {
                case 1:

                    // 010 Data Source Identifier
                    if (FourFSPECOctets[Bit_Ops.Bit7] == true)
                    {
                        DataOut = DataOut + "  010:T";
                        I065DataItems[ItemIDToIndex("010")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  010:F";
                    }

                    // 000 Message Type
                    if (FourFSPECOctets[Bit_Ops.Bit6] == true)
                    {
                        DataOut = DataOut + "  000:T";
                        I065DataItems[ItemIDToIndex("000")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  000:F";
                    }

                    // 015 Service Identification
                    if (FourFSPECOctets[Bit_Ops.Bit5] == true)
                    {
                        DataOut = DataOut + "  015:T";
                        I065DataItems[ItemIDToIndex("015")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  015:F";
                    }

                    // 030 Time of Message
                    if (FourFSPECOctets[Bit_Ops.Bit4] == true)
                    {
                        DataOut = DataOut + "  030:T";
                        I065DataItems[ItemIDToIndex("030")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  030:F";
                    }

                    // 020 Batch Number
                    if (FourFSPECOctets[Bit_Ops.Bit3] == true)
                    {
                        DataOut = DataOut + "  020:T";
                        I065DataItems[ItemIDToIndex("020")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  020:F";
                    }

                    // 040 SDPS Configuration and Status
                    if (FourFSPECOctets[Bit_Ops.Bit2] == true)
                    {
                        DataOut = DataOut + "  040:T";
                        I065DataItems[ItemIDToIndex("040")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  040:F";
                    }

                    // 050 Service Status Report
                    if (FourFSPECOctets[Bit_Ops.Bit1] == true)
                    {
                        DataOut = DataOut + "  050:T";
                        I065DataItems[ItemIDToIndex("050")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  050:F";
                    }

                    break;

                // Handle errors
                default:
                    DataOut = DataOut + "  UKN:T";
                    break;
                }

                CAT65DecodeAndStore.Do(Data);
            }

            // Return decoded data
            return(DataOut);
        }