本文整理汇总了C#中IMeasurement.TimestampQualityIsGood方法的典型用法代码示例。如果您正苦于以下问题:C# IMeasurement.TimestampQualityIsGood方法的具体用法?C# IMeasurement.TimestampQualityIsGood怎么用?C# IMeasurement.TimestampQualityIsGood使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMeasurement
的用法示例。
在下文中一共展示了IMeasurement.TimestampQualityIsGood方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeriveMeasurementValue
//.........这里部分代码省略.........
case DownsamplingMethod.Filtered:
// Get tracked measurement values
if (m_measurements.TryGetValue(measurement.Key, out values))
{
if ((object)values != null && values.Count > 0)
{
// Get first tracked value - we clone the measurement since we are updating its value
derivedMeasurement = Measurement.Clone(values[0]);
if ((object)derivedMeasurement != null)
{
// Get function defined for measurement value filtering
MeasurementValueFilterFunction measurementValueFilter = derivedMeasurement.MeasurementValueFilter;
// Default to average value filter if none is specified
if (measurementValueFilter == null)
measurementValueFilter = Measurement.AverageValueFilter;
// Add new measurement to tracking collection
if ((object)measurement != null)
values.Add(measurement);
// Perform filter calculation as specified by device measurement
if (values.Count > 1)
{
derivedMeasurement.Value = measurementValueFilter(values);
// Keep track of total number of derived measurements
m_derivedMeasurements++;
return derivedMeasurement;
}
// No change from existing measurement
return null;
}
}
}
// No prior measurement exists, track this initial one
values = new List<IMeasurement> { measurement };
m_measurements[measurement.Key] = values;
// Keep track of total number of derived measurements
m_derivedMeasurements++;
return measurement;
case DownsamplingMethod.BestQuality:
// Get tracked measurement values
if (m_measurements.TryGetValue(measurement.Key, out values))
{
if ((object)values != null && values.Count > 0)
{
// Get first tracked value (should only be one for "BestQuality")
derivedMeasurement = values[0];
if ((object)derivedMeasurement != null)
{
// Determine if new measurement's quality is better than existing one or if new measurement's timestamp is closer to frame
if
(
(
(!derivedMeasurement.ValueQualityIsGood() || !derivedMeasurement.TimestampQualityIsGood())
&&
(measurement.ValueQualityIsGood() || measurement.TimestampQualityIsGood())
)
||
(
measurement.Timestamp < derivedMeasurement.Timestamp && measurement.Timestamp >= m_timestamp
)
)
{
// This measurement has a better quality or came in out-of-order and is closer to frame timestamp, so
// we sort this measurement instead of the original
values[0] = measurement;
// Keep track of total number of derived measurements
m_derivedMeasurements++;
return measurement;
}
// Prior measurement is closer to frame than new one
return null;
}
}
}
// No prior measurement exists, track this initial one
values = new List<IMeasurement> { measurement };
m_measurements[measurement.Key] = values;
// Keep track of total number of derived measurements
m_derivedMeasurements++;
return measurement;
}
return null;
}