public static void AssertResponsesEqual(Response expected, IPersistentResponse actual)
 {
     Assert.AreEqual(expected.SampleRate, actual.SampleRate);
     Assert.AreEqual(expected.InputTime, actual.InputTime);
     CollectionAssert.AreEqual(expected.Data, actual.Data);
     AssertConfigurationSpansEqual(expected.DataConfigurationSpans.Consolidate(), actual.ConfigurationSpans);
 }
예제 #2
0
        public void ShouldComputeDuration()
        {
            Response r = new Response();

            Random random = new Random();

            IList<IMeasurement> data = (IList<IMeasurement>) Enumerable.Repeat(0, 100)
                .Select(i => random.Next()).Select(v => new Measurement(v, "V") as IMeasurement)
                .ToList();//generate random data

            IMeasurement srate = new Measurement(1000, "Hz");
            DateTimeOffset time1 = DateTimeOffset.Now;
            IDictionary<string, object> config = new Dictionary<string, object>();

            IInputData d1 = new InputData(data, srate, time1);

            DateTimeOffset time2 = time1.AddSeconds((double) (data.Count / srate.Quantity));
            IInputData d2 = new InputData(data, srate, time2);

            r.AppendData(d1);
            r.AppendData(d2);

            TimeSpan expected = new TimeSpan(0, 0, 0, 0, 200);
            Assert.AreEqual(new TimeSpan(r.DataSegments.Select(d => d.Duration.Ticks).Sum()), r.Duration);
        }
예제 #3
0
        public void ShouldAppendData()
        {
            Response r = new Response();

            IInputData d1;
            IInputData d2;
            OrderedFakeInputData(out d1, out d2);

            r.AppendData(d1);
            r.AppendData(d2);

            Assert.AreEqual(d1, r.DataSegments[0]);
            Assert.AreEqual(d2, r.DataSegments[1]);
        }
예제 #4
0
        public void CoalecesInput()
        {
            Response r = new Response();

            IInputData d1;
            IInputData d2;
            OrderedFakeInputData(out d1, out d2);

            r.AppendData(d1);
            r.AppendData(d2);

            var expected = d1.Data.Concat(d2.Data);

            Assert.NotNull(r.DataSegments);
            Assert.AreEqual(expected, r.Data);
            Assert.AreEqual(d1.SampleRate, r.SampleRate);
            Assert.AreEqual(d1.Duration + d2.Duration, r.Duration);
        }
예제 #5
0
        /// <summary>
        /// Constructs an input data stream around a given Response of a given duration.
        /// </summary>
        /// <param name="response">Response to stream</param>
        /// <param name="duration">Duration of stream</param>
        public ResponseInputDataStream(Response response, Option<TimeSpan> duration)
        {
            if (response == null)
                throw new ArgumentNullException("response");

            if (duration == null)
                throw new ArgumentNullException("duration");

            Response = response;
            Duration = duration;
            Position = TimeSpan.Zero;
        }
예제 #6
0
        public void DataIsNullForEmptySegments()
        {
            Response r = new Response();

            Assert.That(r.Data, Is.Empty);
        }
예제 #7
0
 private void WriteResponseDataConfigurationSpans(H5GroupId rId, Response r)
 {
     WriteConfigurationSpans(rId, r.DataConfigurationSpans);
 }
예제 #8
0
 private void WriteResponseData(Response r)
 {
     writer.WriteStartElement("data");
     foreach (var d in r.Data)
         WriteMeasurement(d);
     writer.WriteEndElement();
 }
예제 #9
0
 private void WriteResponseConfigurationSpans(Response r)
 {
     WriteConfigurationSpans(r.DataConfigurationSpans);
 }
예제 #10
0
        protected override void WriteResponse(Epoch e, IExternalDevice ed, Response r)
        {
            writer.WriteStartElement("response");
            writer.WriteAttributeString("device", ed.Name);

            writer.WriteElementString("inputTime", r.DataSegments.First().InputTime.ToUniversalTime().ToString());

            writer.WriteStartElement("sampleRate");
            WriteMeasurement(r.SampleRate);
            writer.WriteEndElement();

            WriteResponseConfigurationSpans(r);

            WriteResponseData(r);

            writer.WriteEndElement();
        }
예제 #11
0
 protected virtual void WriteResponse(Epoch e, IExternalDevice ed, Response r)
 {
     // write r.Data
 }
        public void SetUp()
        {
            response = new Response();

            stream = new ResponseInputDataStream(response, Option<TimeSpan>.Some(TimeSpan.FromSeconds(3)));
        }