Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
refbox_state_sender.h
1
2
/***************************************************************************
3
* refbox_state_sender.h - Fawkes RefBox state sender
4
*
5
* Created: Wed Apr 09 09:56:57 2008
6
* Copyright 2008 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 __TOOLS_REFBOXREP_REFBOX_STATE_SENDER_H_
24
#define __TOOLS_REFBOXREP_REFBOX_STATE_SENDER_H_
25
26
#include <core/threading/thread.h>
27
#include <netcomm/worldinfo/enums.h>
28
#include <map>
29
30
namespace
fawkes {
31
class
WorldInfoTransceiver;
32
}
33
34
class
RefBoxStateSender
35
{
36
public
:
37
RefBoxStateSender
(
const
char
*addr,
unsigned
short
port,
38
const
char
*key,
const
char
*iv,
39
bool
debug =
false
);
40
virtual
~RefBoxStateSender
();
41
42
virtual
void
send
();
43
virtual
void
set_gamestate
(
int
game_state,
44
fawkes::worldinfo_gamestate_team_t
state_team);
45
virtual
void
set_score
(
unsigned
int
score_cyan,
unsigned
int
score_magenta);
46
virtual
void
set_team_goal
(
fawkes::worldinfo_gamestate_team_t
our_team,
47
fawkes::worldinfo_gamestate_goalcolor_t
goal_color);
48
virtual
void
set_half
(
fawkes::worldinfo_gamestate_half_t
half);
49
virtual
void
add_penalty
(
unsigned
int
player,
unsigned
int
penalty,
50
unsigned
int
seconds_remaining);
51
52
class
TimeoutThread
:
public
fawkes::Thread
53
{
54
public
:
55
TimeoutThread
(
RefBoxStateSender
*rss);
56
virtual
~TimeoutThread
();
57
virtual
void
loop
();
58
private
:
59
unsigned
int
__timeout_usec;
60
RefBoxStateSender
*__rss;
61
};
62
63
protected
:
64
RefBoxStateSender
();
65
66
private
:
67
void
execute_send();
68
69
private
:
70
bool
__debug;
71
fawkes::WorldInfoTransceiver
*__transceiver;
72
TimeoutThread
*__timeout_thread;
73
74
int
__game_state;
75
fawkes::worldinfo_gamestate_team_t
__state_team;
76
unsigned
int
__score_cyan;
77
unsigned
int
__score_magenta;
78
fawkes::worldinfo_gamestate_team_t
__our_team;
79
fawkes::worldinfo_gamestate_goalcolor_t
__our_goal_color;
80
fawkes::worldinfo_gamestate_half_t
__half;
81
82
/// @cond INTERNALS
83
typedef
struct
{
84
unsigned
int
player;
85
unsigned
int
penalty;
86
unsigned
int
seconds_remaining;
87
} rss_penalty_t;
88
/// @endcond
89
std::map<unsigned int, rss_penalty_t> __penalties;
90
std::map<unsigned int, rss_penalty_t>::iterator __pit;
91
92
};
93
94
#endif
src
tools
refboxrep
refbox_state_sender.h
Generated by
1.8.3.1