sensor_thread.cpp

00001 
00002 /***************************************************************************
00003  *  sensor_thread.cpp - Pan/tilt plugin sensor thread
00004  *
00005  *  Created: Thu Jun 18 19:01:59 2009
00006  *  Copyright  2006-2009  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #include "sensor_thread.h"
00024 #include "act_thread.h"
00025 
00026 using namespace fawkes;
00027 
00028 /** @class PanTiltSensorThread "sensor_thread.h"
00029  * Katana sensor thread.
00030  * This thread integrates into the Fawkes main loop at the SENSOR hook and
00031  * triggers the act threads to retrieve and write new sensor data.
00032  * @author Tim Niemueller
00033  */
00034 
00035 /** Constructor. */
00036 PanTiltSensorThread::PanTiltSensorThread()
00037   : Thread("PanTiltSensorThread", Thread::OPMODE_WAITFORWAKEUP),
00038     BlockedTimingAspect(BlockedTimingAspect::WAKEUP_HOOK_SENSOR)
00039 {
00040 }
00041 
00042 
00043 /** Add an act thread.
00044  * @param act_thread to add
00045  */
00046 void
00047 PanTiltSensorThread::add_act_thread(PanTiltActThread *act_thread)
00048 {
00049   __act_threads.push_back(act_thread);
00050 }
00051 
00052 
00053 void
00054 PanTiltSensorThread::loop()
00055 {
00056   for (__ati = __act_threads.begin(); __ati != __act_threads.end(); ++__ati) {
00057     try {
00058       (*__ati)->update_sensor_values();
00059     } catch (Exception &e) {
00060       logger->log_warn(name(), "Act thread %s threw an exception when updating sensor values",
00061                        (*__ati)->name());
00062       logger->log_warn(name(), e);
00063     }
00064   }
00065 }

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1