AnyTypeExtensionsWriteValuesT(IAdsConnection, String, IObservableT) Method

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


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

Syntax

C#

public static IDisposable WriteValues<T>(
    this IAdsConnection connection,
    string instancePath,
    IObservable<T> valueSequence
)

Parameters

connection  IAdsConnection

The connection.

instancePath  String

The instance path.

valueSequence  IObservableT

Value sequence (Any type).

Type Parameters

T

Return Value

IDisposable
IDisposable.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IAdsConnection. 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).

Example

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

AnyTypeExtensions Class WriteValues Overload TwinCAT.Ads.Reactive Namespace

Beckhoff Automation GmbH & Co. KG 2001-2026