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 SPL_HEADER_SIZE 4
00040 #define SPL_MAX_NUM_PLAYERS 11
00041
00042 #pragma pack(push,4)
00043
00044 typedef struct {
00045 uint16_t penalty;
00046 uint16_t secs_till_unpenalized;
00047 } spl_robotinfo_t;
00048
00049
00050 typedef struct {
00051 uint8_t team_number;
00052 uint8_t team_color;
00053 #ifdef USE_SPL_GC6
00054 uint16_t score;
00055 #else
00056 uint8_t goal_color;
00057 uint8_t score;
00058 #endif
00059 spl_robotinfo_t players[SPL_MAX_NUM_PLAYERS];
00060 } spl_teaminfo_t;
00061
00062
00063 typedef struct {
00064 char header[SPL_HEADER_SIZE];
00065 uint32_t version;
00066 uint8_t players_per_team;
00067 uint8_t state;
00068 uint8_t first_half;
00069 uint8_t kick_off_team;
00070 uint8_t secondary_state;
00071 uint8_t drop_in_team;
00072 uint16_t drop_in_time;
00073 uint32_t secs_remaining;
00074 spl_teaminfo_t teams[2];
00075 } spl_gamecontrol_t;
00076 #pragma pack(pop)
00077
00078 class SplRefBoxProcessor : public RefBoxProcessor
00079 {
00080 public:
00081 SplRefBoxProcessor(fawkes::Logger *logger, unsigned short int broadcast_port,
00082 unsigned int team_number, unsigned int player_number);
00083 ~SplRefBoxProcessor();
00084
00085 void run();
00086
00087 bool check_connection();
00088 void refbox_process();
00089
00090 private:
00091 void process_struct(spl_gamecontrol_t *msg);
00092
00093 private:
00094 fawkes::DatagramSocket *__s;
00095 fawkes::Logger *__logger;
00096
00097 bool __quit;
00098
00099 uint16_t __penalty;
00100 uint8_t __team_number;
00101 uint8_t __player_number;
00102 };
00103
00104 #endif