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:
- Playing back data from specific start time to end time on certain speed.
- Calculate aggregate using relative start and end-time.
- 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.
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.