EXPORT_LOG
Generate historic log data using the functionality provided by Data Export. See the main Data Export help for details (the Application Explorer.Data Export). See also the important Operational Notes below.
WebVue support - Yes.
The use of the verbs EXPORT, EXPORT_LOG and EXPORT_TREND is preferred to verbs SVLOG and SVTREND. The latter are kept for compatibility only.
The Data Export module is protected by a license option in PcVue's protection key. If you do not have this option then Data Export will only operate in demonstration mode.
Mode | Mnemonic | Syntax |
1 | GETRECORD | 1 |
2 | GETSTATISTIC | 2 |
3 | READBUFFER | 3 |
4 | CANCEL | 4 |
5 | DISPOSE | 4 |
Common Arguments
Argument |
Meaning |
LogListName |
The name of the log list from which to get the data. Type STR. |
StartTime | The start time for the historic request. The start time must be earlier than the end time. Type DOUBLE. |
EndTime | The end time for the historic request. The end time must be later than the start time. Type DOUBLE. |
Events |
A number calculated using binary weighted values, representing the events to retrieve (decimal values in brackets). Type DOUBLE. |
AlarmLevelMin | Minimum alarm level (0 to 29). Type INTEGER. |
AlarmLevelMax | Maximum alarm level (0 to 29). Type INTEGER. |
ExpressionFilter |
Attributes expression filter. See the topic: |
StatusVariable | The name of a register variable in which the status of the export is reported. Type STR. |
LineSeparator | A single character that is to be used as a line separator in the request output. Type STR. Using "\n" (carriage return) is recommended to avoid parsing errors due to regional settings or field values (those may have commas, semi-columns or dots). |
ColumnSeparator | A single character that is to be used as a column separator in the request output. Type STR. Using "\t" (tab) is recommended to avoid parsing errors due to regional settings or field values (those may have commas, semi-columns or dots). |
MaxRetLines | The maximum number of lines that the request returns (overrides the global setting Max count for generated data). 0 = no maximum. Type INTEGER. |
MaxValuesToProcess | The maximum number of raw values that are to be processed (overrides the global setting Max count for raw data). 0 = no maximum. Type INTEGER. |
Syntax 1
IntVal = EXPORT_LOG(Mode, LogListName, StartTime, EndTime, Events, AlarmLevelMin, AlarmLevelMax, ExpressionFilter, StatusVariable, LineSeparator, ColumnSeparator, MaxRetLines, DataFormat, DataHeader)
Return type: INTEGER.
Argument |
Meaning |
DataFormat |
Data format for columns. The format for each column is separated by a pipe symbol. Type STR. |
DataHeader | Header text. Each column header is separated by a pipe symbol. Type STR. Example: Date|Time|Event|Title |
Execution
Mode |
Mnemonic |
Action |
1 | GETRECORD |
Generate a historic request to return the log records from the Log List. |
Syntax 2
IntVal = EXPORT_LOG(Mode, LogListName, StartTime, EndTime, Events, AlarmLevelMin, AlarmLevelMax, ExpressionFilter, StatusVariable, LineSeparator, ColumnSeparator, MaxValuesToProcess, MaxRetLines, StatFlag, StatSortOrder, StatCountersFormat, StatRounded)
Return type: INTEGER.
Argument |
Meaning |
StatFlag |
A number calculated using binary weighted values, representing the statistics to generate (decimal values in brackets). Type LONGLONG. |
StatSortOrder | The statistic used to sort the results. Selected using one of the values used for StatFlag. 0 = no sorting. Type LONGLONG. |
StatCountersFormat | A number indicating the unit for the duration counters. Type INTEGER. 0 = None 1 = Seconds 2 = Minutes 3 = Hours 4 = Days |
StatRounded | Type INTEGER. 0 = Not rounded 1 = Rounded |
Execution
Mode |
Mnemonic |
Action |
2 | GETSTATISTIC |
Generate a historic request to return statistical values from the log list. Return: See the Operational Notes below. |
Syntax 3
IntVal = EXPORT_LOG(Mode, BufferHandle);
Return type: INTEGER.
Argument |
Meaning |
BufferHandle |
The handle of a buffer previously created using ALLOC_BUFFER. Type LONG. |
Execution
Mode |
Mnemonic |
Action |
5 | READBUFFER |
Read the buffer of data after either a GETRECORD or GETSTATISTIC. |
Syntax 4
IntVal = EXPORT_LOG(Mode);
Return type: INTEGER.
Execution
Mode |
Mnemonic |
Action |
6 | CANCEL |
Cancel the current historic request. A CANCEL should always be followed by a DISPOSE. |
7 | DISPOSE | Release internal buffer used in a historical request. Must always be called before making a further historic request or after a CANCEL. Return: Always 0. |
Operational Notes
The EXPORT_LOG instruction operates asynchronously. That is once a historical request has been generated by either modes GETRECORD or GETSTATISTIC, the script continues without waiting for the historical data to be generated. The instruction's return value indicates if the historic request was successfully sent, or not.
When the historical request is complete (successfully or otherwise) the value of the Status Variable is changed accordingly. On this change, if the Status Variable's value indicates a success, READBUFFER mode must be used to retrieve the data into a memory buffer from where further processing can be done (for example exporting to Excel using BUFTOEXCEL).
It will normally be necessary to use READBUFFER more than once until the number of lines it returns is 0 indicating that all data has been processed.
If you use a loop including READBUFFER, you must respect the 30 seconds limit that is allowed for a continuous SCADA Basic thread. If you exceed this (which is possible if you are processing large amounts of data), the thread will abort with an error.
After completion, a DISPOSE mode must be executed to release the internal buffer used in the historical request.
Return values
All return values other than zero indicate an error. In particular, -30 indicates a previous request is still running and should be accommodated in the script.
Value |
Meaning |
0 | Request sent |
-1 | LogListName is not a STR |
-2 | LogList doesn’t exist |
-3 | Start time undefined or invalid |
-4 | End time undefined or invalid |
-5 | Event code cannot be read |
-6 | Event code smaller or equal to 0 |
-7 | AlarmLevelMin cannot be read |
-8 | AlarmLevelMin between 0 and 29 |
-9 | AlarmLevelMax cannot be read |
-10 | AlarmLevelMax between 0 and 29 |
-11 | AlarmLevelMin smaller than AlarmLevelMax |
-12 | ExpressionFilter is not a STR |
-13 | StatusVariable is not a STR |
-14 | StatusVariable is not a register |
-15 | LineSeparator cannot be read |
-16 | ColumnSeparator cannot be read |
-20 | DataFormat is not a STR |
-21 | DataHeader is not a STR |
-22 | Format and header have different column count |
-23 | StatFlag cannot be read |
-24 | StatFlag smaller or equal to 0 |
-25 | StatSortingOrder cannot be read |
-26 | StatSortingOrder is smaller than 0 |
-27 | StatCountersFormat cannot be read |
-28 | StatCountersFormat between 0 and 4 |
-29 | StatRoundedToRequest cannot be read |
-30 | A previous request is still running |
Status variable values
The status of the latest historical request.
Value |
Meaning |
0 | Completed successfully. |
1 | Running. |
3 | Canceled. |
4 | Completed but the maximum number of points has been reached. |
5 | Completed but the maximum number of processed values has been reached. |
10 | Failed. |
11 | Failed due to an incorrect configuration. |
12 | Failed due to a failed historical request. |
Examples
See the Examples link at the top of the topic.