Description: This launched module returns an array of logged data.
Returns: An array, stored in the first parameter (see comments)
Usage: Script
Format: \GetLog(Result, Tag, Name, Start, End, TPP, Size, Mode, Obsolete [, StaleTime] [, TimeZoneBias])
Parameters: Result { pointer } { required } { no default }
A pointer to set to the array retrieved from file.
Tag { Object value } { required } { no default }
The object value of the tag from which to get the logged data.
Name { text or array } { required } { default: current timestamp }
The name of the logged value in the tag. If Invalid or a valid empty string, a timestamp is used.
It is possible to retrieve more than one field in a single GetLog statement. To do this, pass an array of values in as the Name parameter.
Start { numeric } { required } { no default }
The start time in seconds since January 1, 1970.
End { numeric } { required } { no default }
The end time in seconds since January 1, 1970. If invalid, Size limits the number of tags retrieved.
TPP { numeric } { required } { no default }
The time span per tag. If Invalid, Size limits the number of tags retrieved.
Size { numeric } { required } { no default }
The maximum number of tags to get. If greater than 0, data is accessed one at a time from file, rather than at equal time intervals. If TPP is valid, Size is ignored.
Mode { text } { required } { no default }
Indicates the mode of data collection.
Note: The mode is useful only when the TPP parameter is valid and greater than 0. Mode may be one of:
|
Mode |
Data Collection |
|
0 |
Time-weighted average |
|
1 |
Minimum in range |
|
2 |
Maximum in range |
|
3 |
Change in value over the range |
|
4 |
Value at start of range |
|
5 |
TimeOfMinInRange |
|
6 |
TimeOfMaxInRange |
|
7 |
SumOfZtoNZTransitions |
|
8 |
SumOfNonZeroTime |
|
9 |
Totalizer |
|
10 |
Interpolated |
|
11 |
Difference between the start and end values of a range (see comments) |
It is possible to retrieve more than one mode in a single GetLog statement. To do this, pass an array of values in as the Mode parameter.
Obsolete n/a
No longer used – maintained for backward compatibility.
StaleTime { numeric or array} { optional } { no default }
The meaning of StaleTime depends on the selected Mode. For Mode 0 through 10, StaleTime is indicates the maximum time to propagate an old value. For Mode 11, this is the maximum value of a range (see comments).
It is possible to specify more than one stale time in a single GetLog statement. To do this, pass an array of values in as the StaleTime parameter.
TimeZoneBias { numeric } { optional } { no default }
Used with time zone aware reports. If included, it should be the number of seconds that your time zone differs from UTC, specified in time stamps. This is the value that would be returned from TimeZone(0).
Comments: When the value of the Result parameter becomes valid, all of the data has been retrieved.
If Name is an array with more than one element, then GetLog will retrieve multiple fields from the tag. In this case, Result will be a two-dimensional array. The requested values will be returned in a manner analogous to GetHistory; that is, with the data for a column in the rightmost dimension, and the column index in the previous dimension.
When Name is specified as an array, Mode or StaleTime, or both, may be specified as either a single value or an array of values. If a single value is specified, that value will be used for each of the fields specified in Name. If an array of values is specified, the first element in the array will be applied to the first element of Name, and so on.
When TimeZoneBias is included, GetLog will translate the start and end times for the requested range of data from the local time zone to that of the server before retrieving the data. Then, before returning the retrieved data, it will translate the timestamps back to the local time zone.
When Mode is set to 11, Getlog counts to a maximum value as set by StaleTime, and then rolls over to start a new interval. Whenever there is a decrease in value from one record to the next in the file, it is assumed that the maximum of the range has been reached and a rollover has occurred.
Upon rollover, the value of Getlog for the previous interval is calculated as (StaleTime + CurrentValue) – Minimum Value from previous interval.
Thus, for a StaleTime set to 100 and values read as follows: 10, 40, 90, 5.
The transition from 90 to 5 marks a rollover event. The value for the previous interval is (100 + 5) – 10 = 95.
This module executes in parallel to the launching code.
Example:
If 1 Loop;
[
{ Setup the TimeZone Bias }
TZBias = \IsTimeZoneAware ? TimeZone(0) : Invalid;
{ Set up the fieldnames, modes & staletime arrays for Getlog }
FieldNames = New(5);
FieldNames[0] = Invalid { Timestamps };
FieldNames[1] = "Quality";
FieldNames[2] = "SuccessCount";
FieldNames[3] = "ErrorValue";
FieldNames[4] = "ErrorAddress";
Modes = New(5);
Modes[0] =
Modes[1] =
Modes[2] =
Modes[3] =
Modes[4] = Invalid;
{ Retrieve Data for the first tag }
\GetLog(&TagData,
Scope(\Code, Tags[TagIndex]) { Point object value },
FieldNames { Read data },
Start { Start time },
End { End time },
Invalid { Time per point },
#NUMRECLIMIT { No max number of recs },
Modes { Modes },
Invalid { Obsolete },
Invalid { Stale Time },
TZBias { TimeZone Bias });