Table of Contents

Class ReaderOperation

Namespace
TechnologySolutions.Rfid
Assembly
TechnologySolutions.Rfid.Operations.dll

Base class for IReaderOperations

public class ReaderOperation : IReaderOperation, ITriggerSource
Inheritance
ReaderOperation
Implements
Derived
Inherited Members

Constructors

ReaderOperation(string, bool?)

Initializes a new instance of the ReaderOperation class

public ReaderOperation(string name, bool? hardwareTrigger)

Parameters

name string

A name to identify the operation

hardwareTrigger bool?

Specifies how this operation is triggered. (see remarks)

Remarks

TriggerDescription
nullno trigger
falsesoft trigger, commanded by host when reader reports trigger changes
truehardware trigger

Properties

Fault

Gets an uncaught error that caused the operation to disable unexpectedly

public Exception Fault { get; }

Property Value

Exception

Identifier

Gets a unique identifier for this operation

public string Identifier { get; }

Property Value

string

IsTriggerHardware

Gets a value indicating whether the operation is run on the reader (as opposed to commanded by the host in response to trigger changes)

public bool IsTriggerHardware { get; }

Property Value

bool

Name

Gets a human readable name for the operation

public string Name { get; protected set; }

Property Value

string

PreviousState

Gets the previous state of State

public ReaderOperationState PreviousState { get; }

Property Value

ReaderOperationState

Reader

Gets or sets the reader the operation has been added to

protected IReaderReaderOperation Reader { get; set; }

Property Value

IReaderReaderOperation

State

Gets the current state of the operation

public ReaderOperationState State { get; protected set; }

Property Value

ReaderOperationState

TriggerIndex

Gets or sets the trigger index. Can only be changed while the operation is Disabled

public int TriggerIndex { get; set; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

Only the primary/single (1) or secondary/double (2) trigger is permitted

InvalidOperationException

If the index is changed while the operation is enabled

TriggerInterval

Gets the interval between repeats of the operation (only valid for host commanded operations)

public TimeSpan TriggerInterval { get; set; }

Property Value

TimeSpan

Methods

Added(IReaderReaderOperation)

Called when the operation is added to a reader

public void Added(IReaderReaderOperation reader)

Parameters

reader IReaderReaderOperation

The reader the operation was added to

DisableAsync()

Disables the operation

public virtual Task DisableAsync()

Returns

Task

The task to disable the operation

Remarks

This provides the operation the opportunity to configure the reader to run the operation

DisabledDisconnectedAsync()

Returns a task that is run as the operation is disabled as just before the reader is disconnected

public virtual Task DisabledDisconnectedAsync()

Returns

Task

The task that is run as the task is disabled or the just before the reader is disconnected

Remarks

This provides the operation an opportunity to reset the reader as the operation is disabled

EnableAsync()

Enables the operation to be started (manually or by the specified trigger)

public Task EnableAsync()

Returns

Task

The task to enable the operation

EnabledConnectedAsync()

Returns a task that is run as the operation is enabled or the reader is connected

public virtual Task EnabledConnectedAsync()

Returns

Task

The task to run as the operation is enabled or the reader is connected

Faulted(Exception)

Sets Fault to ex

protected void Faulted(Exception ex)

Parameters

ex Exception

The trapped exception that caused the operation to stop

PerformOperationAsync(CancellationToken)

Performs the operations task by not returning until cancelToken is cancelled.

protected virtual Task PerformOperationAsync(CancellationToken cancelToken)

Parameters

cancelToken CancellationToken

A token that is cancelled when the operation should stop

Returns

Task

The task to perform the operation

RaiseStateChanged(ReaderOperationEventArgs)

Raises StateChanged

protected virtual void RaiseStateChanged(ReaderOperationEventArgs e)

Parameters

e ReaderOperationEventArgs

Removed()

Called when the operation is removed from a reader

public void Removed()

StartAsync()

Changes the operation state from Inactive to Active and then calls PerformOperationAsync(CancellationToken) once if TriggerInterval equals MaxValue or repeated after TriggerInterval delays until StopAsync() is called.

public Task StartAsync()

Returns

Task

Exceptions

InvalidOperationException

If the operation is started when not in the inactive state

StartSafe()

Starts the operation without waiting for completion. Any exception thrown is captured by Faulted(Exception)

public void StartSafe()

StopAsync()

Signals the operation started with StartAsync() to stop and changes the state from Active to Inactive

public virtual Task StopAsync()

Returns

Task

ToString()

Returns a string representation of this object

public override string ToString()

Returns

string

A string to identify the operation and its current state

Events

StateChanged

Raised when the State changes

public event EventHandler<ReaderOperationEventArgs> StateChanged

Event Type

EventHandler<ReaderOperationEventArgs>