comm_thread.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
00073 protected: virtual void run() { Thread::run(); }
00074
00075 private:
00076
00077 private:
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