EXPORT_LOG

Concept Link IconSee also Concept Link IconExample

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.
0x0000 0001 = Alarm on (1)
0x0000 0002 = Alarm off (2)
0x0000 0004 = Alarm on not ack (4)
0x0000 0008 = Alarm off not ack (8)
0x0000 0010 = Alarm on ack (16)
0x0000 0020 = Alarm off ack (32)
0x0000 0040 = Alarm not accessible (64)
0x0000 0080 = Alarm inhibited (128)
0x0000 0100 = Alarm program masked (256)
0x0000 0200 = Alarm variable masked (512)
0x0000 0400 = Alarm user masked (1024)
0x0000 0800 = Alarm expression masked (2048)
0x0000 1000 = Alarm taken into account (4096)
0x0000 2000 = Bit to 0 (8192)
0x0000 4000 = Bit to 1 (16384)
0x0000 8000 = Bit to NS (32768)
0x0001 0000 = User action command (65536)
0x0002 0000 = User action acknowledge (131 072)
0x0004 0000 = User action logon/logoff (262 144)
0x0008 0000 = User action execute program (524 288)
0x0010 0000 = User action mask alarm (1 048 576)

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:
The Application Explorer.Archives.Configuring archive units.Proprietary archive unit.Configuring log data recording.Using an attributes filter expression.

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.
Example: #D/#M/#Y|#h:#m:#s|#E|#T

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.
Return: See the Operational Notes below.

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.
0x0000 0000 0001 = Total transition count (1)
0x0000 0000 0002 = Bit to 0 (occurrences) (2)
0x0000 0000 0004 = Bit to 1 (occurrences) (4)
0x0000 0000 0008 = Bit NS (occurrences) (8)
0x0000 0000 0010 = Bit to 0 (duration) (16)
0x0000 0000 0020 = Bit to 1 (duration) (32)
0x0000 0000 0040 = Bit NS (duration) (64)
0x0000 0000 0080 = Alarm off (occurrences) (128)
0x0000 0000 0100 = Alarm on (occurrences) (256)
0x0000 0000 0200 = Alarm off ack (occurrences) (512)
0x0000 0000 0400 = Alarm off not ack (occurrences) (1024)
0x0000 0000 0800 = Alarm on ack (occurrences) (2048)
0x0000 0000 1000 = Alarm on not ack (occurrences) (4096)
0x0000 0000 2000 = Alarm unavailable (occurrences) (8192)
0x0000 0000 4000 = Alarm masked by expression (occurrences) (16384)
0x0000 0000 8000 = Alarm inhibited (occurrences) (32768)
0x0000 0001 0000 = Alarm not accessible (occurrences) (65536)
0x0000 0002 0000 = Alarm masked by program (occurrences) (131 072)
0x0000 0004 0000 = Alarm masked by user (occurrences) (262 144)
0x0000 0008 0000 = Alarm masked by variable (occurrences) (524 288)
0x0000 0010 0000 = Alarm off (duration) (1 048 576)
0x0000 0020 0000 = Alarm on (duration) (2 097 152)
0x0000 0040 0000 = Alarm off ack (duration) (4 194 304)
0x0000 0080 0000 = Alarm off noack (duration) (8 388 608)
0x0000 0100 0000 = Alarm on ack (duration) (16 777 216)
0x0000 0200 0000 = Alarm on not ack (duration) (33 554 432)
0x0000 0400 0000 = Alarm unavailable (duration) (67 108 864)
0x0000 0800 0000 = Alarm masked by expression (duration) (134 217 728)
0x0000 1000 0000 = Alarm inhibited (duration) (268 435 456)
0x0000 2000 0000 = Alarm not accessible (duration) (536 870 912)
0x0000 4000 0000 = Alarm masked by program (duration) (1 073 741 824)
0x0000 8000 0000 = Alarm masked by user (duration) (2 147 483 648)
0x0001 0000 0000 = Alarm masked by variable (duration) (4 294 967 296)

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.
The status variable must be either 0 (completed), 4 (completed but the maximum number of points has been reached) or 5 (completed but the maximum number of processed values has been reached).
Return: The number of lines retrieved or if less than 1:
0 = End of buffer
-1 = Invalid buffer handle
-2 = No previous historic request has been sent.
-3 = No answer received.
-4 = Nothing to read.
-5 = Buffer too small.

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.
Return: Always 0

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.