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
spl.h
1
2
/***************************************************************************
3
* spl.h - Fawkes SPL refbox repeater
4
*
5
* Created: Tue Jul 08 13:46:19 2008
6
* Copyright 2008-2010 Tim Niemueller [www.niemueller.de]
7
* 2009 Tobias Kellner
8
*
9
****************************************************************************/
10
11
/* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL file in the doc directory.
22
*/
23
24
#ifndef __TOOLS_REFBOXREP_SPL_H_
25
#define __TOOLS_REFBOXREP_SPL_H_
26
27
#include "processor.h"
28
#include <netcomm/worldinfo/enums.h>
29
30
#include <cstdlib>
31
#include <stdint.h>
32
#include <map>
33
34
namespace
fawkes {
35
class
Logger;
36
class
DatagramSocket;
37
}
38
39
#define SPL_HEADER_SIZE 4
40
#define SPL_MAX_NUM_PLAYERS 11
41
42
#pragma pack(push,4)
43
/** SPL RefBox protocol robot info struct. */
44
typedef
struct
{
45
uint16_t
penalty
;
/**< penalty state of the player */
46
uint16_t
secs_till_unpenalized
;
/**< estimate of time till unpenalised */
47
}
spl_robotinfo_t
;
48
49
/** SPL RefBox protocol team info struct. */
50
typedef
struct
{
51
uint8_t
team_number
;
/**< unique team number */
52
uint8_t
team_color
;
/**< colour of the team */
53
#ifdef USE_SPL_GC6
54
uint16_t score;
/**< team's score */
55
#else
56
uint8_t
goal_color
;
/**< colour of the goal */
57
uint8_t
score
;
/**< team's score */
58
#endif
59
spl_robotinfo_t
players[SPL_MAX_NUM_PLAYERS];
/**< the team's players */
60
}
spl_teaminfo_t
;
61
62
/** SPL RefBox protocol game control struct. */
63
typedef
struct
{
64
char
header[SPL_HEADER_SIZE];
/**< header to identify the structure */
65
uint32_t
version
;
/**< version of the data structure */
66
uint8_t
players_per_team
;
/**< The number of players on a team */
67
uint8_t
state
;
/**< state of the game (STATE_READY, STATE_PLAYING, etc.) */
68
uint8_t
first_half
;
/**< 1 = game in first half, 0 otherwise */
69
uint8_t
kick_off_team
;
/**< the next team to kick off */
70
uint8_t
secondary_state
;
/**< Extra state information - (STATE2_NORMAL, STATE2_PENALTYSHOOT, etc) */
71
uint8_t
drop_in_team
;
/**< team that caused last drop in */
72
uint16_t
drop_in_time
;
/**< number of seconds passed since the last drop in. -1 before first dropin */
73
uint32_t
secs_remaining
;
/**< estimate of number of seconds remaining in the half */
74
spl_teaminfo_t
teams[2];
/**< Info about the teams */
75
}
spl_gamecontrol_t
;
76
#pragma pack(pop)
77
78
class
SplRefBoxProcessor
:
public
RefBoxProcessor
79
{
80
public
:
81
SplRefBoxProcessor
(
fawkes::Logger
*logger,
unsigned
short
int
broadcast_port,
82
unsigned
int
team_number,
unsigned
int
player_number);
83
~SplRefBoxProcessor
();
84
85
void
run
();
86
87
bool
check_connection
();
88
void
refbox_process
();
89
90
private
:
91
void
process_struct(
spl_gamecontrol_t
*msg);
92
93
private
:
94
fawkes::DatagramSocket
*__s;
95
fawkes::Logger
*__logger;
96
97
bool
__quit;
98
99
uint16_t __penalty;
100
uint8_t __team_number;
101
uint8_t __player_number;
102
};
103
104
#endif
src
plugins
refboxcomm
processor
spl.h
Generated by
1.8.3.1