Example #1
0
        public void CreateWriterFromReaderTest()
        {
            const string fullPath = @"D:\YandexDisk\Oscillogram\AutoCreated\bin.cfg";
            var          reader   = new RecordReader(fullPath);
            var          writer   = new RecordWriter(reader);

            writer.SaveToFile(fullPathAsciiTwo, DataFileType.ASCII);

            //TODO дописать тест - открыть сконфигурированный и проверить равенство исходному бинарному
        }
        /// <summary>
        /// Create writer with data from reader
        /// </summary>
        public RecordWriter(RecordReader reader)
        {
            this.stationName = reader.Configuration.stationName;
            this.deviceId    = reader.Configuration.deviceId;

            this.samples = new List <DataFileSample>(reader.Data.samples);
            this.analogChannelInformations  = new List <AnalogChannelInformation>(reader.Configuration.AnalogChannelInformations);
            this.digitalChannelInformations = new List <DigitalChannelInformation>(reader.Configuration.DigitalChannelInformations);
            this.sampleRates = new List <SampleRate>(reader.Configuration.sampleRates);

            this.startTime   = reader.Configuration.startTime;
            this.triggerTime = reader.Configuration.triggerTime;
        }
Example #3
0
        void ReaderAsserts(string fullpath)
        {
            var reader = new RecordReader(fullpath);

            Assert.That(reader.Configuration.AnalogChannelInformations.Count, Is.EqualTo(3));
            Assert.That(reader.Configuration.DigitalChannelInformations.Count, Is.EqualTo(17));

            var timeLine   = reader.GetTimeLine();
            var analogs1   = reader.GetAnalogPrimaryChannel(0);
            var analogs2   = reader.GetAnalogPrimaryChannel(1);
            var analogs3   = reader.GetAnalogPrimaryChannel(2);
            var digitals1  = reader.GetDigitalChannel(0);
            var digitals5  = reader.GetDigitalChannel(4);
            var digitals17 = reader.GetDigitalChannel(16);


            Assert.That(timeLine[0], Is.EqualTo(0).Within(0.01));
            Assert.That(timeLine[1], Is.EqualTo(500).Within(0.01));
            Assert.That(timeLine[2], Is.EqualTo(1000).Within(0.01));

            Assert.That(analogs1[0], Is.EqualTo(0).Within(0.01));
            Assert.That(analogs1[1], Is.EqualTo(1.0).Within(0.01));
            Assert.That(analogs1[2], Is.EqualTo(-1.0).Within(0.01));

            Assert.That(analogs2[0], Is.EqualTo(0).Within(0.01));
            Assert.That(analogs2[1], Is.EqualTo(2.0).Within(0.01));
            Assert.That(analogs2[2], Is.EqualTo(2.0).Within(0.01));

            Assert.That(analogs3[0], Is.EqualTo(0).Within(0.01));
            Assert.That(analogs3[1], Is.EqualTo(3.0).Within(0.01));
            Assert.That(analogs3[2], Is.EqualTo(-3.5).Within(0.01));

            Assert.That(digitals1[0], Is.EqualTo(true));
            Assert.That(digitals1[1], Is.EqualTo(false));
            Assert.That(digitals1[2], Is.EqualTo(false));

            Assert.That(digitals5[0], Is.EqualTo(true));
            Assert.That(digitals5[1], Is.EqualTo(false));
            Assert.That(digitals5[2], Is.EqualTo(true));

            Assert.That(digitals17[0], Is.EqualTo(true));
            Assert.That(digitals17[1], Is.EqualTo(false));
            Assert.That(digitals17[2], Is.EqualTo(true));

            Assert.That(reader.Configuration.startTime, Is.EqualTo(new DateTime(1234567890)));
            Assert.That(reader.Configuration.triggerTime, Is.EqualTo(new DateTime(1234569000)));
        }