Accessing historical values - D2_ArchValue function

Access to historical values of D2000 system is allowed by the function D2_ArchValue.


Declaration
D2_ArchValue
(target, archObjeName, bt, et, step, attribute, refresh) 

Parameters
target

 

reference to either one-row or one-column block determining the position of the values from the archive.
archObjName

TEXT type

  • Reference to one value of historical value.
  • Reference to simple value of object (not structured variable).
  • In case of structured variable it is one item (SV.Struct[2]^Item),
    otherwise name of object (e.g. I/O tag).
    In this case the system will automatically look for a "suitable" objet of Historical value type.
    If the column "Item" is of the Object type it is possible to specify a string ",ALL" right after the name of column (e.g. SV.Struct[4]^Item,ALL). This causes the historical values to be obtained for the connected object, not for the item of a structured variable.
bt

ABS. TIME type

Begin time of the archive block.
et

ABS. TIME type

End time of the archive block.
step

INT type

Time step [s] within the archive block.
attribute

TEXT type

Required attribute of historical value.
refresh

 

Optional parameter.

Description
The function returns required attribute of the historical value (the parameter attribute - see the function D2_GetValue) of the given historical value defined by the parameter archObjName. The parameters bt and et defines the time interval of the archive block and the parameter step defines oversampling the values in the archive.

The parameter refresh - see the function D2_GetValue.

Time of a value from the archive is defined by the relative position of the cell containing the function call and the block, to which the parameter target is referred.

Block must be either one-row or one-column.



One-row block


One-row block (can contain several columns) specifies the cells, where you can place the function D2_ArchValue as a rectangle bounded from above. Correct and incorrect positions of cells is shown in the figure below (the functions contains the parameter target only):

The cells C10, C11, C12, …, D10, D11, E10, E11, F10, F11, F12, … are misplaced and the cells D12, D13, …, E12, E13, … are placed correctly in regard of the block D12:E12 (the target). The character $ in the reference ensures, that that the reference is absolute one (not relative one) and it can't be changed by copying cells.

Defining a time interval (the parameters bt and  et) and a step (the parameter step) we can get a sequence of archive values arranged by time in ascending order. This allows us to number individual values in ascending order (by time) from 1. Dependence between the position of the function D2_ArchValue (cell position) and the number (index) of an archive value is shown in the following figure:

The value of the cells, which are misplaced, is invalid position (invalid target). Correctly placed cells contains the number of a value (index), which will be actually displayed. In one-row blocks, the cells are numbered from 1 (the cell placed in the corner left top of the block Target) from left to right in rows.

Example:
The parameters of the archive blocks are:
BT =
10:00:00 1.1.2000
ET =
12:00:00 1.1.2000
STEP =
30*60 = 1800 (1/2 hour)

Times of individual values are:

Value number

Value time

1

10:00:00 1.1.2000

2

10:30:00 1.1.2000

3

11:00:00 1.1.2000

4

11:30:00 1.1.2000

5

12:00:00 1.1.2000

6

Value is out of defined interval.

The return value of the values, which are out of required interval, is the error: #Value, or the value of the cell named SUPP_NO_ARCH_DATA if exists (see the topic Predefined cells).

One-column block


One-column block (can contain several rows) specifies the cells, where you can place the function D2_ArchValue as a rectangle bounded from the left. Correct and incorrect positions of cells is shown in the figure below (the functions contains the parameter target only):

The cells C10, D10, D10, …, C11, D11, E11, …, C12, C13, C14, C15, C16, D16, E16, … are misplaced and the cells D12, E12, …, D13, E13, …, D15, E15, … are placed correctly in regard of the block D12:D15 (Target).

Dependence between the position of the function D2_ArchValue (cell position) and the number (index) of an archive value is shown in the following figure:

Napíšte komentár