ValueSymbolExtensions.PollValues2 Method (IValueSymbol, TimeSpan)

Poll symbol values with communication return codes.

Namespace:  TwinCAT.Ads.Reactive
Assembly:  TwinCAT.Ads.Reactive (in TwinCAT.Ads.Reactive.dll) Version: 6.0.328+39e3229

Syntax

C#

public static IObservable<ResultReadValueAccess2<IValueSymbol, Object?>> PollValues2(
    this IValueSymbol symbol,
    TimeSpan period
)

Parameters

symbol

Type: TwinCAT.TypeSystem.IValueSymbol
The symbol to poll.

period

Type: System.TimeSpan
The polling interval.

Return Value

Type: IObservable.ResultReadValueAccess2.IValueSymbol, Object..
IObservable<ResultReadValueAccess>.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IValueSymbol. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This reactive method polls the symbol version together with additional information. The distinct result data is ResultReadValueAccess which contains the value (if succeeded) together with the communication return code. If the ErrorCode is > 0, then the Value property will return the default value. This has the advantage, that the Observable doesn't produces Errors when communication requests return Errors and the Observer can continue. Internally for optimization reasons because it is expected that the polling occurs many times, this reactive method creates the symbol handle before the first polling trigger (one roundtrip), reads the value with each trigger and unregisters the handle on finalize. So the number of communication roundtrips is Trigggers + 2.

Reference

ValueSymbolExtensions Class

PollValues2 Overload

TwinCAT.Ads.Reactive Namespace

ValueSymbolExtensions.PollValues(IValueSymbol, TimeSpan)