ValueSymbolExtensions Class

Extension class for IAdsConnection to provide reactive ADS extensions for accessing symbols that are loaded by the IAdsSymbolLoaderFactory

Inheritance Hierarchy

SystemObject
  TwinCAT.Ads.ReactiveValueSymbolExtensions

Namespace: TwinCAT.Ads.Reactive
Assembly: TwinCAT.Ads.Reactive (in TwinCAT.Ads.Reactive.dll) Version: 7.0.0+e56d35ccc4675faac24789a4aab60071fc61d470

Syntax

C#

public static class ValueSymbolExtensions

The ValueSymbolExtensions type exposes the following members.

Methods

 

Name

Description

ValueSymbolExtensions Class 1:

PollValues(ISumRead, IObservableUnit)

Polls a series of symbols via a ISumRead command. The SumCommand will read all contained values with every trigger.

ValueSymbolExtensions Class 2:

PollValues(ISumRead, TimeSpan)

Polls a series of symbols via a ISumRead2S command. The SumCommand will read all contained values with every trigger in one roundtrip.

PollValues(IValueSymbol, IObservableUnit)

Poll symbol values on trigger signals.

ValueSymbolExtensions Class 3:

PollValues(IValueSymbol, TimeSpan)

Polls the symbol as value sequence of object values with a specified period time.

PollValues(IValueSymbol, IObservableUnit, Boolean)

Polls symbol values on trigger signals.

ValueSymbolExtensions Class 4:

PollValues(IValueSymbol, TimeSpan, Boolean)

Polls the symbol as value sequence of object values with a specified period time.

PollValuesT(IValueSymbol, IObservableUnit)

Poll symbol values as a value sequence on trigger signals (typed)

ValueSymbolExtensions Class 5:

PollValuesT(IValueSymbol, TimeSpan)

Polls the symbol as value sequence of object values with a specified period time (typed)

PollValuesT(IValueSymbol, IObservableUnit, Boolean)

Poll symbol values on trigger signals (typed)

ValueSymbolExtensions Class 6:

PollValuesT(IValueSymbol, IObservableUnit, FuncResultReadValueAccess2IValueSymbol, Object, T)

Poll symbol values on trigger signals (typed)

PollValuesT(IValueSymbol, TimeSpan, Boolean)

Polls the symbol as value sequence of object values with a specified period time (typed)

PollValues2(IValueSymbol, IObservableUnit)

Poll symbol values as a sequence of annotated results (Value + ErrorCode)

PollValues2(IValueSymbol, TimeSpan)

Poll symbol values with communication return codes.

ValueSymbolExtensions Class 7:

PollValues2S(ISumRead2S, IObservableUnit)

Polls a series of symbols via a ISumRead2S command. The SumCommand will read all contained values with every trigger in one roundtrip.

ValueSymbolExtensions Class 8:

PollValues2S(ISumRead2S, TimeSpan)

Polls a series of symbols via a ISumRead2S command. The SumCommand will read all contained values with every trigger.

ValueSymbolExtensions Class 9:

WhenValueChanged(IValueSymbol)

Gets an observable sequence when the value of the IValueSymbol has changed.

ValueSymbolExtensions Class 10:

WhenValueChanged(IAdsConnection, IEnumerableISymbol)

Observable sequence of Values driven by ADS Notifications on the specified symbol.

ValueSymbolExtensions Class 11:

WriteValues(IValueSymbol, IObservableObject)

Subscribes the IValueSymbol to an observable sequence of values and writes them to the IValueSymbol.

WriteValues(IValueSymbol, IObservableObject, ActionException)

Subscribes the IValueSymbol to an observable sequence of values and writes them to the IValueSymbol.

WriteValues(IValueSymbol, IObservableObject, CancellationToken)

Subscribes the IValueSymbol to an observable sequence of values and writes them to the IValueSymbol.

WriteValues(IValueSymbol, IObservableObject, ActionException, CancellationToken)

Subscribes the IValueSymbol to an observable sequence of values and writes them to the IValueSymbol.

Remarks

Reactive Extensions (Rx) are a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. Using Rx, developers represent asynchronous data streams with Observables, query asynchronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers. The ADS reactive extensions are build on top of this library to enable ADS Symbol and State Observables, seamlessly bound to the reactive extensions. To use the ADS reactive extensions the TwinCAT.Ads.Reactive Nuget package (or the included TwinCAT.Ads.Reactive.dll) must be referenced from All types within are contained in the ADS companion package "Beckhoff.TwinCAT.Ads.Reactive" which must be referenced separately. (Beckhoff.TwinCAT.Ads.Reactive package on Nuget).

Example

The following sample shows how to observe Value changed Notifications with the reactive ValueSymbolExtensions from an IValueSymbol.

Observe a single changing ADS Symbol (ADS Notifications)

// To Test the Observer run a project on the local PLC System (Port 851)
using (AdsClient client = new AdsClient())
{
    // Connect to target
    client.Connect(new AmsAddress(AmsNetId.Local, 851));

    // Create Symbol information
    var symbolLoader = SymbolLoaderFactory.Create(client, SymbolLoaderSettings.Default);
    IValueSymbol cycleCount = (IValueSymbol)symbolLoader.Symbols["TwinCAT_SystemInfoVarList._TaskInfo[1].CycleCount"];

    // Reactive Notification Handler
    var valueObserver = Observer.Create<object>(val =>
    {
    Console.WriteLine(string.Format("Instance: {0}, Value: {1}", cycleCount.InstancePath, val.ToString()));
    }
    );

    cycleCount.NotificationSettings = new NotificationSettings(AdsTransMode.OnChange, 500, 5000); // optional: Change NotificationSettings on Symbol

    // Turning ADS Notifications into sequences of Value Objects (Taking 20 Values)
    // and subscribe to them.
    IDisposable subscription = cycleCount.WhenValueChanged().Take(20).Subscribe(valueObserver);

    Console.ReadKey(); // Wait for Key press
    subscription.Dispose(); // Dispose the Subscription
}

Reference

TwinCAT.Ads.Reactive Namespace AdsClientExtensions AnyTypeExtensions

Beckhoff Automation GmbH & Co. KG 2001-2026