ConnectionStateExtensionSetAdsState Method

Sends an AdsState/AdsStateCommand Request to an AdsServer and waits until the StateChange is done or fails.


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

Syntax

C#

public static ResultWriteControl SetAdsState(
    this IAdsConnection connection,
    AdsStateCommand requested,
    TimeSpan pollingRate,
    TimeSpan waitTimeout,
    bool noReinit,
    bool noWait
)

Parameters

connection  IAdsConnection

The connection.

requested  AdsStateCommand

The requested state / command.

pollingRate  TimeSpan

The polling rate.

waitTimeout  TimeSpan

The wait timeout.

noReinit  Boolean

Checks first for the actual state and decides to return immediatly if the device is already in the expected target state. This is a SystemService specific.

noWait  Boolean

if set to true this method doesn't wait for the requested state change but returns immediatly.

Return Value

ResultWriteControl
ResultWriteControl.

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).

Exceptions

Exception

Condition

ClientNotConnectedException

AdsException

Polling rate higher than connection timeout!

AdsException

Cannot set '{address}' to '{requested}'. This would leave the target system unavailable for ADS!

Remarks

The method waits until the state change (via polling) is done. The end state doesn't need to be the requested state.

Reference

ConnectionStateExtension Class TwinCAT.Ads.Extensions Namespace

Beckhoff Automation GmbH & Co. KG 2001-2026