FB_BaseBatchADSRead

Abstract function block for batch ADS read access. Each individual ADS read access is treated as a data record and processed cyclically, one after another. To use the function block, it must be derived; this requires implementing the OnInitData event method. Optionally, the OnRead and OnValidateData methods can be overridden to evaluate and validate the data that has been read.
Internally, the function block operates as a state machine with the steps Initialization and Read. For each data record, the function block first calls OnInitData to provide all the information needed for ADS read access. The data record is then read, optionally validated, and subsequently returned to the derived implementation via OnRead.
If an error occurs in a data record or validation fails, a suppression phase is activated depending on tTolerance. During this time, duplicate reports for the same data record can be suppressed. If bClearOnError is set, the destination buffer is set to 0 in the event of an error.
![]() | Using the function block: Derive from |
Syntax
FUNCTION_BLOCK ABSTRACT FB_BaseBatchADSRead
VAR_INPUT CONSTANT
tInterval : TIME := T#30S;
tTolerance : TIME := T#0MS;
bClearOnError : BOOL := FALSE;
tTimeout : TIME := T#5S;
nPort : T_AmsPort := 851;
END_VAR
VAR_OUTPUT
bBusy : BOOL;
bSuppressing : BOOL;
bError : BOOL;
nErrorID : UDINT := 0;
END_VAR
Inputs CONSTANT
|
Name |
Type |
Description |
|---|---|---|
|
tInterval |
TIME |
Cycle time between two initializations of data record processing. |
|
tTolerance |
TIME |
The delay time before a pending error is treated as persistent and flagged. |
|
bClearOnError |
BOOL |
Clears the destination buffer in the event of a read or validation error. |
|
tTimeout |
TIME |
Timeout for each ADS read access. |
|
nPort |
T_AmsPort |
The remote station’s ADS port from which data is to be read. |
Outputs
|
Name |
Type |
Description |
|---|---|---|
|
bBusy |
BOOL |
Indicates that the function block is currently initializing or reading data records. |
|
bSuppressing |
BOOL |
Indicates that notifications and error analysis are temporarily suppressed due to the grace period. |
|
bError |
BOOL |
Becomes TRUE if an ADS read access fails or if the read data does not pass validation. |
|
nErrorID |
UDINT |
Contains the current ADS or validation error number. |
Methods
Name | Definition location | Description |
|---|---|---|
Local | Abstract event method for initializing the next record to be read. Returns the source address, symbol name, destination buffer, and optional parameters. | |
Local | This function is called after each read access is completed and can analyze the data that was read. | |
Local | Checks the data that has been read before it is processed further. By default, the data is considered valid. |
Properties
|
Name |
Type |
Access |
Definition location |
Description |
|---|---|---|---|---|
|
Suppressing |
BOOL |
Get |
Local |
An internal property that indicates that notifications are suppressed during the active grace period. |
