Replay Data

Follow the guide Add Module to Apis Hive, but this time select a module of type ApisReplay from the Module type drop down list.

3 ways of running the Replay module will be described here:

  1. Playing back data from specific start time to end time on certain speed.
  2. Calculate aggregate using relative start and end-time.
  3. Playback data and use for input to another module and synchronize these.
  • After adding the module, select the new module named "Replay" from theSolution Explorer.

1. Playing back data from specific start time to end time on certain speed.

In the Properties Editor, enter values for:

"SynchronousReadDelay": 1000 ms.This property is the delay in ms. between read from the database. Setting this property to 0 might cause system overload.

"Resolution":1 s.

"StartTime" and "EndTime": Choose values where you are sure that database contains data.

"Exchange rate": Exchange rate in milliseconds for updating items from external items.

Press "Apply" when done.

Follow the guide Add Items to a Module, but this time add item of type "SynchrounusItem".

  • Click the "Browse" button.

  • A dialog opens that lets you select Items in the database(s). Click "Ok" when done.

  • The item list will get new entries showing the added items.

In addition it shows number of status and control items, amongst them; "Start and End-Time", "Resolution" and "Sync delay". The newly added items now shows quality bad, they still have no data.

Toggle the "CmdStart" tag to true

The replay starts, CurrentTime shows the timestamps of played values, the timestamps of replayed values depends of the "TimeMode" property.

Controlling the playback:

The "speed" of the playback can be adjusted with the "Syncdelay" item and the Resolution depending of application.

Playback can be paused/unpaused by toggle the "CmdPause" item, in pause you can step playback by toggle the "CmdStep" item.

If the "Step on NextTime" property is set, you can in Pause step to a desired time by setting the "NextTime" item to a value between "Start" and "End-time"

2. Calculate aggregate using relative start and end-time.

In the Properties Editor, Advanced section enter values for:

UseRelativeTime : true

SynchronousReadAggregate : "Average" or any other aggregate suitable for your needs.

We use the same items as in previous example, in the item list set the values of "RelativeStart" and "EndTime" and "Resolution". In this case we want to calculate the average of the last hour.

Toggle "CmdStart"

The replayed items will now show the average for the last hour.

3. Playback data and use for input to another module and synchronize these.

A. Replicate data from a Modbus source stored in HoneyStore database to a ModbusSlave module

Create a new Replay module and add SynchronousItems.

Click browse to open the dialogue screen for selecting database items.

Applying a filter before clicking browse a second time is recommended if you are looking for specific items when working in an environment with large databases (unless it is desired to view all items found in all present databases.) Also note that using Content filter with the box ticked performs filtering as you type and can potentially slow down performance when working with a large amount of items.

IMPORTANT: Both HoneyStore and the OPCHDA service/server must be running for the items to show up in this step.

Once the items have been selected click OK and they will appear in the Replay module.

Create a ModbusSlave module and add the relevant items. In this example we are using two modules, one with HoldingRegister and the other with InputRegister items connected to two seperate Replay modules reading values from databases containing values sampled with 1 second and 1 minute intervals.

Right-click an item and select Connect. Find the desired source item in the Replay module and link it to the corresponding destination item in the ModbusSlave module. Click Connect, then OK.

It is important that the SrcItemId in the destination item matches that of the source item (ExternalItem 1). In this case the item name is Documentation-1s.Worker.Documentation.Signal1 (omitting the modulename prefix "Replay-1s").

In certain cases the ExternalItems will fail to load on initial startup. Check to see if EventType is set to AEBE_TIMER_ON under Module->Events->ExternalItems. If this value is AEBE_TIMER_OFF changing the modules ExhcangeRate to some random value and then back to the desired rate will fix this issue.

In this example setup the Resolution is set to 1 and SynchronousReadAggregate is Interpolative zero-order, resulting in the values being changed every minute given that the database only contains new values with 1 minute intervals.

In the Property editor under "Information" the StartTime and EndTime of the two buffers are displayed. These buffers are determined by the MajorSubInterval property in seconds, which divides the entire timespan given by StartTime, EndTime and Resolution into smaller chunks, in this case 1 hour intervals (3600 seconds).

If the amount of data required exceeds available memory the module will calculatue the largest possible MajorSubInterval and override the property before starting. If MajorSubInterval is set to 0 the entire timespan will be used as one buffer if there is enough memory available, if not the largest possible MajorSubInterval will be used.

Note that the data Type might change depending on the SynchronousReadAggregate and Resolution. In this example the values from the 1 second database are being passed on as their original valuetype (Float) given that the SynchronousReadAggregate is set to "Interpolative zero-order", but the values from the 1 minute database gets converted to Double since SynchronousReadAggregate is set to "Average" and Resolution is 60.

B.

This implicates another module consuming data from the Replay module, this is beyond Quick start guide, however here is a simple example.

A simulation module is required in this case Java module connected to a simple ModFrame application. The ModFrame application has two input signals Salar1 and 2 and one output signal Scalar3. The playback items ApisReplay.Logger.Worker.Signal3 and 4 ar used as input to Java.Scalar1 and 2

To be able to synchronize these two modules Java and ApisReplay we have to use the internal Commands and Events mechanism in Apis.The image below shows the default configuration for these two modules.

In the Replay module we have OnSyncReadDone, event th at notifies that a synchronous read operation has finished and new data is ready on replayed items. In the default configuration this event is connected to ReadSync command which initiates a new synchronized read operation immediately (a loop).

In Java module there is a OnTimer, event fired when at a rate given by the module-property Timerperiod. this is connected to the OnsStep command calling the OnOneStep() java method, when OnOneStep() retuns it fires OneStepDone event indicating that the OnOneStep() java method is finished. With this configuration these two modules live their own life.

In next image we have changed the configuration: When Replay module has new data (OnSyncReadDone) it notifies the Java module first to read input (HandleExternalItems) and then to run a step (OneStep). When Java has finished its calculation, (this could take some time if the application was a advanced simulator) it fires OnStepDone which triggers ReadSynch i Replay module. We now have a "loop" where the two modules are synchronized.

Trouble shooting

No data :Check Start- and End- time, is there any data in the time period.

Hangs : Check Commands and Events loop.