Fawkes API
Fawkes Development Version
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 "enums.h"
28
#include "processor.h"
29
30
#include <cstdlib>
31
#include <map>
32
#include <memory>
33
#include <stdint.h>
34
35
namespace
fawkes
{
36
class
Logger;
37
class
DatagramSocket;
38
}
// namespace fawkes
39
40
#define SPL_HEADER_SIZE 4
41
#define SPL_MAX_NUM_PLAYERS 11
42
43
#pragma pack(push, 4)
44
/** SPL RefBox protocol robot info struct. */
45
typedef
struct
46
{
47
uint16_t penalty;
/**< penalty state of the player */
48
uint16_t secs_till_unpenalized;
/**< estimate of time till unpenalised */
49
}
spl_robotinfo_t
;
50
51
/** SPL RefBox protocol team info struct. */
52
typedef
struct
53
{
54
uint8_t team_number;
/**< unique team number */
55
uint8_t team_color;
/**< colour of the team */
56
#ifdef USE_SPL_GC6
57
uint16_t score;
/**< team's score */
58
#else
59
uint8_t goal_color;
/**< colour of the goal */
60
uint8_t score;
/**< team's score */
61
#endif
62
spl_robotinfo_t
players[SPL_MAX_NUM_PLAYERS];
/**< the team's players */
63
}
spl_teaminfo_t
;
64
65
/** SPL RefBox protocol game control struct. */
66
typedef
struct
67
{
68
char
header[SPL_HEADER_SIZE];
/**< header to identify the structure */
69
uint32_t version;
/**< version of the data structure */
70
uint8_t players_per_team;
/**< The number of players on a team */
71
uint8_t state;
/**< state of the game (STATE_READY, STATE_PLAYING, etc.) */
72
uint8_t first_half;
/**< 1 = game in first half, 0 otherwise */
73
uint8_t kick_off_team;
/**< the next team to kick off */
74
uint8_t
75
secondary_state;
/**< Extra state information - (STATE2_NORMAL, STATE2_PENALTYSHOOT, etc) */
76
uint8_t drop_in_team;
/**< team that caused last drop in */
77
uint16_t
78
drop_in_time;
/**< number of seconds passed since the last drop in. -1 before first dropin */
79
uint32_t secs_remaining;
/**< estimate of number of seconds remaining in the half */
80
spl_teaminfo_t
teams[2];
/**< Info about the teams */
81
}
spl_gamecontrol_t
;
82
#pragma pack(pop)
83
84
class
SplRefBoxProcessor
:
public
RefBoxProcessor
85
{
86
public
:
87
SplRefBoxProcessor
(
fawkes::Logger
* logger,
88
unsigned
short
int
broadcast_port,
89
unsigned
int
team_number,
90
unsigned
int
player_number);
91
~SplRefBoxProcessor
();
92
93
void
run
();
94
95
bool
check_connection
();
96
void
refbox_process
();
97
98
private
:
99
void
process_struct(
spl_gamecontrol_t
*msg);
100
101
private
:
102
std::shared_ptr<fawkes::DatagramSocket> s_;
103
fawkes::Logger
* logger_;
104
105
bool
quit_;
106
107
uint16_t penalty_;
108
uint8_t team_number_;
109
uint8_t player_number_;
110
};
111
112
#endif
spl_teaminfo_t
SPL RefBox protocol team info struct.
Definition:
spl.h:51
SplRefBoxProcessor::refbox_process
void refbox_process()
Definition:
spl.cpp:216
SplRefBoxProcessor
Definition:
spl.h:83
SplRefBoxProcessor::SplRefBoxProcessor
SplRefBoxProcessor(fawkes::Logger *logger, unsigned short int broadcast_port, unsigned int team_number, unsigned int player_number)
Constructor.
Definition:
spl.cpp:113
SplRefBoxProcessor::check_connection
bool check_connection()
Definition:
spl.cpp:236
fawkes::Logger
Definition:
logger.h:40
fawkes
RefBoxProcessor
Definition:
processor.h:27
SplRefBoxProcessor::~SplRefBoxProcessor
~SplRefBoxProcessor()
Destructor.
Definition:
spl.cpp:129
spl_gamecontrol_t
SPL RefBox protocol game control struct.
Definition:
spl.h:65
spl_robotinfo_t
SPL RefBox protocol robot info struct.
Definition:
spl.h:44
SplRefBoxProcessor::run
void run()
Run.
Definition:
spl.cpp:245
src
plugins
refboxcomm
processor
spl.h
Generated by
1.8.16