Fawkes API  Fawkes Development Version
comm_thread.h
1 
2 /***************************************************************************
3  * comm_thread.h - Fawkes RefBox Communication Thread
4  *
5  * Created: Sun Apr 19 13:10:29 2009
6  * Copyright 2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_REFBOXCOMM_COMM_THREAD_H_
24 #define _PLUGINS_REFBOXCOMM_COMM_THREAD_H_
25 
26 #include "processor/state_handler.h"
27 
28 #include <aspect/blackboard.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/configurable.h>
31 #include <aspect/logging.h>
32 #include <core/threading/thread.h>
33 
34 namespace fawkes {
35 class GameStateInterface;
36 class SwitchInterface;
37 #ifdef HAVE_SPL
38 class SoccerPenaltyInterface;
39 #endif
40 } // namespace fawkes
41 
42 class RefBoxProcessor;
43 
46  public fawkes::LoggingAspect,
49  public RefBoxStateHandler
50 {
51 public:
53 
54  virtual void init();
55  virtual void finalize();
56  virtual void loop();
57 
58  // RefBoxStateHandler
59  virtual void set_gamestate(int game_state, fawkes::worldinfo_gamestate_team_t state_team);
60  virtual void set_score(unsigned int score_cyan, unsigned int score_magenta);
63  virtual void set_half(fawkes::worldinfo_gamestate_half_t half, bool kickoff);
64  virtual void add_penalty(unsigned int penalty, unsigned int seconds_remaining);
65 
66  virtual void handle_refbox_state();
67 
68  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
69 protected:
70  virtual void
71  run()
72  {
73  Thread::run();
74  }
75 
76 private: /* methods */
77 private: /* members */
78  fawkes::GameStateInterface *gamestate_if_;
79 #ifdef HAVE_SPL
80  fawkes::SoccerPenaltyInterface *penalty_if_;
81 #endif
82  RefBoxProcessor *refboxproc_;
83 
84  bool gamestate_modified_;
85  int last_gamestate_;
87  bool kickoff_;
88  unsigned int last_score_cyan_;
89  unsigned int last_score_magenta_;
92  unsigned int team_number_;
93  unsigned int player_number_;
94 
95  bool cfg_beep_on_change_;
96  float cfg_beep_frequency_;
97  float cfg_beep_duration_;
98  fawkes::SwitchInterface *beep_if_;
99 };
100 
101 #endif
fawkes::SwitchInterface
Definition: SwitchInterface.h:39
RefBoxCommThread::set_gamestate
virtual void set_gamestate(int game_state, fawkes::worldinfo_gamestate_team_t state_team)
Definition: comm_thread.cpp:212
fawkes::GameStateInterface
Definition: GameStateInterface.h:39
RefBoxCommThread
Definition: comm_thread.h:44
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:56
RefBoxCommThread::loop
virtual void loop()
Code to execute in the thread.
Definition: comm_thread.cpp:159
RefBoxCommThread::add_penalty
virtual void add_penalty(unsigned int penalty, unsigned int seconds_remaining)
Definition: comm_thread.cpp:301
RefBoxCommThread::RefBoxCommThread
RefBoxCommThread()
Constructor.
Definition: comm_thread.cpp:51
RefBoxCommThread::finalize
virtual void finalize()
Finalize the thread.
Definition: comm_thread.cpp:148
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
fawkes::worldinfo_gamestate_goalcolor_t
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:67
RefBoxCommThread::set_team_goal
virtual void set_team_goal(fawkes::worldinfo_gamestate_team_t our_team, fawkes::worldinfo_gamestate_goalcolor_t goal_color)
Definition: comm_thread.cpp:247
RefBoxProcessor
Definition: processor.h:28
fawkes::worldinfo_gamestate_team_t
worldinfo_gamestate_team_t
Team.
Definition: enums.h:59
RefBoxCommThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: comm_thread.h:71
RefBoxCommThread::set_score
virtual void set_score(unsigned int score_cyan, unsigned int score_magenta)
Definition: comm_thread.cpp:233
RefBoxCommThread::init
virtual void init()
Initialize the thread.
Definition: comm_thread.cpp:59
fawkes::Thread
Definition: thread.h:45
fawkes::worldinfo_gamestate_half_t
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:73
RefBoxCommThread::set_half
virtual void set_half(fawkes::worldinfo_gamestate_half_t half, bool kickoff)
Definition: comm_thread.cpp:276
fawkes::ConfigurableAspect
Definition: configurable.h:38
fawkes::SoccerPenaltyInterface
Definition: SoccerPenaltyInterface.h:39
RefBoxStateHandler
Definition: state_handler.h:28
RefBoxCommThread::handle_refbox_state
virtual void handle_refbox_state()
Definition: comm_thread.cpp:317