Пример #1
0
        private ArchiveFileRecord ReadRecord(BinaryReader br)
        {
            ArchiveFileRecord r = new ArchiveFileRecord();

            r.Valid = true;
            r.Time  = "";
            byte[] buff = new byte[2];
            r.Site = "null";
            int count = br.Read(buff, 0, 2);

            if (count <= 0)
            {
                r.Valid = false;
                if (br.BaseStream.Position == br.BaseStream.Length)
                {
                    return(r);
                }
            }
            r.Id = BitConverter.ToInt16(buff, 0);

            r.Site = new string(br.ReadChars(12));
            if (r.Site == null)
            {
                r.Site  = "null";
                r.Valid = false;
            }

            r.Pcode = new string(br.ReadChars(9));
            r.Time  = new string(br.ReadChars(4));
            br.ReadChars(5); // spare bytes.

            r.Values = new float[366];
            for (int i = 0; i < 366; i++)
            {
                byte[] b = br.ReadBytes(4);
                if (b.Length != 4)
                {
                    r.Valid = false;
                    break;
                }
                float f = VaxBinaryReader.VaxSingleFromBytes(b);
                r.Values[i] = f;
            }

            br.ReadChars(5); // spare bytes.
            return(r);
        }
Пример #2
0
        private float[] ReadValues(BinaryReader br, int count)
        {
            float[] rval = new float[count];
            float   f;

            //  Console.WriteLine(" OB             15.45 # PC             17.87");
            for (int i = 0; i < count; i++)
            {
                byte[] b = br.ReadBytes(4);
                if (b.Length != 4)
                {
                    Console.WriteLine("Error: only " + b.Length + " bytes.  Expected 4");

                    f = (float)Point.MissingValueFlag;
                }
                else
                {
                    f = VaxBinaryReader.VaxSingleFromBytes(b);
                }

                rval[i] = f;
            }
            return(rval);
        }