Replay Logfiles (Command Line)

To replay data, runtime nodes need to be told which logfile session to load. Sensor and hardware nodes subscribe to the ps_rnr_msg to receive commands to enter record or replay modes and know when to start reading or writing the data.

PolySync provides both GUI and command line tools to command runtime nodes to record and replay data.

This article shows how to use the supplied C API rnr_control example application to command nodes to replay an existing logfile session.

1. Clone the repo

The rnr_control code is in the PolySync C Examples GitHub repo.

$ git clone https://github.com/PolySync/PolySync-Core-C-Examples

2. Build the application

The project uses Make to build, and places the binary in the bin/ directory.

$ cd PolySync-Core-C-Examples/rnr_control
$ make
$ sudo cp ./bin/polysync-rnr-control-c /usr/local/polysync/bin

The binary is built and is named polysync-rnr-control-c.

3. Record and replay sessions directory

Each host has a defined record and replay (RnR) sessions directory defined in the SDF. The RnR directory is defined and viewed in the SDF Configurator, and can also be printed by the license tool:

$ polysync-license-tool
*****************************
*** PolySync License Tool ***
API Build Version: 2.0.9-1486494674

[...]
Record and Replay Sessions Directory: '/home/$USER/.local/share/polysync/rnr_logs'
[...]

*****************************

The polysync-rnr-control-c application can only command runtime nodes to replay data contained in the RnR directory. The default directory is $PSYNC_USER_HOME/rnr_logs.

4. Replay a PolySync logfile

Now that the polysync-rnr-control-c application has been built, we can use it to command nodes to replay PolySync logfiles.

4.1 Starting runtime nodes

Use the manager to start all runtime nodes defined in the system SDF in the replay context.

$ polysync-core-manager -n -w

Nodes are now in the standby state, waiting to be told which PolySync logfile to load for replay.

4.2 Commanding replay

The polysync-rnr-control-c application uses the -t flag to indicate which logfile session to replay. All other flags are optional while commanding runtime nodes to replay data.

$ polysync-rnr-control-c -t 1000

This command will replay the default logfile session that ships with PolySync.

It’s important to note that the rnr_control application has no knowledge of the nodes on the PolySync bus. It’s simply packaging and publishing a ps_rnr_msg that active nodes subscribe and react to.

For systems that have a couple dozen nodes, or limited compute resources, it’s nice to provide a loading grace period. Pass in the -s <opt> flag to specify a relative start time (microseconds), or the -S <opt> flag to specify an absolute UTC microsecond start time.

$ polysync-rnr-control-c -t 1000 -s 3000000   # 3 seconds

To stop replay at any time, use the applications -q flag.

$ polysync-rnr-control-c -q

5. Access and visualize the data

Now that data is being published on the bus by dynamic driver nodes, you can use applications like Studio, the C++ Echo example, or a custom application to access the data.