Reading Variables in Batches

<< Click to Display Table of Contents >>

 

Reading Variables in Batches

This Driver allows reading history data blocks stored in batches in memory. A device stores N samples of M variables from a batch in a memory area and, at the end of that batch, increments a BN variable and configures an I variable with the interval between samples, in milliseconds. A Flag variable is configured with the value 1 (one) whenever a device is performing a sampling and configured with the value 0 (zero) whenever a batch is ready for reading. The memory map shown next corresponds to the variables N equal to 100 and M equal to 8 (eight). All variables are normal registers of a device, that is, integers with 2 (two) bytes.

000: Flag (1: Batch is not ready or 0: Batch is ready)
001: BN (Batch number)
002: I
003: M
004: N
First sample
005: V1, V2, V3, V4, V5, V6, V7, V8
Second sample
013: V1, V2, V3, V4, V5, V6, V7, V8
...
...
...
Last sample
797: V1, V2, V3, V4, V5, V6, V7, V8

 

Reading and monitoring a device's history is performed using a Tag with the B2 parameter equal to 100, according to the next table. The number of Elements of this Block Tag is equal to the number of variables read in each register. This Tag only returns data if there are batches to read and if the Flag variable is configured as 0 (zero). Batches already in memory at the moment of the first reading of this Tag, or the first scan after initializing an application, are considered as already read and only new batches are read.

 

B1

Address of a device in the network, between 1 (one) and 63

B2

100

B3

Starting address of a data block

B4

This parameter must be used only for Word data types. Possible values are 0: Unsigned integer between 0 (zero) and 65536 or 1: Signed integer between -32767 and 32767. For other data types this parameter is not used and can be left in 0 (zero)

 

At each scan of this Tag, this Driver must monitor the BN variable (batch number) and, if it detects a change in its value, it must check whether the Flag variable is configured with the value 0 (zero). If true, it must transfer the history of this batch to the application, considering as the starting time the current time minus the result of (N × I) - 1, in milliseconds, and add I milliseconds for each new sample.

The values read from each batch are returned by this Driver to an application as a list of events, generating a succession of OnRead events of this Tag. For each OnRead event, the Elements of this Tag contain the values referring to a specific register from a batch. Users can use a script in these events to execute a WriteRecord method of the linked Historic object, storing the blocks read one by one.

Was this page useful?