예제 #1
0
파일: CAT08.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.Bit0] == true)
                    {
                        DataOut = DataOut + "  010:T";
                        I008DataItems[ItemIDToIndex("010")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  010:F";
                    }

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

                    // 020 Vector Qualifier
                    if (FourFSPECOctets[Bit_Ops.Bit2] == true)
                    {
                        DataOut = DataOut + "  020:T";
                        I008DataItems[ItemIDToIndex("020")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  020:F";
                    }

                    // 036 Sequence of Cartesian Vectors in SPF Notation
                    if (FourFSPECOctets[Bit_Ops.Bit3] == true)
                    {
                        DataOut = DataOut + "  036:T";
                        I008DataItems[ItemIDToIndex("036")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  036:F";
                    }

                    // 034 Sequence of Polar Vectors in SPF Notation
                    if (FourFSPECOctets[Bit_Ops.Bit4] == true)
                    {
                        DataOut = DataOut + "  034:T";
                        I008DataItems[ItemIDToIndex("034")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  034:F";
                    }

                    // 040 Contour Identifier
                    if (FourFSPECOctets[Bit_Ops.Bit5] == true)
                    {
                        DataOut = DataOut + "  040:T";
                        I008DataItems[ItemIDToIndex("040")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  040:F";
                    }

                    // 050 Sequence of Contour Points in SPF Notation
                    if (FourFSPECOctets[Bit_Ops.Bit6] == true)
                    {
                        DataOut = DataOut + "  050:T";
                        I008DataItems[ItemIDToIndex("050")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  050:F";
                    }

                    break;

                case 2:

                    // 090 Time of Day
                    if (FourFSPECOctets[Bit_Ops.Bit8] == true)
                    {
                        DataOut = DataOut + "  090:T";
                        I008DataItems[ItemIDToIndex("090")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  090:F";
                    }

                    // 100 Processing Status
                    if (FourFSPECOctets[Bit_Ops.Bit9] == true)
                    {
                        DataOut = DataOut + "  100:T";
                        I008DataItems[ItemIDToIndex("100")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  100:F";
                    }

                    // 110 Station Configuration Status
                    if (FourFSPECOctets[Bit_Ops.Bit10] == true)
                    {
                        DataOut = DataOut + "  110:T";
                        I008DataItems[ItemIDToIndex("110")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  110:F";
                    }

                    // 120 Total Number of Items Constituting One Weather Picture
                    if (FourFSPECOctets[Bit_Ops.Bit11] == true)
                    {
                        DataOut = DataOut + "  120:T";
                        I008DataItems[ItemIDToIndex("120")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  120:F";
                    }

                    // 038 Sequence of Weather Vectors in SPF Notation
                    if (FourFSPECOctets[Bit_Ops.Bit12] == true)
                    {
                        DataOut = DataOut + "  038:T";
                        I008DataItems[ItemIDToIndex("038")].IsPresent = true;
                    }
                    else
                    {
                        DataOut = DataOut + "  038:F";
                    }

                    break;

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

                CAT08DecodeAndStore.Do(Data);
            }

            // Return decoded data
            return(DataOut);
        }