Implement the plugin
- Last UpdatedApr 24, 2025
- 2 minute read
The format the Batch Tracking Compiler (BTC) plugin function signature is as follows:
int process_custom_field(RealTimeRecord& record, const char* key, const char* value);
Where:
-
The return value is the error code of the plugin execution. The system considers any non-zero code an error. If a non-zero code is returned, the BTC process terminates with an error status. In scenarios where an unexpected condition should be treated as a warning, you can make the plugin generate a log message, and the function should return zero. It is the responsibility of the plugin to handle different error conditions and write to the error log if needed.
-
record = The RealTime database (RTDB) table record locked for writing. The BTC application releases the lock after the plugin execution terminates.
-
key = The label assigned to the custom field in the BT file without the exclamation mark ("!").
-
value = The value assigned to the custom field in the BT file.
When the Batch Tracking Compiler (BTC) process runs, the system passes the key-value pair, and the record under which they are defined, to the plugin for processing. AVEVA recommends that the plugin use the following strategy to process the different custom fields in the BT file:
-
Perform any required preparations before processing, such as removing the comment from the value string.
-
Create a switch statement (or equivalent logic) to inspect the record and key and determine how to process them.
-
Return an error code to communicate back to the BTC process if it should either continue or terminate with an error:
-
A value of 0 indicates that the processing of custom fields has been successful.
-
Any integer other than 0 indicates that the processing of custom fields has failed.
-
The following code skeleton demonstrates the implementation strategy explained above:
int process_custom_field (RealTimeRecord& record, const char* key, const char* value) {
int returnCode = 0;
//Perform any required preparations before processing, such as removing the comment from the value string
cleanValue = removeComment(value);
//Create a switch statement to handle different custom fields
switch (key):
CASE "KEY1":
//processKey1 is expected to handle all the processing including mapping the provided key to the
//appropriate custom field in the RTDB, performing necessary validations,
//interpreting the value and writing it to the RTDB record, and writing to the log if needed
returnCode = processKey1(record, key, cleanValue);
Break;
CASE "KEY2":
returnCode = processKey2(record, key, cleanValue);
Break;
...
MORE CASES
...
DEFAULT:
returnCode = logError(...);
return returnCode;
}