本文整理汇总了C#中Controller.NextEpoch方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.NextEpoch方法的具体用法?C# Controller.NextEpoch怎么用?C# Controller.NextEpoch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller.NextEpoch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputPipelineContinuity
public void OutputPipelineContinuity(
[Values(1000, 5000, 10000, 15000, 20000)] double sampleRate,
[Values(0.1, 0.5, 1, 5)] double blockDurationSeconds
)
{
const double epochDuration = 2; //seconds
var srate = new Measurement((decimal) sampleRate, "Hz");
var daq = new TestDAQController();
var outStream = new DAQOutputStream("OUT")
{
SampleRate = srate,
MeasurementConversionTarget = "V"
};
var controller = new Controller() { Clock = daq, DAQController = daq };
var dev = new UnitConvertingExternalDevice("dev", "co", controller, new Measurement(0, "V"))
{
Clock = daq,
MeasurementConversionTarget = "V"
};
dev.BindStream(outStream);
// Setup Epoch
var e = new Epoch("OutputPipelineContinuity");
var nSamples = (int)TimeSpan.FromSeconds(epochDuration).Samples(srate);
IList<IMeasurement> stimData = (IList<IMeasurement>) Enumerable.Range(0, nSamples)
.Select(i => new Measurement((decimal) (8 * Math.Sin(((double)i) / (nSamples / 10.0))), "V") as IMeasurement)
.ToList();
IOutputData stimOutputData = new OutputData(stimData, srate);
var stim = new RenderedStimulus((string) "RenderedStimulus", (IDictionary<string, object>) new Dictionary<string, object>(),
stimOutputData);
e.Stimuli[dev] = stim;
e.Responses[dev] = new Response();
e.Background[dev] = new Epoch.EpochBackground(new Measurement(0, "V"), srate);
controller.EnqueueEpoch(e);
controller.NextEpoch();
var blockSpan = TimeSpan.FromSeconds(blockDurationSeconds);
foreach (var stimBlock in stim.DataBlocks(blockSpan))
{
var cons = stimOutputData.SplitData(blockSpan);
var expected = cons.Head.Data;
stimOutputData = cons.Rest;
Assert.That(stimBlock.Data, Is.EqualTo(expected));
}
}
示例2: ShouldTruncateResponseAtEpochBoundary
public void ShouldTruncateResponseAtEpochBoundary()
{
var c = new Controller();
var e = new Epoch(UNUSED_PROTOCOL);
var dev1 = new UnitConvertingExternalDevice("dev2", "co", c, new Measurement(0, "V"));
var sampleRate = new Measurement(1, "Hz");
var samples = new List<IMeasurement> { new Measurement(1, "V"), new Measurement(2, "V"), new Measurement(3, "V") };
var data = new OutputData(samples,
sampleRate, true);
e.Stimuli[dev1] = new RenderedStimulus((string) "ID1",
(IDictionary<string, object>) new Dictionary<string, object>(),
(IOutputData) data);
e.Responses[dev1] = new Response();
c.EnqueueEpoch(e);
c.NextEpoch();
c.PushInputData(dev1, new InputData(samples.Concat(samples).ToList(),
sampleRate,
DateTimeOffset.Now)
.DataWithStreamConfiguration(streamFake, new Dictionary<string, object>())
.DataWithExternalDeviceConfiguration(devFake, new Dictionary<string, object>()));
Assert.That(((TimeSpan)e.Responses[dev1].Duration), Is.EqualTo((TimeSpan)e.Duration));
}
示例3: 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());
}
示例4: 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);
}
示例5: NextEpochThrowsIfCannotDequeue
public void NextEpochThrowsIfCannotDequeue()
{
var c = new Controller();
var e = new Epoch(UNUSED_PROTOCOL);
var dev1 = new UnitConvertingExternalDevice("dev2", "co", c, new Measurement(0, "V"));
var sampleRate = new Measurement(1, "Hz");
var samples = new List<IMeasurement> { new Measurement(1, "V"), new Measurement(2, "V"), new Measurement(3, "V") };
var data = new OutputData(samples,
sampleRate, true);
e.Stimuli[dev1] = new RenderedStimulus((string) "ID1",
(IDictionary<string, object>) new Dictionary<string, object>(),
(IOutputData) data);
e.Responses[dev1] = new Response();
c.EnqueueEpoch(e);
c.NextEpoch();
Assert.Throws<SymphonyControllerException>(() => c.NextEpoch());
}
示例6: NextEpochShouldFireNextEpochEvent
public void NextEpochShouldFireNextEpochEvent()
{
var c = new Controller();
c.Clock = new FakeClock();
var e = new Epoch(UNUSED_PROTOCOL);
var dev1 = new UnitConvertingExternalDevice("dev2", "co", c, new Measurement(0, "V"));
var sampleRate = new Measurement(1, "Hz");
var samples = new List<IMeasurement> { new Measurement(1, "V"), new Measurement(2, "V"), new Measurement(3, "V") };
var data = new OutputData(samples,
sampleRate, true);
e.Stimuli[dev1] = new RenderedStimulus((string) "ID1",
(IDictionary<string, object>) new Dictionary<string, object>(),
(IOutputData) data);
e.Responses[dev1] = new Response();
c.EnqueueEpoch(e);
bool evt = false;
c.NextEpochRequested += (sender, args) => evt = true;
c.NextEpoch();
Assert.True(evt);
}
示例7: NexEpochShouldDequeueEpoch
public void NexEpochShouldDequeueEpoch()
{
var c = new Controller();
var e = new Epoch(UNUSED_PROTOCOL);
var dev1 = new UnitConvertingExternalDevice("dev2", "co", c, new Measurement(0, "V"));
var sampleRate = new Measurement(1, "Hz");
var samples = new List<IMeasurement> { new Measurement(1, "V"), new Measurement(2, "V"), new Measurement(3, "V") };
var data = new OutputData(samples,
sampleRate, true);
e.Stimuli[dev1] = new RenderedStimulus((string) "ID1",
(IDictionary<string, object>) new Dictionary<string, object>(),
(IOutputData) data);
e.Responses[dev1] = new Response();
c.EnqueueEpoch(e);
Assert.That(c.CurrentEpoch, Is.Null);
c.NextEpoch();
Assert.That(c.CurrentEpoch, Is.EqualTo(e));
}