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 ValueSymbolExtensionsThe ValueSymbolExtensions type exposes the following members.
Methods
|
|
Name |
Description |
|---|---|---|
|
|
Polls a series of symbols via a ISumRead command. The SumCommand will read all contained values with every trigger. | |
|
|
Polls a series of symbols via a ISumRead2S command. The SumCommand will read all contained values with every trigger in one roundtrip. | |
|
|
Poll symbol values on trigger signals. | |
|
|
Polls the symbol as value sequence of object values with a specified period time. | |
|
|
Polls symbol values on trigger signals. | |
|
|
Polls the symbol as value sequence of object values with a specified period time. | |
|
|
Poll symbol values as a value sequence on trigger signals (typed) | |
|
|
Polls the symbol as value sequence of object values with a specified period time (typed) | |
|
|
Poll symbol values on trigger signals (typed) | |
|
|
PollValuesT(IValueSymbol, IObservableUnit, FuncResultReadValueAccess2IValueSymbol, Object, T) |
Poll symbol values on trigger signals (typed) |
|
|
Polls the symbol as value sequence of object values with a specified period time (typed) | |
|
|
Poll symbol values as a sequence of annotated results (Value + ErrorCode) | |
|
|
Poll symbol values with communication return codes. | |
|
|
Polls a series of symbols via a ISumRead2S command. The SumCommand will read all contained values with every trigger in one roundtrip. | |
|
|
Polls a series of symbols via a ISumRead2S command. The SumCommand will read all contained values with every trigger. | |
|
|
Gets an observable sequence when the value of the IValueSymbol has changed. | |
|
|
Observable sequence of Values driven by ADS Notifications on the specified symbol. | |
|
|
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
- ValueSymbolExtensions.WhenValueChanged Method (IValueSymbol)
- ValueSymbolExtensions.WhenValueChanged Method (IAdsConnection, IEnumerable.ISymbol.)
- ValueSymbolExtensions.WriteValues Method (IValueSymbol, IObservable.Object.)
- ValueSymbolExtensions.WriteValues Method (IValueSymbol, IObservable.Object., Action.Exception.)
- ValueSymbolExtensions.WriteValues Method (IValueSymbol, IObservable.Object., CancellationToken)
- ValueSymbolExtensions.WriteValues Method (IValueSymbol, IObservable.Object., Action.Exception., CancellationToken)
- ValueSymbolExtensions.PollValues Method (ISumSymbolRead, IObservable.Unit.)
- ISumSymbolRead Interface
- ValueSymbolExtensions.PollValues Method (ISumSymbolRead, TimeSpan)
- ValueSymbolExtensions.PollValues Method (IValueSymbol, IObservable.Unit.)
- ValueSymbolExtensions.PollValues Method (IValueSymbol, TimeSpan)
- ValueSymbolExtensions.PollValues Method (IValueSymbol, IObservable.Unit., Boolean)
- ValueSymbolExtensions.PollValues Method (IValueSymbol, TimeSpan, Boolean)
- ValueSymbolExtensions.PollValues2 Method (IValueSymbol, IObservable.Unit.)
- ValueSymbolExtensions.PollValues2 Method (IValueSymbol, TimeSpan)
- ValueSymbolExtensions.PollValues Method (ISumRead, IObservable.Unit.)
- ValueSymbolExtensions.PollValues Method (ISumRead, TimeSpan)
- ISumRead2.S. Interface
- ValueSymbolExtensions.PollValues.T. Method (IValueSymbol, IObservable.Unit.)
- ValueSymbolExtensions.PollValues.T. Method (IValueSymbol, TimeSpan)
- ValueSymbolExtensions.PollValues.T. Method (IValueSymbol, IObservable.Unit., Boolean)
- ValueSymbolExtensions.PollValues.T. Method (IValueSymbol, IObservable.Unit., Func.ResultReadValueAccess2.IValueSymbol, Object., T.)
- ValueSymbolExtensions.PollValues.T. Method (IValueSymbol, TimeSpan, Boolean)
- ValueSymbolExtensions.PollValues2.S. Method (ISumRead2.S., IObservable.Unit.)
- ValueSymbolExtensions.PollValues2.S. Method (ISumRead2.S., TimeSpan)