AnyTypeExtensions.WriteValues.T. Method (IAdsConnection, String, IObservable.T.)
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: 6.0.328+39e3229
Syntax
C#
public static IDisposable WriteValues<T>(
this IAdsConnection connection,
string instancePath,
IObservable<T> valueSequence
)
Parameters
connection |
Type: TwinCAT.Ads.IAdsConnection |
instancePath |
Type: System.String |
valueSequence |
Type: System.IObservable.T. |
Type Parameters
T |
Return Value
Type: 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).
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
}