Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Error Codes

  • Last UpdatedJul 13, 2023
  • 2 minute read

The error codes returns from the CtAPI functions are the Microsoft WIN 32 error codes. These error codes are documented in the Microsoft SDKs. Where the error code is a Plant SCADA special error code, the error code is added to the value -ERROR_USER_DEFINED_BASE.

Note: If a CtAPI function returns the error 233, it typically means the connection to the client is not established. However, it may also mean the client has not logged in correctly. Check for both scenarios.

Example

int bRet = ctTagWrite(hCTAPI, "SP123", "12.34");

if (bRet == 0) {

dwStatus = GetLastError();

if (dwStatus < ERROR_USER_DEFINED_BASE) {

// Microsoft error codes see ERROR.H

} else {

short status;

// status is thePlant SCADA error codes, see Plant SCADA help

status = dwStatus - ERROR_USER_DEFINE_BASE;

}

}

The following defines have been declared to make this checking easier:

IsPlantSCADAError(dwStatus) // test if Plant SCADA error

WIN32_TO_CT_ERROR(dwStatus) // Convert to Plant SCADA status

For example:

if (IsPlantSCADAError(dwStatus)) {

short status;

// status is the Plant SCADA error codes, see Plant SCADA help

status = WIN32_TO_CT_ERROR(dwStatus);

}

If the connection is lost between your application and Plant SCADA, close the connection and reopen. An inoperative connection will be shown by the returning of a Microsoft error code. If a Plant SCADA status error is returned, the connection has not been lost. The command requested is invalid and the connection does not have to be closed and reopened.

int bRet = ctTagWrite(hCTAPI, "SP123", "12.34");

if (bRet == 0) {

dwStatus = GetLastError();

if (dwStatus < ERROR_USER_DEFINED_BASE) {

ctClose(hCTAPI);

hCTAPI = ctOpen(NULL, NULL, NULL, 0);

while (hCTAPI == NULL) {

Sleep(2000); // wait a while

hCTAPI = ctOpen(NULL, NULL, NULL, 0);

}

}

}

When the connection between your application and Plant SCADA is lost, any pending overlapped commands will time out and be canceled by CtAPI. You need to destroy handles which are associated with the connection.

In Version 5.10, the CT_OPEN_RECONNECT mode was added to ctOpen(). When this mode is enabled, CtAPI will attempt to re-establish the connection to Plant SCADA if a communication interruption occurs. Handles created with the connection will remain valid when the connection is re-created. While the connection is down, functions will be ineffective and will report errors.

See Also

Debug Tracing

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in