Beckhoff.TwinCAT.Ads 5.0.0-preview1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
This is a prerelease version of Beckhoff.TwinCAT.Ads.
There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Beckhoff.TwinCAT.Ads --version 5.0.0-preview1
NuGet\Install-Package Beckhoff.TwinCAT.Ads -Version 5.0.0-preview1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Beckhoff.TwinCAT.Ads" Version="5.0.0-preview1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Beckhoff.TwinCAT.Ads --version 5.0.0-preview1
#r "nuget: Beckhoff.TwinCAT.Ads, 5.0.0-preview1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Beckhoff.TwinCAT.Ads as a Cake Addin
#addin nuget:?package=Beckhoff.TwinCAT.Ads&version=5.0.0-preview1&prerelease

// Install Beckhoff.TwinCAT.Ads as a Cake Tool
#tool nuget:?package=Beckhoff.TwinCAT.Ads&version=5.0.0-preview1&prerelease

Description

The package 'Beckhoff.TwinCAT.Ads' contains a client implementation for the ADS Communication protocol used by .NET Core and .NET Full Framework.

It includes everything to develop own .NET applications (e.g. visualization, scientific automation) to communicate with TwinCAT devices (e.g. PLC, NC or IO-devices).

The Root object is the TwinCAT.Ads.AdsClient to communicate to all variants of local and remote ADS servers and devices or the AdsSession object.

Requirements

  • .NET Core 3.0, .NET Framework 4.8 or .NET Standard 2.0 compatible SDK (included in VS2019 16.3)
  • Latest TwinCAT 3.1.4024 Build
  • or alternatively for systems where a TwinCAT installation is not running the Nuget package 'Beckhoff.TwinCAT.Ads.AdsRouterConsole'. to route ADS communication.
  • Installed Nuget package manager (for systems without Visual Studio installation)

Installation

System with TwinCAT System Service (TCP Loopback enabled)

Running TwinCAT 3.1.4024 Installation
Enable TCP Loopback vor TwinCAT 3.1.4024 via regkey:   
	
	32-Bit:
	HKEY_LOCAL_MACHINE\SOFTWARE\Beckhoff\TwinCAT3\System\EnableAmsTcpLoopbackDWORD (1)

	64-Bit:
	HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Beckhoff\TwinCAT3\System\EnableAmsTcpLoopback	DWORD(1)

System without TwinCAT System Service

Install the 'Beckhoff.TwinCAT.Ads.AdsRouterConsole' package from Nuget.org:
PS> nuget install Beckhoff.TwinCAT.Ads.AdsRouterConsole

To enable ADS Communication via the AdsRouteConsole, the following settings have to be made:

  • Select the Local AmsNetId and the Route Name of the System in the local "StaticRoutes.xml"
  • Add Remote Connections to the local StaticRoutes
  • Add the "Backroute" from the Remote system linking to the our system (via AmsNETId) running the AdsRouteConsole. This can be done via SystemManager or SystemService System Tray.

An example of the local "StaticRoutes.xml" is given here:

<?xml version="1.0" encoding="utf-8"?>
<TcConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\TwinCAT3\Config\TcConfig.xsd">
  <Local>
      <Name>MyLocalSystem</Name>
      <NetId>192.168.1.22.1.1</NetId>
  </Local>
  <RemoteConnections>
    <Route>
      <Name>MyRemoteSystem</Name>
      <Address>RemoteSytem</Address> 
       
      <NetId>192.168.1.21.1.1</NetId>
      <Type>TCP_IP</Type>
    </Route>
  </RemoteConnections>
</TcConfig>

First Steps

The following code instantiates an AdsClient object, connects to a target device (here the local System Service) and reads the ADS state asynchronously.

using System;
using System.Threading.Tasks;
using System.Threading;
using TwinCAT.Ads;

namespace AdsAsyncTest
{
    class Program
    {
        static async Task Main(string[] args)
        {
            AdsClient myClient = new AdsClient();
            try
            {
                // Connect to local TwinCAT System Service
                myClient.Connect(AmsNetId.Local, 10000);
                ResultReadDeviceState result = await myClient.ReadStateAsync(CancellationToken.None);
                Console.WriteLine("State: " + result.State.AdsState);
                Console.WriteLine("Press key to exit...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
            finally
            {
                myClient.Dispose();
            }
        }
    }
}

Please be aware, that the AdsRouteConsole doesn't support the Port 10000. Therefore the AmsNetId of the connection must be changed to a registered remote system.

Hints

There are a few breaking changes in the new version to enable asynchronous programming, reducing the memory footprint and enhancement of the performance. Nevertheless the usage the TwinCAT.Ads.AdsClient is very similar to the documented 4.3.0 Version of the class TwinCAT.Ads.TcAdsClient.

The Link to the Version 4.3.0 API documentation is:

https://infosys.beckhoff.com/content/1031/tcadsnetref/6358291723.html?id=8100459743587155746

Please use this documentation as long as the 'official' Version for ADS 5.0.0 is not released.

The main issues you will have with 'legacy' code:

  • Renaming the TcAdsClient class to AdsClient
  • Changing synchronous code to 'async'. The new asynchronous methods are indicated with “MethodNameAsync” and could be used very similar to their synchronous counterparts.
  • For using .NET Core more efficiently, all the AdsStream class appearances in method interfaces are replaced by the new more efficient Span<byte> and Memory[byte] classes.
  • AdsBinaryReader and AdsBinaryWriter should be replaced by using the standard BinaryReader and/or System.Buffers.Binary.BinaryPrimitives Methods.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (19)

Showing the top 5 NuGet packages that depend on Beckhoff.TwinCAT.Ads:

Package Downloads
TwinCAT.JsonExtension

Convert TwinCAT variables to and from Json

Haku.Zvar

Package Description

Beckhoff.TwinCAT.Ads.SymbolicServer The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

The Beckhoff.TwinCAT.Ads.SymbolicServer Package can be used to implement your own ADS Server.

YSAI.Beckhoff

采集协议:Beckhoff ( 倍福 - Tcp )

PlcInterface.Ads

A PLC communication implementation for Beckhoff ADS

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.1.203 4,300 3/15/2024
6.1.197 10,599 2/12/2024
6.1.154 16,572 12/8/2023
6.1.125 4,990 11/23/2023
6.0.356 1,114 2/12/2024
6.0.334 967 12/8/2023
6.0.322 725 11/23/2023
4.4.26 4,151 7/27/2023

Beta version of the ADS Version 5.0.0 Version branch. Don't use for productive code.