comm_thread.h

00001 
00002 /***************************************************************************
00003  *  comm_thread.h - Fawkes RefBox Communication Thread
00004  *
00005  *  Created: Sun Apr 19 13:10:29 2009
00006  *  Copyright  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 #ifndef __PLUGINS_REFBOXCOMM_COMM_THREAD_H_
00024 #define __PLUGINS_REFBOXCOMM_COMM_THREAD_H_
00025 
00026 #include "processor/state_handler.h"
00027 
00028 #include <core/threading/thread.h>
00029 #include <aspect/blocked_timing.h>
00030 #include <aspect/logging.h>
00031 #include <aspect/configurable.h>
00032 #include <aspect/blackboard.h>
00033 #include <aspect/blocked_timing.h>
00034 
00035 namespace fawkes {
00036   class GameStateInterface;
00037   class SwitchInterface;
00038 #ifdef HAVE_SPL
00039   class SoccerPenaltyInterface;
00040 #endif
00041 }
00042 
00043 class RefBoxProcessor;
00044 
00045 class RefBoxCommThread
00046 : public fawkes::Thread,
00047   public fawkes::BlockedTimingAspect,
00048   public fawkes::LoggingAspect,
00049   public fawkes::ConfigurableAspect,
00050   public fawkes::BlackBoardAspect,
00051   public RefBoxStateHandler
00052 {
00053  public:
00054   RefBoxCommThread();
00055 
00056   virtual void init();
00057   virtual void finalize();
00058   virtual void loop();
00059 
00060   // RefBoxStateHandler
00061   virtual void set_gamestate(int game_state,
00062                              fawkes::worldinfo_gamestate_team_t state_team);
00063   virtual void set_score(unsigned int score_cyan, unsigned int score_magenta);
00064   virtual void set_team_goal(fawkes::worldinfo_gamestate_team_t our_team,
00065                              fawkes::worldinfo_gamestate_goalcolor_t goal_color);
00066   virtual void set_half(fawkes::worldinfo_gamestate_half_t half, bool kickoff);
00067   virtual void add_penalty(unsigned int penalty,
00068                            unsigned int seconds_remaining);
00069 
00070   virtual void handle_refbox_state();
00071 
00072  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00073  protected: virtual void run() { Thread::run(); }
00074 
00075  private: /* methods */
00076 
00077  private: /* members */
00078   fawkes::GameStateInterface   *__gamestate_if;
00079 #ifdef HAVE_SPL
00080   fawkes::SoccerPenaltyInterface  *__penalty_if;
00081 #endif
00082   RefBoxProcessor              *__refboxproc;
00083 
00084   bool         __gamestate_modified;
00085   int          __last_gamestate;
00086   fawkes::worldinfo_gamestate_half_t  __last_half;
00087   bool __kickoff;
00088   unsigned int __last_score_cyan;
00089   unsigned int __last_score_magenta;
00090   fawkes::worldinfo_gamestate_team_t __our_team;
00091   fawkes::worldinfo_gamestate_goalcolor_t __our_goal_color;
00092   unsigned int __team_number;
00093   unsigned int __player_number;
00094 
00095   bool __cfg_beep_on_change;
00096   float __cfg_beep_frequency;
00097   float __cfg_beep_duration;
00098   fawkes::SwitchInterface *__beep_if;
00099 };
00100 
00101 
00102 #endif

Generated on Tue Feb 22 13:32:31 2011 for Fawkes API by  doxygen 1.4.7