AnyTypeExtensions Class

Extension class for IAdsConnection to provide reactive ADS extensions (accessing symbol value sequences with the ANY_TYPE concept)

Inheritance Hierarchy

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

Syntax

C#

public static class AnyTypeExtensions

Methods

 

Name

Description

AnyTypeExtensions Class 1:

AnyTypeExtensions Class 2:

PollValues(IAdsConnection, String, Type, IObservable.Unit.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 3:

AnyTypeExtensions Class 4:

PollValues(IAdsConnection, String, Type, TimeSpan)

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

AnyTypeExtensions Class 5:

AnyTypeExtensions Class 6:

PollValues(IAdsConnection, ISymbol, Type, IObservable.Unit.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 7:

AnyTypeExtensions Class 8:

PollValues(IAdsConnection, ISymbol, Type, TimeSpan)

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

AnyTypeExtensions Class 9:

AnyTypeExtensions Class 10:

PollValues(IAdsConnection, String, Type, .Int32., TimeSpan)

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

AnyTypeExtensions Class 11:

AnyTypeExtensions Class 12:

PollValues(IAdsConnection, String, Type, IObservable.Unit., Func.Exception, Object.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 13:

AnyTypeExtensions Class 14:

PollValues(IAdsConnection, String, Type, TimeSpan, Func.Exception, Object.)

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

AnyTypeExtensions Class 15:

AnyTypeExtensions Class 16:

PollValues(IAdsConnection, ISymbol, Type, .Int32., TimeSpan)

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

AnyTypeExtensions Class 17:

AnyTypeExtensions Class 18:

PollValues(IAdsConnection, ISymbol, Type, IObservable.Unit., Func.Exception, Object.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 19:

AnyTypeExtensions Class 20:

PollValues(IAdsConnection, ISymbol, Type, TimeSpan, Func.Exception, Object.)

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

AnyTypeExtensions Class 21:

AnyTypeExtensions Class 22:

PollValues(IAdsConnection, String, Type, .Int32., IObservable.Unit., Func.Exception, Object.)

Polls the symbol values on time points where the polling observable streams data / triggers

AnyTypeExtensions Class 23:

AnyTypeExtensions Class 24:

PollValues(IAdsConnection, String, Type, .Int32., TimeSpan, Func.Exception, Object.)

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

AnyTypeExtensions Class 25:

AnyTypeExtensions Class 26:

PollValues(IAdsConnection, ISymbol, Type, .Int32., IObservable.Unit., Func.Exception, Object.)

Polls the symbol values on time points where the polling observable streams data / triggers

AnyTypeExtensions Class 27:

AnyTypeExtensions Class 28:

PollValues(IAdsConnection, ISymbol, Type, .Int32., TimeSpan, Func.Exception, Object.)

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

AnyTypeExtensions Class 29:

AnyTypeExtensions Class 30:

PollValues.T.(IAdsConnection, String, IObservable.Unit.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 31:

AnyTypeExtensions Class 32:

PollValues.T.(IAdsConnection, String, TimeSpan)

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

AnyTypeExtensions Class 33:

AnyTypeExtensions Class 34:

PollValues.T.(IAdsConnection, ISymbol, IObservable.Unit.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 35:

AnyTypeExtensions Class 36:

PollValues.T.(IAdsConnection, ISymbol, TimeSpan)

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

AnyTypeExtensions Class 37:

AnyTypeExtensions Class 38:

PollValues.T.(IAdsConnection, String, .Int32., IObservable.Unit.)

Polls the symbol values on time points where the polling observable streams data / triggers

AnyTypeExtensions Class 39:

AnyTypeExtensions Class 40:

AnyTypeExtensions Class 41:

PollValues.T.(IAdsConnection, String, .Int32., TimeSpan)

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

AnyTypeExtensions Class 42:

AnyTypeExtensions Class 43:

PollValues.T.(IAdsConnection, String, IObservable.Unit., Func.Exception, T.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 44:

AnyTypeExtensions Class 45:

PollValues.T.(IAdsConnection, String, TimeSpan, Func.Exception, T.)

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

AnyTypeExtensions Class 46:

AnyTypeExtensions Class 47:

PollValues.T.(IAdsConnection, ISymbol, .Int32., IObservable.Unit.)

Polls the symbol values on time points where the polling observable streams data / triggers

AnyTypeExtensions Class 48:

AnyTypeExtensions Class 49:

AnyTypeExtensions Class 50:

PollValues.T.(IAdsConnection, ISymbol, .Int32., TimeSpan)

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

AnyTypeExtensions Class 51:

AnyTypeExtensions Class 52:

PollValues.T.(IAdsConnection, ISymbol, IObservable.Unit., Func.Exception, T.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 53:

AnyTypeExtensions Class 54:

PollValues.T.(IAdsConnection, ISymbol, TimeSpan, Func.Exception, T.)

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

AnyTypeExtensions Class 55:

AnyTypeExtensions Class 56:

PollValues.T.(IAdsConnection, String, .Int32., IObservable.Unit., Func.Exception, T.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 57:

AnyTypeExtensions Class 58:

AnyTypeExtensions Class 59:

PollValues.T.(IAdsConnection, String, .Int32., TimeSpan, Func.Exception, T.)

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

AnyTypeExtensions Class 60:

AnyTypeExtensions Class 61:

PollValues.T.(IAdsConnection, ISymbol, .Int32., IObservable.Unit., Func.Exception, T.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 62:

AnyTypeExtensions Class 63:

AnyTypeExtensions Class 64:

PollValues.T.(IAdsConnection, ISymbol, .Int32., TimeSpan, Func.Exception, T.)

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

AnyTypeExtensions Class 65:

AnyTypeExtensions Class 66:

PollValues2.T.(IAdsConnection, String, .Int32., IObservable.Unit.)

Polls the symbol values on time points where the polling observable streams data / triggers

AnyTypeExtensions Class 67:

AnyTypeExtensions Class 68:

PollValues2.T.(IAdsConnection, ISymbol, .Int32., IObservable.Unit.)

Polls the symbol values on timepoints where the polling observable streams data / triggers

AnyTypeExtensions Class 69:

AnyTypeExtensions Class 70:

AnyTypeExtensions Class 71:

WhenNotification(IAdsConnection, String, Type, NotificationSettings)

Creates an observable sequence of values that are created by ADS Notifications.

AnyTypeExtensions Class 72:

AnyTypeExtensions Class 73:

AnyTypeExtensions Class 74:

WhenNotification.T.(IAdsConnection, String, NotificationSettings)

Creates an observable sequence of values that are created by ADS Notifications.

AnyTypeExtensions Class 75:

AnyTypeExtensions Class 76:

AnyTypeExtensions Class 77:

WriteValues.T.(IAdsConnection, String, IObservable.T.)

Writes the sequence of values to the symbol specified by the instance path.

AnyTypeExtensions Class 78:

AnyTypeExtensions Class 79:

AnyTypeExtensions Class 80:

WriteValues.T.(IAdsConnection, String, IObservable.T., Action.Exception.)

Writes the sequence of values to the symbol specified by the instance path.

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. (Beckhoff.TwinCAT.Ads.Reactive package on Nuget).

Examples

Example1: Observe Value changed Notifications with the reactive AnyTypeExtensions

Observe a single changing ADS Symbols (Extended AdsNotifications, ANY_TYPE)

// 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));

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

    // Turning ADS Notifications into sequences of Value Objects (Taking 20 Values)
    // and subscribe to them.
    IDisposable subscription = client.WhenNotification<ushort>("TwinCAT_SystemInfoVarList._TaskInfo.CycleCount", NotificationSettings.Default).Take(20).Subscribe(valueObserver);

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

Examples

Example2: Polling ANY_TYPE values.

Observe changing ADS Symbols by polling (Read Polling) (ANY_TYPE)

// 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.CycleCount"];

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

    // Take 20 Values in an Interval of 500ms
    IDisposable subscription = cycleCount.PollValues(TimeSpan.FromMilliseconds(500)).Take(20).Subscribe(valueObserver);

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

Examples

Write values sequentially.

Write sequences of values to the target (ANY_TYPE)

using (AdsClient client = new AdsClient())
{
    // Connect to target
    client.Connect(new AmsAddress(AmsNetId.Local, 851));

    // Create Symbol information (Symbol 'i : INT' in PLC Global Variables list.
    var symbolLoader = SymbolLoaderFactory.Create(client, SymbolLoaderSettings.Default);
    IValueSymbol gvlIntSymbol = (IValueSymbol)symbolLoader.Symbols["GVL.i"];

    // Produces object (short) Values 0,1,2,3 ... in seconds period
    IObservable<object> timerObservable = Observable.Interval(TimeSpan.FromSeconds(1.0)).Select(i => (object)(short)i);

    // Take 10 Values (0..9) and write them to GVL.i
    IDisposable dispose = gvlIntSymbol.WriteValues(timerObservable.Take(10));

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

Reference

TwinCAT.Ads.Reactive Namespace

TwinCAT.Ads.Reactive.AdsClientExtensions

TwinCAT.Ads.Reactive.ValueSymbolExtensions