本文整理汇总了C#中System.TimeSpan.Samples方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.Samples方法的具体用法?C# TimeSpan.Samples怎么用?C# TimeSpan.Samples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.Samples方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PullOutputData
public override IOutputData PullOutputData(IDAQOutputStream stream, TimeSpan duration)
{
/*
* IOuputData will be directed to a device (not an DAQStream) by the controller.
* Controller should get mapping (device=>data) from the current Epoch instance.
*
* Thus the standard PullOuputData will pull from the controller's queue for this
* device.
*/
if (duration.Samples(stream.SampleRate) <= 1)
throw new ExternalDeviceException("Cannot pull less than one sample.");
try
{
IOutputData data = this.Controller.PullOutputData(this, duration);
return data.DataWithUnits(MeasurementConversionTarget)
.DataWithExternalDeviceConfiguration(this, Configuration);
}
catch (Exception ex)
{
log.DebugFormat("Error pulling data from controller: " + ex.Message);
throw;
}
}
示例2: DataForDuration
private static IOutputData DataForDuration(TimeSpan blockDuration, IMeasurement sampleRate)
{
ulong nSamples = blockDuration.Samples(sampleRate);
var samples = Enumerable.Range(0, (int)nSamples).Select(i => new Measurement(1, "V")).ToList();
return new OutputData(samples, sampleRate, false);
}
示例3: ConstantMeasurementList
private static IEnumerable<IMeasurement> ConstantMeasurementList(TimeSpan blockDuration, IMeasurement srate, IMeasurement value)
{
//log.DebugFormat("Generating constant measurment: {0} x {1} samles @ {2}", value, blockDuration.Samples(srate), srate);
return Enumerable.Range(0, (int)blockDuration.Samples(srate))
.Select(i => value)
.ToList();
}
示例4: PullsOutputData
public void PullsOutputData()
{
var dur1 = new TimeSpan(seqData.Duration.Ticks / 3);
var pull1 = seqStream.PullOutputData(dur1);
var dur2 = new TimeSpan(seqData.Duration.Ticks);
var pull2 = seqStream.PullOutputData(dur2);
var samples1 = (int)dur1.Samples(seqStream.SampleRate);
Assert.That(pull1.Data, Is.EqualTo(seqData.Data.Take(samples1).ToList()));
var samples2 = (int)dur2.Samples(seqStream.SampleRate);
Assert.That(pull2.Data, Is.EqualTo(seqData.Data.Skip(samples1).Take(samples2).ToList()));
}