Table of Contents

Class MonitorData

Namespace
Acuit.Pinpoint.Workflows.Testing.Activities
Assembly
Acuit.Pinpoint.Workflows.Testing.dll

Continuously monitors a data source, failing the test upon any invalid data value.

public class MonitorData : Activity, IActivity
Inheritance
MonitorData
Implements
Inherited Members

Examples

<WhenAny>
  <MonitorData DataSource="{Reading L1Current}" FailReason="ID fan overcurrent fault">
    <MonitorData.Validator>
      <LessThanOrEqualToValidator Value="8" />
    </MonitorData.Validator>
  </MonitorData>
  <Sequence>
    <!-- Perform the regular test sequence here... -->
  </Sequence>
</WhenAny>

Remarks

If the data source completes (i.e., all data is read) without any invalid values, then the activity will end without failing the test. Otherwise, it will continuously monitor the data source until an invalid value occurs or until the activity is canceled.

Typically, instances of MonitorData should be placed in parallel to each other and to the main workflow sequence under a WhenAny activity so that they will automatically be canceled when the main workflow sequence completes.

Properties

DataSource

Gets or sets the data source to sample.

public ValueSource<IDataSource> DataSource { get; set; }

Property Value

ValueSource<IDataSource>

FailReason

Gets or sets an optional reason to use for failed tests when an invalid data value occurs.

public ValueSource<string> FailReason { get; set; }

Property Value

ValueSource<string>

Remarks

If specified, the value will be interpreted as a format string that can contain a single format item (i.e., "{0}") for the validated data value. For example, "Pressure safety fault: {0}" could yield a failed test reason like: "Pressure safety fault: 505 psi (<= 500)").

If this is not specified, the default value will be "{Data Source Name} invalid: {0}", where "{Data Source Name}" will be the name of the data source (e.g., the reading display name). This will yield test failure reasons like "Suction Pressure 1 invalid: 505 psi (<= 500)" or "Data invalid: 505 psi (<= 500)".

This is not evaluated until the validation fails and the test about to be failed.

Validator

Gets or sets the validator used to validate the data value. This is required. If the data value ever fails this validation, the test will fail. Take special note that this specifies how values are validated as good; the value must fail this validation to cause a failed test.

public IDataValueValidator Validator { get; set; }

Property Value

IDataValueValidator

Methods

OnExecuteAsync(ActivityContext, CancellationToken)

Derived classes must implement this to perform the activity.

protected override Task OnExecuteAsync(ActivityContext context, CancellationToken cancellationToken)

Parameters

context ActivityContext

The activity context.

cancellationToken CancellationToken

The cancellation token used to request canceling the activity.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

context is null.

InvalidOperationException

A service required by the activity is not available, or a required activity property value is not set. This will only occur asynchronously, wrapped in an AggregateException as the faulted task's Exception.

Exception

An error occurred while performing the activity. This will only occur asynchronously, wrapped in an AggregateException as the faulted task's Exception.

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.