本文整理汇总了C#中Controller.PullOutputData方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.PullOutputData方法的具体用法?C# Controller.PullOutputData怎么用?C# Controller.PullOutputData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller.PullOutputData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PullsOutputData
public void PullsOutputData()
{
var c = new Controller();
IExternalDevice dev = new UnitConvertingExternalDevice(UNUSED_DEVICE_NAME, UNUSED_DEVICE_MANUFACTURER, c, UNUSED_BACKGROUND);
const int srate = 1000;
IList<IMeasurement> data = (IList<IMeasurement>) Enumerable.Range(0, srate * 2).Select(i => new Measurement(i, "V") as IMeasurement).ToList();
var sampleRate = new Measurement(srate, "Hz");
IOutputData data1 = new OutputData(data, sampleRate, false);
var e = new Epoch("");
e.Stimuli[dev] = new RenderedStimulus((string) "RenderedStimulus", (IDictionary<string, object>) new Dictionary<string, object>(),
data1);
e.Background[dev] = new Epoch.EpochBackground(new Measurement(0, "V"), sampleRate);
c.EnqueueEpoch(e);
TimeSpan d1 = TimeSpan.FromSeconds(0.75);
c.EnqueueEpoch(e);
c.NextEpoch();
var pull1 = c.PullOutputData(dev, d1);
var pull2 = c.PullOutputData(dev, d1);
var samples = (int)d1.Samples(new Measurement(srate, "Hz"));
Assert.AreEqual(data.Take(samples).ToList(),
pull1.Data);
Assert.AreEqual(data.Skip(samples).Take(samples).ToList(),
pull2.Data);
var pull3 = c.PullOutputData(dev, d1);
Assert.AreEqual(data.Skip(2 * samples)
.Take(samples)
.Concat(Enumerable.Range(0, srate - samples).Select(i => e.Background[dev].Background))
.ToList(),
pull3.Data);
}
示例2: ShouldSupplyEpochBackgroundForExternalDevicesWithoutStimuli
public void ShouldSupplyEpochBackgroundForExternalDevicesWithoutStimuli()
{
var c = new Controller();
var dev1 = new UnitConvertingExternalDevice("dev1", "co", c, new Measurement(0, "V"));
var dev2 = new UnitConvertingExternalDevice("dev2", "co", c, new Measurement(0, "V"));
int baseSamples = 1000;
IList<IMeasurement> data = (IList<IMeasurement>)Enumerable.Range(0, baseSamples)
.Select(i => new Measurement(i, "V") as IMeasurement)
.ToList();
Measurement sampleRate = new Measurement(baseSamples, "Hz");
var config = new Dictionary<string, object>();
IOutputData data1 = new OutputData(data, sampleRate, true);
var e = new Epoch("");
e.Stimuli[dev1] = new RenderedStimulus((string) "RenderedStimulus", (IDictionary<string, object>) config, data1);
var backgroundMeasurement = new Measurement(3.2m, "V");
e.Background[dev2] = new Epoch.EpochBackground(backgroundMeasurement, sampleRate);
c.EnqueueEpoch(e);
c.NextEpoch();
var out1 = c.PullOutputData(dev1, e.Duration);
Assert.NotNull(out1);
var out2 = c.PullOutputData(dev2, e.Duration);
Assert.NotNull(out2);
Assert.AreEqual((TimeSpan)e.Duration, out2.Duration);
Assert.AreEqual(backgroundMeasurement, out2.Data.First());
}
示例3: PullOutputDataShouldReturnNullWithNullCurrentEpoch
public void PullOutputDataShouldReturnNullWithNullCurrentEpoch()
{
Controller c = new Controller();
IExternalDevice dev = new UnitConvertingExternalDevice(UNUSED_DEVICE_NAME, UNUSED_DEVICE_MANUFACTURER, c, UNUSED_BACKGROUND);
IList<IMeasurement> data = (IList<IMeasurement>) Enumerable.Range(0, 1000).Select(i => new Measurement(i, "V") as IMeasurement).ToList();
var sampleRate = new Measurement(1000, "Hz");
IOutputData data1 = new OutputData(data, sampleRate, false);
var e = new Epoch("");
e.Stimuli[dev] = new RenderedStimulus((string) "RenderedStimulus", (IDictionary<string, object>) new Dictionary<string, object>(),
data1);
e.Background[dev] = new Epoch.EpochBackground(new Measurement(0, "V"), sampleRate);
Assert.Null(c.PullOutputData(dev, TimeSpan.FromSeconds(1)));
}