Class SampleAverageOverTime
- Namespace
- Acuit.Pinpoint.Workflows.Testing.Activities
- Assembly
- Acuit.Pinpoint.Workflows.Testing.dll
Samples the average value of a data source over a time duration.
public class SampleAverageOverTime : Activity<IDataValue>, IActivity
- Inheritance
-
SampleAverageOverTime
- Implements
- Inherited Members
Examples
<TakeValue Name="High Speed Inducer Current" DataItemName="HighSpeedInducerCurrent">
<SampleAverageOverTime DataSource="{Reading L1Current}" Duration="0:00:06">
<SampleAverageOverTime.Validator>
<TargetToleranceValidator Target="3" Tolerance="20%" />
</SampleAverageOverTime.Validator>
</SampleAverageOverTime>
</TakeValue>
Remarks
The average is not a simple average of the data source values; it weights each value based on the time stamps. The average is calculated as the integration of the data source values over the time window divided by the time window duration.
The activity result value will be the resulting value.
Properties
DataSource
Gets or sets the data source to sample.
public ValueSource<IDataSource> DataSource { get; set; }
Property Value
Duration
Gets or sets the duration over which the data values will be averaged, which is required and must be greater than Zero.
public ValueSource<TimeSpan> Duration { get; set; }
Property Value
Validator
Gets or sets the optional validator used to validate the data value. The validator is initialized (i.e., arguments are evaluated) at the end of the Duration time.
public IDataValueValidator Validator { get; set; }
Property Value
Methods
OnExecuteAsync(ActivityContext, CancellationToken)
Derived classes must implement this to perform the activity.
protected override Task<IDataValue> OnExecuteAsync(ActivityContext context, CancellationToken cancellationToken)
Parameters
context
ActivityContextThe activity context.
cancellationToken
CancellationTokenThe cancellation token used to request canceling the activity.
Returns
- Task<IDataValue>
A task that represents the asynchronous operation. The value of its Result property contains the result.
Exceptions
- ArgumentNullException
context
is null.- InvalidOperationException
A service required by the activity is not available, or a required activity property value is not set.
- Exception
An error occurred while performing the activity.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Remarks
This is expected to produce a string suitable for labeling this activity in a workflow diagram. It should be as specific as possible, but while keeping it very short. In general, it should be the short name of the class (as that is how it would typically be defined in the workflow XAML), optionally followed by other property values of interest in a diagram. The default implementation returns the short name of the class.