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); }
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); }
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]); }
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); }
/// <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; }
public void DataIsNullForEmptySegments() { Response r = new Response(); Assert.That(r.Data, Is.Empty); }
private void WriteResponseDataConfigurationSpans(H5GroupId rId, Response r) { WriteConfigurationSpans(rId, r.DataConfigurationSpans); }
private void WriteResponseData(Response r) { writer.WriteStartElement("data"); foreach (var d in r.Data) WriteMeasurement(d); writer.WriteEndElement(); }
private void WriteResponseConfigurationSpans(Response r) { WriteConfigurationSpans(r.DataConfigurationSpans); }
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(); }
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))); }