SIMATIC Automation Tool API for .NET framework
6.4 Common support classes
SIMATIC Automation Tool V2.1 user guide
72 Manual, V2.1.1 07/2016, A5E33042676-AC
You are not allowed to legitimize a connection to an S7 CPU using the fail-safe password. If
you specify a fail-safe password for any
ICPU method that accepts a password, the SIMATIC
Automation Tool API method will fail and return the error:
ErrorCode.LegitimizationFailsafeLevelNotAllowed.
The Result class
The Result Class
This class encapsulates the logic that determines if a given API action succeeded. Most API
actions involve some level of network communications. Many also involve opening a
connection to a network device. Such actions are never guaranteed to be successful. The
Result object returned by an API action should always be inspected for success or failure.
In many instances, it may be sufficient to know whether a given action was successful. In
this case, a check of the
Succeeded property is all that is required:
Result retVal = dev.RefreshStatus(new EncryptedString(""));
if (retVal.Succeeded)
{
//------------------------
// Continue operations....
//------------------------
}
In other cases, you may need more information about the failure. To inspect the specific
error, use the
Code property, as follows:
Result retVal = devAsCpu.RefreshStatus(new EncryptedString(""));
if (retVal.Succeeded)
{
//------------------------
// Continue operations....
//------------------------
}
else
{
//--------------
// What happened
//--------------
switch (retVal.Code)
{
case ErrorCode.AccessDenied:
break;
case ErrorCode.TooManySessions:
break;
}
}
ErrorCode values (Page 117)