AsterixDisplayAnalyser.ASTERIX.ExtractLengthOfDataBlockInBytes_Int C# (CSharp) Метод

ExtractLengthOfDataBlockInBytes_Int() публичный статический Метод

public static ExtractLengthOfDataBlockInBytes_Int ( byte Data ) : int
Data byte
Результат int
        public static int ExtractLengthOfDataBlockInBytes_Int(byte[] Data)
        {
            // Get an instance of bit ops
            Bit_Ops BO = new Bit_Ops();

            // Extract first 16 bits
            // 15..........................0
            // 00000000             00000000
            // First_LEN_Octet   Second_LEN_Octet

            BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[Second_LEN_Octet];
            BO.DWord[Bit_Ops.Bits8_15_Of_DWord] = Data[First_LEN_Octet];

            int Result = BO.DWord[Bit_Ops.Bits0_15_Of_DWord];
            return Result;
        }

Usage Example

        public static string DecodeAsterixData(string FileName)
        {
            long Position = 0;
            // get total byte length of the file
            long TotalBytes = new System.IO.FileInfo(FileName).Length;

            try
            {
                // Open file for reading
                System.IO.FileStream FileStream = new System.IO.FileStream(FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);

                // attach filestream to binary reader
                System.IO.BinaryReader BinaryReader = new System.IO.BinaryReader(FileStream);

                while (Position < TotalBytes)
                {
                    // First determine the size of the message
                    // octet    data
                    // 0        ASTERIX CATEGORY
                    // 1 .. 2   LENGTH OF MESSAGE BLOCK
                    byte[] Data_Block_Buffer    = BinaryReader.ReadBytes((Int32)3);
                    int    LengthOfMessageBlock = ASTERIX.ExtractLengthOfDataBlockInBytes_Int(Data_Block_Buffer);

                    BinaryReader.BaseStream.Position = BinaryReader.BaseStream.Position - 3;
                    // Now read the message and pass it to the parser
                    // for decoding
                    Data_Block_Buffer = BinaryReader.ReadBytes((Int32)LengthOfMessageBlock);
                    ExtractAndDecodeASTERIX_CAT_DataBlock(Data_Block_Buffer, false);
                    Position = BinaryReader.BaseStream.Position;
                }

                // close file reader
                FileStream.Close();
                FileStream.Dispose();
                BinaryReader.Close();
            }
            catch (Exception Exception)
            {
                // Error
                MessageBox.Show("Exception caught in process: {0}", Exception.ToString());
            }

            return("Read " + Position.ToString() + " of total " + TotalBytes.ToString() + " bytes");
        }
All Usage Examples Of AsterixDisplayAnalyser.ASTERIX::ExtractLengthOfDataBlockInBytes_Int