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
34namespace fawkes {
35class GameStateInterface;
36class SwitchInterface;
37#ifdef HAVE_SPL
38class SoccerPenaltyInterface;
39#endif
40} // namespace fawkes
41
42class RefBoxProcessor;
43
50{
51public:
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() */
69protected:
70 virtual void
72 {
73 Thread::run();
74 }
75
76private: /* methods */
77private: /* members */
78 fawkes::GameStateInterface *gamestate_if_;
79#ifdef HAVE_SPL
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_;
99};
100
101#endif
Referee Box Communication Thread for robotic soccer.
Definition: comm_thread.h:50
virtual void add_penalty(unsigned int penalty, unsigned int seconds_remaining)
Add penalty.
virtual void set_score(unsigned int score_cyan, unsigned int score_magenta)
Set score.
virtual void handle_refbox_state()
Process the information set up to now.
virtual void set_gamestate(int game_state, fawkes::worldinfo_gamestate_team_t state_team)
Set current game state.
virtual void set_team_goal(fawkes::worldinfo_gamestate_team_t our_team, fawkes::worldinfo_gamestate_goalcolor_t goal_color)
Set team and goal info.
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: comm_thread.h:71
RefBoxCommThread()
Constructor.
Definition: comm_thread.cpp:51
virtual void set_half(fawkes::worldinfo_gamestate_half_t half, bool kickoff)
Set current half of the game time.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
Definition: comm_thread.cpp:59
virtual void finalize()
Finalize the thread.
Referee Box Communication Processor.
Definition: processor.h:29
Referee Box state handler for RefBoxProcessor.
Definition: state_handler.h:29
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect to access configuration data.
Definition: configurable.h:33
GameStateInterface Fawkes BlackBoard Interface.
Thread aspect to log output.
Definition: logging.h:33
SoccerPenaltyInterface Fawkes BlackBoard Interface.
SwitchInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:46
Fawkes library namespace.
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:61
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:67
worldinfo_gamestate_team_t
Team.
Definition: enums.h:53