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 <core/threading/thread.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <aspect/blackboard.h>
33 #include <aspect/blocked_timing.h>
34 
35 namespace fawkes {
36  class GameStateInterface;
37  class SwitchInterface;
38 #ifdef HAVE_SPL
39  class SoccerPenaltyInterface;
40 #endif
41 }
42 
43 class RefBoxProcessor;
44 
46 : public fawkes::Thread,
48  public fawkes::LoggingAspect,
51  public RefBoxStateHandler
52 {
53  public:
55 
56  virtual void init();
57  virtual void finalize();
58  virtual void loop();
59 
60  // RefBoxStateHandler
61  virtual void set_gamestate(int game_state,
63  virtual void set_score(unsigned int score_cyan, unsigned int score_magenta);
64  virtual void set_team_goal(fawkes::worldinfo_gamestate_team_t our_team,
66  virtual void set_half(fawkes::worldinfo_gamestate_half_t half, bool kickoff);
67  virtual void add_penalty(unsigned int penalty,
68  unsigned int seconds_remaining);
69 
70  virtual void handle_refbox_state();
71 
72  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
73  protected: virtual void run() { Thread::run(); }
74 
75  private: /* methods */
76 
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 
102 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Referee Box Communication Thread for robotic soccer.
Definition: comm_thread.h:45
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: comm_thread.h:73
Thread class encapsulation of pthreads.
Definition: thread.h:42
SoccerPenaltyInterface Fawkes BlackBoard Interface.
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:70
Thread aspect to use blocked timing.
SwitchInterface Fawkes BlackBoard Interface.
Thread aspect to log output.
Definition: logging.h:35
Referee Box Communication Processor.
Definition: processor.h:28
Thread aspect to access configuration data.
Definition: configurable.h:35
Referee Box state handler for RefBoxProcessor.
Definition: state_handler.h:28
worldinfo_gamestate_team_t
Team.
Definition: enums.h:54
GameStateInterface Fawkes BlackBoard Interface.
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:63