Example #1
0
 static private long[] ReadLengthArray(byte[] bytes, int startOffset, int dataDimension, out int readDataSize)
 {
     long[] lengthArray = new long[dataDimension];
     readDataSize = dataDimension * Marshal.SizeOf(typeof(long));
     for (int iDim = 0; iDim < dataDimension; ++iDim)
     {
         lengthArray[iDim] = ChunkReader.BigEndianBytesToInt64(bytes, startOffset + iDim * Marshal.SizeOf(typeof(long)));
     }
     return(lengthArray);
 }
Example #2
0
        private void Initialize()
        {
            ntsFormats = new List <DataFormat>();
            tsFormats  = new List <DataFormat>();

            int readCursor = 0;

            byte[] bytes = dataChunk.ChunkBytes;
            while (readCursor < bytes.Length)
            {
                string ioType = ChunkReader.BytesToString(bytes, readCursor, DataFormat.IOTypeCodeSize);
                readCursor += DataFormat.IOTypeCodeSize;
                string dimension = ChunkReader.BytesToString(bytes, readCursor, DataFormat.DimensionCodeSize);
                readCursor += DataFormat.DimensionCodeSize;
                string name     = ChunkReader.NullTerminatedBytesToString(bytes, readCursor, ref readCursor);
                string elemType = ChunkReader.BytesToString(bytes, readCursor, DataFormat.ElementTypeCodeSize);
                readCursor += DataFormat.ElementTypeCodeSize;

                long[] length = new long[4];
                for (int iLength = 0; iLength < 4; ++iLength)
                {
                    length[iLength] = ChunkReader.BigEndianBytesToInt64(bytes, readCursor);
                    readCursor     += DataFormat.LengthSize;
                }

                DataFormat fmt = CreateDataFormat(ioType, dimension, name, elemType, length);
                if (fmt.IsTimeSeries)
                {
                    fmt.FormatIndex = tsFormats.Count;
                    tsFormats.Add(fmt);
                }
                else
                {
                    fmt.FormatIndex = ntsFormats.Count;
                    ntsFormats.Add(fmt);
                }
            }
        }