Fawkes API Fawkes Development Version
test_plugin.cpp
1/***************************************************************************
2 * test_plugin.cpp - SyncPoint Test plugin
3 *
4 * Created: Wed Mar 04 17:57:42 2015
5 * Copyright 2015 Till Hofmann
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#include "test_thread.h"
22
23#include <aspect/blocked_timing.h>
24#include <core/plugin.h>
25
26#include <algorithm>
27#include <vector>
28
29using namespace fawkes;
30
31/** Plugin to test syncpoints
32 * @author Till Hofmann
33 */
35{
36public:
37 /** Constructor.
38 * @param config Fawkes configuration
39 */
41 {
42 std::vector<BlockedTimingAspect::WakeupHook> hooks;
43 hooks = {
44 BlockedTimingAspect::WAKEUP_HOOK_PRE_LOOP, /**< before each loop */
45 BlockedTimingAspect::WAKEUP_HOOK_SENSOR_ACQUIRE, /**< sensor acquisition thread,
46 * acquire data from sensor */
47 BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PREPARE, /**< sensor data preparation thread,
48 * convert acquired data to usable format */
49 BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PROCESS, /**< sensor data processing thread */
50 BlockedTimingAspect::WAKEUP_HOOK_WORLDSTATE, /**< world state thread */
51 BlockedTimingAspect::WAKEUP_HOOK_THINK, /**< think thread (agent) */
52 BlockedTimingAspect::WAKEUP_HOOK_SKILL, /**< skill thread (skill module) */
53 BlockedTimingAspect::WAKEUP_HOOK_ACT, /**< act thread (motor module etc.) */
54 BlockedTimingAspect::WAKEUP_HOOK_ACT_EXEC, /**< act execution thread */
55 BlockedTimingAspect::WAKEUP_HOOK_POST_LOOP /**< run after loop */
56 };
57
58 for (std::vector<BlockedTimingAspect::WakeupHook>::iterator it = hooks.begin();
59 it != hooks.end();
60 ++it) {
61 std::string name = "SyncPointTestThread-";
62 std::string hook_name = BlockedTimingAspect::blocked_timing_hook_to_string(*it);
63 std::transform(hook_name.begin(), hook_name.end(), hook_name.begin(), ::tolower);
64 name.append(hook_name);
66 }
67 }
68};
69
70PLUGIN_DESCRIPTION("Test SyncPoints and BlockedTimingAspect")
71EXPORT_PLUGIN(SyncPointTestPlugin)
Plugin to test syncpoints.
Definition: test_plugin.cpp:35
SyncPointTestPlugin(Configuration *config)
Constructor.
Definition: test_plugin.cpp:40
Thread to test SyncPoints.
Definition: test_thread.h:31
Interface for configuration handling.
Definition: config.h:68
Plugin interface class.
Definition: plugin.h:34
ThreadList thread_list
Thread list member.
Definition: plugin.h:53
Configuration * config
Fawkes configuration.
Definition: plugin.h:58
const char * name() const
Get the name of the plugin.
Definition: plugin.cpp:142
void push_back(Thread *thread)
Add thread to the end.
Fawkes library namespace.