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 
29 using namespace fawkes;
30 
31 /** Plugin to test syncpoints
32  * @author Till Hofmann
33  */
35 {
36 public:
37  /** Constructor.
38  * @param config Fawkes configuration
39  */
40  explicit SyncPointTestPlugin(Configuration *config) : Plugin(config)
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);
65  thread_list.push_back(new SyncPointTestThread(name.c_str(), *it));
66  }
67  }
68 };
69 
70 PLUGIN_DESCRIPTION("Test SyncPoints and BlockedTimingAspect")
71 EXPORT_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
@ WAKEUP_HOOK_SENSOR_ACQUIRE
sensor acquisition thread, acquire data from sensor
@ WAKEUP_HOOK_ACT
act thread (motor module etc.)
@ WAKEUP_HOOK_WORLDSTATE
world state thread
@ WAKEUP_HOOK_PRE_LOOP
before each loop
@ WAKEUP_HOOK_SENSOR_PREPARE
sensor data preparation thread, convert acquired data to usable format
@ WAKEUP_HOOK_THINK
think thread (agent)
@ WAKEUP_HOOK_POST_LOOP
run after loop
@ WAKEUP_HOOK_SKILL
skill thread (skill module)
@ WAKEUP_HOOK_SENSOR_PROCESS
sensor data processing thread
@ WAKEUP_HOOK_ACT_EXEC
act execution thread
static const char * blocked_timing_hook_to_string(WakeupHook hook)
Get string for wakeup hook.
Interface for configuration handling.
Definition: config.h:65
Plugin interface class.
Definition: plugin.h:34
Fawkes library namespace.