Fawkes API  Fawkes Development Version
led_thread.h
00001 
00002 /***************************************************************************
00003  *  led_thread.h - Provide NaoQi LEDs to Fawkes
00004  *
00005  *  Created: Thu Jun 30 19:49:00 2011
00006  *  Copyright  2006-2011  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 #ifndef __PLUGINS_NAO_LED_THREAD_H_
00024 #define __PLUGINS_NAO_LED_THREAD_H_
00025 
00026 #include <core/threading/thread.h>
00027 #include <aspect/logging.h>
00028 #include <aspect/configurable.h>
00029 #include <aspect/blackboard.h>
00030 #include <aspect/blocked_timing.h>
00031 #include <plugins/nao/aspect/naoqi.h>
00032 #include <blackboard/interface_listener.h>
00033 
00034 #include <core/utils/lock_multimap.h>
00035 #include <string>
00036 #include <utility>
00037 
00038 namespace fawkes {
00039   class LedInterface;
00040 }
00041 namespace AL {
00042   class ALMemoryFastAccess;
00043 }
00044 
00045 class NaoQiLedThread
00046 : public fawkes::Thread,
00047   public fawkes::LoggingAspect,
00048   public fawkes::BlockedTimingAspect,
00049   public fawkes::BlackBoardAspect,
00050   public fawkes::ConfigurableAspect,
00051   public fawkes::NaoQiAspect,
00052   public fawkes::BlackBoardInterfaceListener
00053 {
00054  public:
00055   NaoQiLedThread();
00056   virtual ~NaoQiLedThread();
00057 
00058   virtual void init();
00059   virtual void loop();
00060   virtual void finalize();
00061 
00062  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00063  protected: virtual void run() { Thread::run(); }
00064 
00065  protected:
00066   bool bb_interface_message_received(fawkes::Interface *interface,
00067                                      fawkes::Message *message) throw();
00068 
00069  private:
00070   AL::ALPtr<AL::DCMProxy>           __dcm;
00071   AL::ALPtr<AL::ALMemoryProxy>      __almem;
00072   AL::ALPtr<AL::ALMemoryFastAccess> __memfa;
00073 
00074   std::vector<float> __values;
00075 
00076   typedef std::multimap<fawkes::LedInterface *, unsigned int> LedMemMap;
00077   LedMemMap  __memids;
00078 
00079   typedef fawkes::LockMultiMap<fawkes::LedInterface *, std::string> LedMap;
00080   LedMap  __leds;
00081 
00082   bool        __cfg_verbose_face;
00083   std::string __subd_prefix;
00084 };
00085 
00086 #endif