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