Fawkes API  Fawkes Development Version
 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 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_SPL_H_
24 #define __TOOLS_REFBOXREP_SPL_H_
25 
26 #include "refbox_state_sender.h"
27 #include <cstdlib>
28 #include <stdint.h>
29 #include <map>
30 
31 namespace fawkes {
32  class DatagramSocket;
33 }
34 
35 #define GCHS 4
36 #define MAX_NUM_PLAYERS 11
37 #pragma pack(push,4)
38 /** SPL RefBox protocol robot info struct. */
39 typedef struct {
40  uint16_t penalty; /**< penalty state of the player */
41  uint16_t secs_till_unpenalized; /**< estimate of time till unpenalised */
43 
44 /** SPL RefBox protocol team info struct. */
45 typedef struct {
46  uint8_t team_number; /**< unique team number */
47  uint8_t team_color; /**< colour of the team */
48  uint16_t score; /**< team's score */
49  spl_robotinfo_t players[MAX_NUM_PLAYERS]; /**< the team's players */
51 
52 /** SPL RefBox protocol game control struct. */
53 typedef struct {
54  char header[GCHS]; /**< header to identify the structure */
55  uint32_t version; /**< version of the data structure */
56  uint8_t players_per_team; /**< The number of players on a team */
57  uint8_t state; /**< state of the game (STATE_READY, STATE_PLAYING, etc) */
58  uint8_t first_half; /**< 1 = game in first half, 0 otherwise */
59  uint8_t kick_off_team; /**< the next team to kick off */
60  uint8_t secondary_state; /**< Extra state information - (STATE2_NORMAL, STATE2_PENALTYSHOOT, etc) */
61  uint8_t drop_in_team; /**< team that caused last drop in */
62  uint16_t drop_on_time; /**< number of seconds passed since the last drop in. -1 before first dropin */
63  uint32_t secs_remaining; /**< estimate of number of seconds remaining in the half */
64  spl_teaminfo_t teams[2]; /**< Info about the teams */
66 #pragma pack(pop)
67 
69 {
70  public:
72  const char *broadcast_ip, unsigned short int broadcast_port,
76 
77  void run();
78 
79  private:
80 
81 
82  void process_struct(spl_gamecontrol_t *msg);
83 
84  private:
85  RefBoxStateSender &__rss;
87 
88  bool __quit;
89  std::map<unsigned int, unsigned int> __penalties;
90 
93 };
94 
95 #endif
SPL league refbox repeater.
Definition: spl.h:68
SPL RefBox protocol team info struct.
Definition: spl.h:50
RefBox repeater state sender.
SPL RefBox protocol robot info struct.
Definition: spl.h:44
Datagram socket.
Definition: datagram.h:31
SplRefBoxRepeater(RefBoxStateSender &rss, const char *broadcast_ip, unsigned short int broadcast_port, fawkes::worldinfo_gamestate_team_t our_team, fawkes::worldinfo_gamestate_goalcolor_t our_goal)
Constructor.
Definition: spl.cpp:76
uint16_t drop_on_time
number of seconds passed since the last drop in.
Definition: spl.h:62
~SplRefBoxRepeater()
Destructor.
Definition: spl.cpp:96
SPL RefBox protocol game control struct.
Definition: spl.h:63
void run()
Run.
Definition: spl.cpp:155
worldinfo_gamestate_team_t
Team.
Definition: enums.h:54
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:63
uint16_t score
team's score
Definition: spl.h:48