Fawkes API
Fawkes Development Version
sensor_thread.cpp
1
2
/***************************************************************************
3
* sensor_thread.cpp - Pan/tilt plugin sensor thread
4
*
5
* Created: Thu Jun 18 19:01:59 2009
6
* Copyright 2006-2009 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
25
#include "act_thread.h"
26
27
using namespace
fawkes
;
28
29
/** @class PanTiltSensorThread "sensor_thread.h"
30
* Katana sensor thread.
31
* This thread integrates into the Fawkes main loop at the SENSOR hook and
32
* triggers the act threads to retrieve and write new sensor data.
33
* @author Tim Niemueller
34
*/
35
36
/** Constructor. */
37
PanTiltSensorThread::PanTiltSensorThread
()
38
:
Thread
(
"PanTiltSensorThread"
,
Thread
::OPMODE_WAITFORWAKEUP),
39
BlockedTimingAspect
(
BlockedTimingAspect
::WAKEUP_HOOK_SENSOR_ACQUIRE)
40
{
41
}
42
43
/** Add an act thread.
44
* @param act_thread to add
45
*/
46
void
47
PanTiltSensorThread::add_act_thread
(
PanTiltActThread
*act_thread)
48
{
49
act_threads_.push_back(act_thread);
50
}
51
52
void
53
PanTiltSensorThread::loop
()
54
{
55
for
(ati_ = act_threads_.begin(); ati_ != act_threads_.end(); ++ati_) {
56
try
{
57
(*ati_)->update_sensor_values();
58
}
catch
(
Exception
&e) {
59
logger
->
log_warn
(
name
(),
60
"Act thread %s threw an exception when updating sensor values"
,
61
(*ati_)->name());
62
logger
->
log_warn
(
name
(), e);
63
}
64
}
65
}
fawkes::BlockedTimingAspect
Definition:
blocked_timing.h:56
PanTiltSensorThread::add_act_thread
void add_act_thread(PanTiltActThread *act_thread)
Add an act thread.
Definition:
sensor_thread.cpp:47
fawkes::Thread::name
const char * name() const
Definition:
thread.h:100
PanTiltSensorThread::PanTiltSensorThread
PanTiltSensorThread()
Constructor.
Definition:
sensor_thread.cpp:37
fawkes::LoggingAspect::logger
Logger * logger
Definition:
logging.h:53
PanTiltActThread
Definition:
act_thread.h:36
fawkes
fawkes::Logger::log_warn
virtual void log_warn(const char *component, const char *format,...)=0
fawkes::Thread
Definition:
thread.h:45
PanTiltSensorThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
sensor_thread.cpp:53
fawkes::Exception
Definition:
exception.h:41
src
plugins
pantilt
sensor_thread.cpp
Generated by
1.8.17