Example #1
0
        public void ReadFirstThreeRecordsTest()
        {
            DateTime stamp;
            // setup the stamp variable to compare
            Assert.True(DaqDataFileInfo.TryConvert7ByteDateTime(
                new byte[] { 0x07, 0xda, 0x03, 0x0f, 0x13, 0x1e, 0x17, 0xa5 },
                0, out stamp
            ));
            using (var stream = DaqDataFileTestUtility.CreateSampleDaqFileStream()) {
                using (var reader = new DaqDataFileReader(stream)) {

                    Assert.True(reader.MoveNext());
                    Assert.AreEqual(
                        PackedReadingValues.FromDeviceBytes(new byte[] {
                            0x00, 0x01, 0x09, 0x41, 0x33, 0x60, 0x00, 0x1f
                        }, 0),
                        reader.Current.Values
                    );
                    Assert.AreEqual(stamp.Add(new TimeSpan(0, 0, 0, 1)), reader.Current.TimeStamp);

                    Assert.True(reader.MoveNext());
                    Assert.AreEqual(
                        PackedReadingValues.FromDeviceBytes(new byte[] {
                            0x00, 0x01, 0x05, 0x41, 0x33, 0x60, 0x00, 0x1f
                        }, 0),
                        reader.Current.Values
                    );
                    Assert.AreEqual(stamp.Add(new TimeSpan(0, 0, 0, 2)), reader.Current.TimeStamp);

                    Assert.True(reader.MoveNext());
                    Assert.AreEqual(
                        PackedReadingValues.FromDeviceBytes(new byte[] {
                            0x00, 0x01, 0x09, 0x41, 0x33, 0x60, 0x00, 0x1f
                        }, 0),
                        reader.Current.Values
                    );
                    Assert.AreEqual(stamp.Add(new TimeSpan(0, 0, 0, 3)), reader.Current.TimeStamp);

                }
            }
        }
Example #2
0
 private static IEnumerable<PackedReading> ReadAll(DaqDataFileReader reader)
 {
     while (reader.MoveNext()) {
         yield return reader.Current;
     }
 }