Fawkes API  Fawkes Development Version
logreplay_bt_thread.cpp
1 
2 /***************************************************************************
3  * logreplay_bt_thread.cpp - BB Log Replay Blocked Timing Thread
4  *
5  * Created: Mon Feb 22 00:09:58 2010
6  * Copyright 2010 Tim Niemueller [www.niemueller.de]
7  * 2010 Masrur Doostdar <doostdar@kbsg.rwth-aachen.de>
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #include "logreplay_bt_thread.h"
25 
26 using namespace fawkes;
27 
28 /** @class BBLogReplayBlockedTimingThread "logreplay_bt_thread.h"
29  * BlackBoard log replay blocked timing thread.
30  * This thread basically does the same task as the BBLogReplayThread, with
31  * the difference that this thread operates in blocked timing mode and
32  * integrates into the Fawkes main loop. It will replay one data set per
33  * loop and will block the loop until the data is ready. This is most useful
34  * to replay sensor logs of sensors, which are integrated into the main loop
35  * and thus influence timing also on the real data system.
36  * @author Masrur Doostdar
37  * @author Tim Niemueller
38  */
39 
40 /** Constructor.
41  * @param hook main loop hook to register for
42  * @param logfile_name filename of the log to be replayed
43  * @param logdir directory containing the logfile
44  * @param scenario ID of the log scenario
45  * @param grace_period time in seconds that desired offset and loop offset may
46  * diverge to still write the new data
47  * @param loop_replay specifies if the replay should be looped
48  * @param non_blocking do not block the main loop if not enough time has elapsed
49  * to replay new data but just wait for the next cycle. This is ignored in
50  * continuous thread mode as it could cause busy waiting.
51  */
54  const char *logfile_name,
55  const char *logdir,
56  const char *scenario,
57  float grace_period,
58  bool loop_replay,
59  bool non_blocking)
60  : BBLogReplayThread(logfile_name, logdir, scenario,
61  grace_period, loop_replay, non_blocking,
62  "BBLogReplayBTThread", Thread::OPMODE_WAITFORWAKEUP),
64 {
65  set_name("BBLogReplayBTThread(%s)", logfile_name);
66  set_prepfin_conc_loop(false);
67 }
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
void set_prepfin_conc_loop(bool concurrent=true)
Set concurrent execution of prepare_finalize() and loop().
Definition: thread.cpp:727
Thread aspect to use blocked timing.
BBLogReplayBlockedTimingThread(fawkes::BlockedTimingAspect::WakeupHook hook, const char *logfile_name, const char *logdir, const char *scenario, float grace_period, bool loop_replay, bool non_blocking)
Constructor.
void set_name(const char *format,...)
Set name of thread.
Definition: thread.cpp:761
WakeupHook
Type to define at which hook the thread is woken up.
BlackBoard log Replay thread.