Class SampleValidOverSlidingWindow
- Namespace
- Acuit.Pinpoint.Workflows.Testing.Activities
- Assembly
- Acuit.Pinpoint.Workflows.Testing.dll
Samples a data source until it has been continuously valid over a sliding time window.
public class SampleValidOverSlidingWindow : Activity<IDataValue>, IActivity
- Inheritance
-
SampleValidOverSlidingWindow
- Implements
- Inherited Members
Examples
<TakeValue Name="Ignition Gas Flow">
<SampleValidOverSlidingWindow DataSource="{Reading GasFlowRate}" WindowDuration="0:00:11" Timeout="0:00:50">
<SampleValidOverTime.Validator>
<GreaterThanOrEqualToValidator Value="2" />
</SampleValidOverTime.Validator>
</SampleValidOverSlidingWindow>
</TakeValue>
Remarks
The activity result value will be the average value of the valid data source values over the time window of length WindowDuration.
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.
Properties
DataSource
Gets or sets the data source to sample.
public ValueSource<IDataSource> DataSource { get; set; }
Property Value
Timeout
Gets or sets an optional timeout duration. When set, it must be greater than WindowDuration. If a good data value is not obtained over the sliding window defined by WindowDuration before this timeout expires, then the returned data value will be the average value over the last WindowDuration, considered invalid, even if the average value is considered valid by the specified validator.
public ValueSource<TimeSpan?> Timeout { get; set; }
Property Value
Validator
Gets or sets the validator used to validate the data values. This is required. The validator is initialized once when the activity starts; arguments are not continuously evaluated while waiting.
public IDataValueValidator Validator { get; set; }
Property Value
WindowDuration
Gets or sets the window duration over which the data values must stay valid, which is required and must be greater than Zero.
public ValueSource<TimeSpan> WindowDuration { 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.