00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __TOOLS_REFBOXREP_SPL_H_
00024 #define __TOOLS_REFBOXREP_SPL_H_
00025
00026 #include "refbox_state_sender.h"
00027 #include <cstdlib>
00028 #include <stdint.h>
00029 #include <map>
00030
00031 namespace fawkes {
00032 class DatagramSocket;
00033 }
00034
00035 #define GCHS 4
00036 #define MAX_NUM_PLAYERS 11
00037 #pragma pack(push,4)
00038
00039 typedef struct {
00040 uint16_t penalty;
00041 uint16_t secs_till_unpenalized;
00042 } spl_robotinfo_t;
00043
00044
00045 typedef struct {
00046 uint8_t team_number;
00047 uint8_t team_color;
00048 uint16_t score;
00049 spl_robotinfo_t players[MAX_NUM_PLAYERS];
00050 } spl_teaminfo_t;
00051
00052
00053 typedef struct {
00054 char header[GCHS];
00055 uint32_t version;
00056 uint8_t players_per_team;
00057 uint8_t state;
00058 uint8_t first_half;
00059 uint8_t kick_off_team;
00060 uint8_t secondary_state;
00061 uint8_t drop_in_team;
00062 uint16_t drop_on_time;
00063 uint32_t secs_remaining;
00064 spl_teaminfo_t teams[2];
00065 } spl_gamecontrol_t;
00066 #pragma pack(pop)
00067
00068 class SplRefBoxRepeater
00069 {
00070 public:
00071 SplRefBoxRepeater(RefBoxStateSender &rss,
00072 const char *broadcast_ip, unsigned short int broadcast_port,
00073 fawkes::worldinfo_gamestate_team_t our_team,
00074 fawkes::worldinfo_gamestate_goalcolor_t our_goal);
00075 ~SplRefBoxRepeater();
00076
00077 void run();
00078
00079 private:
00080
00081
00082 void process_struct(spl_gamecontrol_t *msg);
00083
00084 private:
00085 RefBoxStateSender &__rss;
00086 fawkes::DatagramSocket *__s;
00087
00088 bool __quit;
00089 std::map<unsigned int, unsigned int> __penalties;
00090
00091 fawkes::worldinfo_gamestate_team_t __our_team;
00092 fawkes::worldinfo_gamestate_goalcolor_t __our_goal;
00093 };
00094
00095 #endif