本文整理汇总了C#中IDataService.GetSamples方法的典型用法代码示例。如果您正苦于以下问题:C# IDataService.GetSamples方法的具体用法?C# IDataService.GetSamples怎么用?C# IDataService.GetSamples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataService
的用法示例。
在下文中一共展示了IDataService.GetSamples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainViewModel
public MainViewModel(IDataService dataService)
{
_dataService = dataService;
_dataService.GetSamples().GroupBy(sample => new { sample.SensorId, sample.UnitOfMeasure }).ObserveOnDispatcher().Subscribe(grp =>
{
var sampleGroup = new SampleGroup
{
SensorId = grp.Key.SensorId,
UnitOfMeasure = grp.Key.UnitOfMeasure,
Samples = new ObservableCollection<double>()
};
SampleGroups.Add(sampleGroup);
grp.Buffer(5).Subscribe(window => sampleGroup.AverageMeasurement = window.Average(avg => avg.SensorValue));
/*grp.Scan(new { sum = .0, count = 0 }, (agg, sample) => new { sum = agg.sum + sample.SensorValue, count = agg.count + 1 })
.Select(agg => agg.sum / agg.count).ObserveOnDispatcher().Subscribe(average => sampleGroup.AverageMeasurement = average);*/
grp.Sample(TimeSpan.FromSeconds(1)).ObserveOnDispatcher().Select(sample => sample.SensorValue).Subscribe(sampleGroup.Samples.Add);
});
_dataService
.GetSamples()
.Where(sample => sample.SampleType == SensorSample.SampleTypes.Temperature && sample.SensorValue < -25)
.ObserveOnDispatcher().Subscribe(sample => Warnings.Add(string.Format("Warning: Sensor {0} registerede temperature of {1:0.00}", sample.SensorId, sample.SensorValue)));
}