PlaybackLogFile

<< Click to Display Table of Contents >>

Navigation:  Reference (Scripting) > Docklight Script Commands - The DL Object > Methods (Advanced) >

PlaybackLogFile

Opens an existing Docklight Log File (HEX, Decimal or Binary representation) and plays back (re-sends) the data from one communication direction of this log file.

 

Starts the communication, if not already running (see StartCommunication).

 

Return Value

 

Void

 

Syntax

 

DL.PlaybackLogFile filePathName [, dataDirection] [, timeInterval ]

 

The PlaybackLogFile method syntax has these parts:

 

Part

Description

filePathName

Required. String containing the file path (directory and file name) of the log file. If no directory is specified, Docklight uses the current working directory. If filePathName is an empty string, a file dialog will be displayed to choose a file.

dataDirection

Optional String value. Specifies which of the two communication channels  recorded (TX or RX? COM1 or rather COM2?) should be played back. If dataDirection is an empty string, the first channel that appears in the log file is used.

timeInterval

Optional Integer value. Use a pause time in milliseconds between two messages instead of the original timing from the log file (see remarks below).

 

Remarks

 

Playback is only possible in Communication Mode Send/Receive and only for log files in HEX, Decimal or Binary representation. Both HTML (.htm) and plain text (.txt) files can be used for playback.

 

If filePathName does not exist, Docklight reports an error and the script execution is stopped.

 

The log file used must contain date/time stamps for the two communication directions.

 

filePathName needs to contain the original Docklight-style name extension to determine the type of log file, e.g. "log1_hex.txt", "log1_dec.txt" or "log1_bin.txt". If filePathName has a different format, a HEX log file is assumed.

 

PlaybackLogFile evaluates the date/time stamps from the log file and emulates the timing of the original communications logged. If you want to change this, e.g. to slow down things for debugging purposes, you can use the optional timeInterval argument.  

 

Example

 

' Example PlaybackLogFile

 

' Playback the first data direction from a sample log file

DL.AddComment "Playback TX side"

DL.PlaybackLogFile "modbus_logfile_hex.txt"

 

' Same file, but now play the answers from the RX side

DL.AddComment

DL.AddComment

DL.AddComment "Playback RX side"

DL.PlaybackLogFile "modbus_logfile_hex.txt", "RX"

 

' Same file, but use a fixed time interval between the individual sequences.

DL.AddComment

DL.AddComment

DL.AddComment "Playback TX with fixed 500 milliseconds interval"

DL.PlaybackLogFile "modbus_logfile_hex.txt", "", 500

 

We assume that the log file modbus_logfile_hex.txt was created during a previous Modbus communication session and contains the following information:

8/29/2006 18:45:23.19 [TX] - 01 04 00 00 00 01 31 CA

8/29/2006 18:45:23.34 [RX] - 01 04 02 FF FF B8 80

8/29/2006 18:45:33.14 [TX] - 02 04 00 00 00 01 31 F9

8/29/2006 18:45:33.29 [RX] - 02 04 02 27 10 E7 0C

8/29/2006 18:45:43.23 [TX] - 03 04 00 00 00 01 30 28

8/29/2006 18:45:43.39 [RX] - 03 04 02 00 00 C0 F0

8/29/2006 18:45:58.72 [TX] - 04 04 00 00 00 01 31 9F

8/29/2006 18:45:58.87 [RX] - 04 04 02 04 00 77 F0

 

After running the example script, the communications window could look like this:

 

Playback TX side

 

4/26/2009 13:29:15.841 [TX] - 01 04 00 00 00 01 31 CA

4/26/2009 13:29:25.788 [TX] - 02 04 00 00 00 01 31 F9

4/26/2009 13:29:35.879 [TX] - 03 04 00 00 00 01 30 28

4/26/2009 13:29:51.367 [TX] - 04 04 00 00 00 01 31 9F

 

Playback RX side

 

4/26/2009 13:29:51.545 [TX] - 01 04 02 FF FF B8 80

4/26/2009 13:30:01.495 [TX] - 02 04 02 27 10 E7 0C

4/26/2009 13:30:11.596 [TX] - 03 04 02 00 00 C0 F0

4/26/2009 13:30:27.075 [TX] - 04 04 02 04 00 77 F0

 

Playback TX with fixed 500 milliseconds interval

 

4/26/2009 13:30:27.095 [TX] - 01 04 00 00 00 01 31 CA

4/26/2009 13:30:27.595 [TX] - 02 04 00 00 00 01 31 F9

4/26/2009 13:30:28.096 [TX] - 03 04 00 00 00 01 30 28

4/26/2009 13:30:28.596 [TX] - 04 04 00 00 00 01 31 9F