Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
sensor_thread.cpp
1
2
/***************************************************************************
3
* sensor_thread.cpp - Joystick thread that pushes data into the interface
4
*
5
* Created: Sat Nov 22 18:05:55 2008
6
* Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "sensor_thread.h"
24
#include "acquisition_thread.h"
25
26
#include <interfaces/JoystickInterface.h>
27
28
using namespace
fawkes;
29
30
/** @class JoystickSensorThread "sensor_thread.h"
31
* Joystick sensor thread.
32
* This thread integrates into the Fawkes main loop at the sensor hook and
33
* publishes new data when available from the JoystickAcquisitionThread.
34
* @author Tim Niemueller
35
*/
36
37
38
/** Constructor.
39
* @param aqt JoystickAcquisitionThread to get data from
40
*/
41
JoystickSensorThread::JoystickSensorThread
(
JoystickAcquisitionThread
*aqt)
42
:
Thread
(
"JoystickSensorThread"
,
Thread
::OPMODE_WAITFORWAKEUP),
43
BlockedTimingAspect
(
BlockedTimingAspect
::WAKEUP_HOOK_SENSOR_ACQUIRE)
44
{
45
__aqt = aqt;
46
}
47
48
49
void
50
JoystickSensorThread::init
()
51
{
52
__joystick_if =
blackboard
->
open_for_writing
<
JoystickInterface
>(
"Joystick"
);
53
}
54
55
56
void
57
JoystickSensorThread::finalize
()
58
{
59
blackboard
->
close
(__joystick_if);
60
}
61
62
63
void
64
JoystickSensorThread::loop
()
65
{
66
if
( __aqt->
lock_if_new_data
() ) {
67
__joystick_if->
set_num_axes
( __aqt->
num_axes
() );
68
__joystick_if->
set_num_buttons
( __aqt->
num_buttons
() );
69
__joystick_if->
set_pressed_buttons
( __aqt->
pressed_buttons
() );
70
__joystick_if->
set_axis
( __aqt->
axis_values
() );
71
__joystick_if->
write
();
72
__aqt->
unlock
();
73
}
74
}
src
plugins
joystick
sensor_thread.cpp
Generated by
1.8.3.1