Handle einer SPS Variablen löschen

Download

Voraussetzungen

Sprache / IDE

Beispielprogram auspacken

C# / Visual Studio

Sample11.zip

Beschreibung

In diesem Beispiel wird das Handle einer SPS Variablen gelöscht:

C# Programm


static void Main(string[] args)
{
//Create a new instance of class TcAdsClient
TcAdsClient tcClient = new TcAdsClient();
int iHandle = 0;

try
{
// Connect to local PLC - Runtime 1 - TwinCAT 3 Port=851
tcClient.Connect(851);

//Get the handle of the PLC variable "PLCVar"
iHandle = tcClient.CreateVariableHandle("MAIN.PLCVar");

//Release the specific handle of "PLCVar"
tcClient.DeleteVariableHandle(iHandle);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadKey();
}
finally
{
tcClient.Dispose();
}
}