|
|
| DDFFDataRecorder () |
| | Constructor.
|
| |
| bool | complete (const std::string &entity, const ChannelWriteToken &w_token, const std::string &key=std::string("")) |
| | Complete; i.e., connect to the file storage. More...
|
| |
| bool | complete (const std::string &entity, const std::string &key, const std::string &data_class=std::string("")) |
| | Complete; i.e., connect to the file storage. More...
|
| |
| template<typename DCO > |
| bool | replay (const DataTimeSpec &ts, DCO &object, DataTimeSpec &object_ts) |
| | Replay "stream" data into a DCO object. More...
|
| |
| template<typename DCO > |
| bool | replay (const DataTimeSpec &ts, DCO &object) |
| | Replay "stream" data into a DCO object. More...
|
| |
| template<typename DCO > |
| void | record (const DataTimeSpec &ts, const DCO &object) |
| | Record data from a DCO object. More...
|
| |
| void | channelRecord (const DataTimeSpec &ts, const CommObjectWriter &writer) |
| | Record data from a generic data writer. More...
|
| |
| unsigned | channelReplay (const DataTimeSpec &ts, ChannelWriteToken &w_token) |
| | Replay previously recorded data into a write channel. More...
|
| |
| void | markRecord (const DataTimeSpec &ts) |
| | Mark until where data recording is complete. More...
|
| |
|
| ~DDFFDataRecorder () |
| | Destructor.
|
| |
|
bool | isValid () |
| | Is connected, valid, etc.
|
| |
|
unsigned | getStreamId () const |
| | Get the associated stream id.
|
| |
|
void | startReplay (TimeTickType tick) final |
| | Starting a new replay; provide offset for the replayed data.
|
| |
| void | spoolReplay (ddff::FileHandler::pos_type offset, ddff::FileHandler::pos_type end_offset, TimeTickType replay_record_tick, unsigned inblock_offset) final |
| | Control spooling replay position. More...
|
| |
Recording/replay facility for storing data in simulation replay.
To enable recording and replay, all DUECA modules that "generate" fresh data, e.g., a control loading module, or a module reading stick/ buttons/screens in a simulator etc., need to record the data generated and sent in a session, and be able to retrieve and replay that data in replay mode. Often it is enough to record the data sent over channels, but it may also be necessary, e.g., to have control loading devices mimic the previously generated motion, to record additional data. Decide what you need for full replay, and create one or more DDFFDataRecorder objects in your module to record the data and access the replay.
If your recorder directly records the data sent over a channel, the recorder needs to be "completed" in the isPrepared call for your module, after the channel has become valid, an example:
bool MyModule::isPrepared()
{
bool res = true;
CHECK_TOKEN(w_mytoken);
if (res) {
my_recorder.
complete(getEntity(), w_mytoken);
}
CHECK_RECORDER(my_recorder);
return res;
}
If you need to record additional data, not sent over a channel, create a recorder directly for a DCO datatype, in that case, the complete call changes a little, and is not dependent on a channel state:
my_other_recorder.complete(getEntity(),
"some unique key for the recorder",
"SomeDCODataClass");
CHECK_RECORDER(my_other_recorder);
In the "Advance" mode of the simulation, use the record call to record the data of the DCO object you are about to write:
my_recorder.
record(ts, my_dco);
or directly when writing (note, do not record in HoldCurrent:
DataWriter<MyObject> dw(w_mytoken, ts);
if (getCurrentState() == SimulationState::Advance) {
my_recorder.
record(ts, dw.data());
}
If you need to record the data from an event (which you will normally only now and then write, or even repeatedly in a single time span), make sure that the time span you specify when recording is 0, and use the markRecord() function in each cycle to indicate that you passed the given time:
while (writing_my_event) {
DataWriter<MyObject> dw(w_mytoken, ts);
if (getCurrentState() == SimulationState::Advance) {
my_recorder.
record(ts.getValidityStart(), dw.data());
}
}
if (getCurrentState() == SimulationState::Advance) {
}
When in the "Replay" mode, the recorder's "replay" method can be used to explicitly retrieve the previously stored data. In the following example, we assume an event object, when there is an event for the given time span, the replay call returns true.
if (getCurrentState() == SimulationState::Replay) {
MyObject obj;
DataTimeSpec ts2;
while (my_recorder.
replay(ts, obj, ts2)) {
DataWriter<MyObject> dw(w_mytoken, ts2);
dw.data() = obj;
....
}
}
Of course, if you wrote and recorded a stream channel, you may assume that the data is there during replay, ignore the returned boolean, and call replay only once.
If you only want to write the data to the channel again, and you don't need to access the data in the module, you can use the channelReplay method. This handles event or stream channels in the proper fashion, and simplifies your work:
if (getCurrentState() == SimulationState::Replay) {
}