Sample06: UI-C#-ADS client uploading the symbolic from module

This article describes the implementation of an ADS client to

Download

Here you can access the source code for this client sample.

This code requires .NET Framework 3.5 or higher!
1. Unpack the downloaded ZIP file.
2. Open the sln file contained in it with Visual Studio.
3. Create the sample on your local machine (right-click on the project and click on "Build").
4. Start the program with a right-click on Project, Debug->Start new instance.

The client sample should be used with sample 03 "C++ as ADS server".

Open Sample 03 before you begin with this client-side sample!

Description

The possibilities of the ADS are described on the basis of this sample.

The details of the implementation are described in Form1.cs, which is included in the download. The connection via ADS with the target system is established in the btnLoad_Click method, which is called on clicking on the Load Symbols button. From there you can explore the different GUI functions.

Background information:

For this ADS client it is irrelevant whether the ADS server is based on TwinCAT 2 or TwinCAT 3. It also doesn't matter if the server is a C++ module, a PLC module or an IO task without any logic.

The ADS client UI

On starting of the sample the user interface (UI) is displayed.

Sample06: UI-C#-ADS client uploading the symbolic from module 1:

Selecting a communication partner

After starting the client, enter the two ADS parameters, in order to determine your ADS communication partner.

Sample06: UI-C#-ADS client uploading the symbolic from module 2:

Do not confuse the ADS server port with the regular ADS port.

Do not confuse the ADS server port (which was explicitly implemented in sample 03 for providing your own message handler) with the regular ADS port for the purpose of access to symbols (this is provided automatically, without the need for user intervention):

The regular ADS port is required to access symbols. You can find the AdsPort for the IO task of your instance or the module instance yourself (since the module is executed in the context of the IO task).

Navigate to IO task Task1 and note the value of the port: 350.
Sample06: UI-C#-ADS client uploading the symbolic from module 3:

Since the C++ module instance is executed in the context of Task1, the ADS port is also 350.
Sample06: UI-C#-ADS client uploading the symbolic from module 4:

Enabled symbols for access available via ADS

Individual symbols or whole data areas can be provided for access via ADS, or they can be deliberately not provided.
Navigate to the Data Area tab of your instance and activate/deactivate the C/S column.

In this sample all symbols are marked and therefore available for ADS access.

After making the changes, click on Activate configuration.

Sample06: UI-C#-ADS client uploading the symbolic from module 5:

Load symbols

Once the NetID and the ADS port have been set up, click on the Load Symbols button to make a connection with the target system and load the symbols.

All available symbols are then visible. You can then: