SumReleaseHandles Class

Release Handles SumCommand (internal)

Inheritance Hierarchy

SystemObject
  SumCommandBase
    TwinCAT.Ads.SumCommandSumReleaseHandles

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

Syntax

C#

public class SumReleaseHandles : SumCommandBase

The SumReleaseHandles type exposes the following members.

Constructors

 

Name

Description

SumReleaseHandles Class 1:

SumReleaseHandles(IAdsConnection, UInt32)

Initializes a new instance of the SumReleaseHandles class.

SumReleaseHandles Class 2:

SumReleaseHandles(IAdsConnection, UInt32, SumFallbackMode)

Initializes a new instance of the SumReleaseHandles class.

SumReleaseHandles Class 3:

SumReleaseHandles(IAdsConnection, UInt32, SumCommandErrorStrategy, SumFallbackMode)

Initializes a new instance of the SumReleaseHandles class.

Methods

 

Name

Description

SumReleaseHandles Class 4:

Equals

Determines whether the specified object is equal to the current object.
(Inherited from Object)

SumReleaseHandles Class 5:

Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)

SumReleaseHandles Class 6:

GetHashCode

Serves as the default hash function.
(Inherited from Object)

SumReleaseHandles Class 7:

GetType

Gets the Type of the current instance.
(Inherited from Object)

SumReleaseHandles Class 8:

MemberwiseClone

Creates a shallow copy of the current Object.
(Inherited from Object)

SumReleaseHandles Class 9:

ReleaseHandles

Releases the handles.

SumReleaseHandles Class 10:

ReleaseHandlesAsync

Releases the handles asynchronously.

SumReleaseHandles Class 11:

ToString

Returns a string that represents the current object.
(Inherited from Object)

Remarks

Releases the specified ADS handles. Usually used in conjunction with the SumCreateHandles and the SumHandleReadAnyType / SumHandleWriteAnyType commands. This is not removing the handles from the IHandleCache of the AdsClient.

Example

Usage of Sum commands with handles (CreateHandles, Read, Write, ReleaseHandles)

/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
static async void Main(string[] args)
{
    Console.WriteLine("");
    Console.WriteLine("Press [Enter] for start:");
    Console.ReadLine();

    // Parse the command-line arguments
    AmsAddress address = ArgParser.Parse(args);

    CancellationTokenSource cancelSource = new CancellationTokenSource();
    CancellationToken cancel = cancelSource.Token;

    using (AdsClient client = new AdsClient())
    {
    // Connect the AdsClient to the device target.
    client.Connect(address);

    string[] instancePathList = {
        "GVL.bVar",
        "GVL.iCount",
        "TwinCAT_SystemInfoVarList._AppInfo.ProjectName"
    };
    SumCreateHandles createHandlesCommand = new SumCreateHandles(client,instancePathList);

    var resultCreateHandles = await createHandlesCommand.CreateHandlesAsync(cancel);

    if (resultCreateHandles.Succeeded)
    {
        uint[] handles = resultCreateHandles.Handles;
        Type[] valueTypes = new Type[]
        {
        typeof(bool),
        typeof(short),
        typeof(string)
        };
        SumHandleReadAnyType readCommand = new SumHandleReadAnyType(client, handles, valueTypes, SumFallbackMode.All);
        var resultRead = await readCommand.ReadAsync(cancel);

        if (resultRead.Succeeded)
        {
        object[] readValues = resultRead.Values;

        for (int i = 0; i < instancePathList.Length; i++)
        {
            Console.WriteLine("Symbol: {0} (Value: {1}, Type: {2})", instancePathList[i], readValues[i].ToString(), valueTypes[i].Name);
        }

        // Sum Command Write
        SumHandleWriteAnyType writeCommand = new SumHandleWriteAnyType(client, handles, valueTypes);
        object[] writeValues = new object[] { true, (short)42, "MyNewProjectName" };

        await writeCommand.WriteAsync(writeValues,cancel);
        }

        SumReleaseHandles releaseCommand = new SumReleaseHandles(client, handles);
        await releaseCommand.ReleaseHandlesAsync(cancel);
    }
    }

    Console.WriteLine("");
    Console.WriteLine("Press [Enter] for leave:");
    Console.ReadLine();
}

Reference

TwinCAT.Ads.SumCommand Namespace ISumCommand SumCreateHandles SumHandleReadAnyType SumHandleWriteAnyType

Beckhoff Automation GmbH & Co. KG 2001-2026