本文整理汇总了C#中Controller.CancelEpoch方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.CancelEpoch方法的具体用法?C# Controller.CancelEpoch怎么用?C# Controller.CancelEpoch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller.CancelEpoch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunEpochShouldDiscardEpochWhenCancelEpochCalled
public void RunEpochShouldDiscardEpochWhenCancelEpochCalled()
{
Converters.Register("V", "V",
// just an identity conversion for now, to pass Validate()
(IMeasurement m) => m);
var c = new Controller { DAQController = new SimpleDAQController2() };
c.DAQController.Clock = c.DAQController as IClock;
var e = new Epoch(UNUSED_PROTOCOL);
var dev1 = new UnitConvertingExternalDevice("dev1", "co", c, new Measurement(0, "V"))
{
MeasurementConversionTarget = "V",
Clock = c.Clock
};
var sampleRate = new Measurement(1, "Hz");
e.Stimuli[dev1] = new DelegatedStimulus("ID1", "units", new Dictionary<string, object>(),
(parameters, duration) =>
new OutputData(new List<IMeasurement>(), sampleRate, false),
objects => Option<TimeSpan>.None());
bool epochDiscarded = false;
c.DiscardedEpoch += (sender, args) =>
{
epochDiscarded = true;
};
c.DAQController.ProcessIteration += (o, eventArgs) =>
{
Console.WriteLine("Process iteration");
c.CancelEpoch();
};
c.RunEpoch(e, new FakeEpochPersistor());
Assert.True(epochDiscarded);
}
示例2: SealLeak
public void SealLeak(
[Values(10000, 20000, 50000)] double sampleRate
)
{
Converters.Clear();
Converters.Register("V", "V",
// just an identity conversion for now, to pass Validate()
(IMeasurement m) => m);
HekaDAQInputStream.RegisterConverters();
HekaDAQOutputStream.RegisterConverters();
Assert.That(HekaDAQController.AvailableControllers().Count(), Is.GreaterThan(0));
foreach (var daq in HekaDAQController.AvailableControllers())
{
const double epochDuration = 10; //s
//Configure DAQ
daq.InitHardware();
try
{
daq.SampleRate = new Measurement((decimal)sampleRate, "Hz");
var controller = new Controller();
controller.Clock = daq;
controller.DAQController = daq;
const decimal expectedBackgroundVoltage = 3.2m;
var expectedBackground = new Measurement(expectedBackgroundVoltage, "V");
var dev0 = new UnitConvertingExternalDevice("Device0", "Manufacturer", controller, expectedBackground)
{
MeasurementConversionTarget = "V",
Clock = daq
};
dev0.BindStream(daq.GetStreams("ANALOG_OUT.0").First() as IDAQOutputStream);
dev0.BindStream(daq.GetStreams("ANALOG_IN.0").First() as IDAQInputStream);
controller.DiscardedEpoch += (c, args) => Console.WriteLine("Discarded epoch: " + args.Epoch);
// Setup Epoch
var e = new Epoch("HekaIntegration");
HekaDAQController cDAQ = daq;
var stim = new DelegatedStimulus("TEST_ID", "V", new Dictionary<string, object>(),
(parameters, duration) =>
DataForDuration(duration, cDAQ.SampleRate),
parameters => Option<TimeSpan>.None()
);
e.Stimuli[dev0] = stim;
e.Background[dev0] = new Epoch.EpochBackground(expectedBackground, daq.SampleRate);
//Run single epoch
var fakeEpochPersistor = new FakeEpochPersistor();
new TaskFactory().StartNew(() =>
{
Thread.Sleep(TimeSpan.FromSeconds(epochDuration));
controller.CancelEpoch();
},
TaskCreationOptions.LongRunning
);
controller.RunEpoch(e, fakeEpochPersistor);
}
finally
{
if (daq.HardwareReady)
daq.CloseHardware();
}
}
}