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 SplPenaltyInterface;
00038 }
00039
00040 class RefBoxProcessor;
00041
00042 class RefBoxCommThread
00043 : public fawkes::Thread,
00044 public fawkes::BlockedTimingAspect,
00045 public fawkes::LoggingAspect,
00046 public fawkes::ConfigurableAspect,
00047 public fawkes::BlackBoardAspect,
00048 public RefBoxStateHandler
00049 {
00050 public:
00051 RefBoxCommThread();
00052
00053 virtual void init();
00054 virtual void finalize();
00055 virtual void loop();
00056
00057
00058 virtual void set_gamestate(int game_state,
00059 fawkes::worldinfo_gamestate_team_t state_team);
00060 virtual void set_score(unsigned int score_cyan, unsigned int score_magenta);
00061 virtual void set_team_goal(fawkes::worldinfo_gamestate_team_t our_team,
00062 fawkes::worldinfo_gamestate_goalcolor_t goal_color);
00063 virtual void set_half(fawkes::worldinfo_gamestate_half_t half, bool kickoff);
00064 virtual void add_penalty(unsigned int penalty,
00065 unsigned int seconds_remaining);
00066
00067 virtual void handle_refbox_state();
00068
00069
00070 protected: virtual void run() { Thread::run(); }
00071
00072 private:
00073
00074 private:
00075 fawkes::GameStateInterface *__gamestate_if;
00076 fawkes::SplPenaltyInterface *__penalty_if;
00077 RefBoxProcessor *__refboxproc;
00078
00079 bool __gamestate_modified;
00080 int __last_gamestate;
00081 fawkes::worldinfo_gamestate_half_t __last_half;
00082 bool __kickoff;
00083 unsigned int __last_score_cyan;
00084 unsigned int __last_score_magenta;
00085 fawkes::worldinfo_gamestate_team_t __our_team;
00086 fawkes::worldinfo_gamestate_goalcolor_t __our_goal_color;
00087 unsigned int __team_number;
00088 unsigned int __player_number;
00089 };
00090
00091
00092 #endif