AnyTypeExtensionsWhenNotification(IAdsConnection, String, Type, NotificationSettings) Method
Creates an observable sequence of values that are created by ADS Notifications.
Namespace: TwinCAT.Ads.Reactive
Assembly: TwinCAT.Ads.Reactive (in
TwinCAT.Ads.Reactive.dll) Version:
7.0.0+e56d35ccc4675faac24789a4aab60071fc61d470
Syntax
C#
public static IObservable<Object> WhenNotification(
this IAdsConnection connection,
string instancePath,
Type type,
NotificationSettings settings
)Parameters
|
connection IAdsConnection |
The connection. |
|
instancePath String |
The instance path. |
|
type Type |
The type. |
|
settings NotificationSettings |
The settings. |
Return Value
IObservable
Object
IObservable<T>.
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).
Remarks
The values will be cast to the specified type. The .NET type must fit be one of the compatible 'ANYTYPES'.
Example
The following sample shows how to observe Value changed Notifications with the reactive AnyTypeExtensions
Observe changing ADS Symbols with reactive extensions (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
}Reference
AnyTypeExtensions Class WhenNotification Overload TwinCAT.Ads.Reactive Namespace
Beckhoff Automation GmbH & Co. KG 2001-2026