Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * GameStateInterface.h - Fawkes BlackBoard Interface - GameStateInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2008 Tim Niemueller 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __INTERFACES_GAMESTATEINTERFACE_H_ 00025 #define __INTERFACES_GAMESTATEINTERFACE_H_ 00026 00027 #include <interface/interface.h> 00028 #include <interface/message.h> 00029 #include <interface/field_iterator.h> 00030 00031 namespace fawkes { 00032 00033 class GameStateInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(GameStateInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 static const uint32_t GS_FROZEN; 00041 static const uint32_t GS_PLAY; 00042 static const uint32_t GS_KICK_OFF; 00043 static const uint32_t GS_DROP_BALL; 00044 static const uint32_t GS_PENALTY; 00045 static const uint32_t GS_CORNER_KICK; 00046 static const uint32_t GS_THROW_IN; 00047 static const uint32_t GS_FREE_KICK; 00048 static const uint32_t GS_GOAL_KICK; 00049 static const uint32_t GS_HALF_TIME; 00050 static const uint32_t GS_SPL_INITIAL; 00051 static const uint32_t GS_SPL_READY; 00052 static const uint32_t GS_SPL_SET; 00053 static const uint32_t GS_SPL_PLAY; 00054 static const uint32_t GS_SPL_FINISHED; 00055 00056 /** 00057 Enumeration defining the different teams. Keep in sync with 00058 worldinfo_gamestate_team_t. 00059 */ 00060 typedef enum { 00061 TEAM_NONE /**< No team, not team-specific */, 00062 TEAM_CYAN /**< Cyan team */, 00063 TEAM_MAGENTA /**< Magenta team */, 00064 TEAM_BOTH /**< Both teams */ 00065 } if_gamestate_team_t; 00066 const char * tostring_if_gamestate_team_t(if_gamestate_team_t value) const; 00067 00068 /** 00069 Enumeration defining the different teams. Keep in sync with 00070 worldinfo_gamestate_goalcolor_t. 00071 */ 00072 typedef enum { 00073 GOAL_BLUE /**< Blue goal */, 00074 GOAL_YELLOW /**< Yellow goal */ 00075 } if_gamestate_goalcolor_t; 00076 const char * tostring_if_gamestate_goalcolor_t(if_gamestate_goalcolor_t value) const; 00077 00078 /** 00079 Enumeration defining the different teams. Keep in sync with 00080 worldinfo_gamestate_half_t. 00081 */ 00082 typedef enum { 00083 HALF_FIRST /**< First half */, 00084 HALF_SECOND /**< Second half */ 00085 } if_gamestate_half_t; 00086 const char * tostring_if_gamestate_half_t(if_gamestate_half_t value) const; 00087 00088 /** 00089 Enumeration defining the different robot roles. Keep in sync with 00090 worldinfo_gamestate_role_t. 00091 */ 00092 typedef enum { 00093 ROLE_GOALIE /**< Goalie */, 00094 ROLE_DEFENDER /**< Defender */, 00095 ROLE_MID_LEFT /**< Midfield left */, 00096 ROLE_MID_RIGHT /**< Midfield right */, 00097 ROLE_ATTACKER /**< Attacker */ 00098 } if_gamestate_role_t; 00099 const char * tostring_if_gamestate_role_t(if_gamestate_role_t value) const; 00100 00101 private: 00102 #pragma pack(push,4) 00103 /** Internal data storage, do NOT modify! */ 00104 typedef struct { 00105 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00106 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00107 uint32_t game_state; /**< Current game state */ 00108 int32_t state_team; /**< Team referred to by game state */ 00109 int32_t our_team; /**< Our team color */ 00110 int32_t our_goal_color; /**< Our own goal color */ 00111 int32_t half; /**< Current game half */ 00112 bool kickoff; /**< Whether we have kickoff */ 00113 int32_t role; /**< Current role of this robot */ 00114 uint32_t score_cyan; /**< Score of team cyan */ 00115 uint32_t score_magenta; /**< Score of team magenta */ 00116 } GameStateInterface_data_t; 00117 #pragma pack(pop) 00118 00119 GameStateInterface_data_t *data; 00120 00121 public: 00122 /* messages */ 00123 class SetTeamColorMessage : public Message 00124 { 00125 private: 00126 #pragma pack(push,4) 00127 /** Internal data storage, do NOT modify! */ 00128 typedef struct { 00129 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00130 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00131 int32_t our_team; /**< Our team color */ 00132 } SetTeamColorMessage_data_t; 00133 #pragma pack(pop) 00134 00135 SetTeamColorMessage_data_t *data; 00136 00137 public: 00138 SetTeamColorMessage(const if_gamestate_team_t ini_our_team); 00139 SetTeamColorMessage(); 00140 ~SetTeamColorMessage(); 00141 00142 SetTeamColorMessage(const SetTeamColorMessage *m); 00143 /* Methods */ 00144 if_gamestate_team_t our_team() const; 00145 void set_our_team(const if_gamestate_team_t new_our_team); 00146 size_t maxlenof_our_team() const; 00147 virtual Message * clone() const; 00148 }; 00149 00150 class SetKickoffMessage : public Message 00151 { 00152 private: 00153 #pragma pack(push,4) 00154 /** Internal data storage, do NOT modify! */ 00155 typedef struct { 00156 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00157 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00158 bool kickoff; /**< Whether we have kickoff */ 00159 } SetKickoffMessage_data_t; 00160 #pragma pack(pop) 00161 00162 SetKickoffMessage_data_t *data; 00163 00164 public: 00165 SetKickoffMessage(const bool ini_kickoff); 00166 SetKickoffMessage(); 00167 ~SetKickoffMessage(); 00168 00169 SetKickoffMessage(const SetKickoffMessage *m); 00170 /* Methods */ 00171 bool is_kickoff() const; 00172 void set_kickoff(const bool new_kickoff); 00173 size_t maxlenof_kickoff() const; 00174 virtual Message * clone() const; 00175 }; 00176 00177 class SetStateTeamMessage : public Message 00178 { 00179 private: 00180 #pragma pack(push,4) 00181 /** Internal data storage, do NOT modify! */ 00182 typedef struct { 00183 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00184 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00185 int32_t state_team; /**< Team referred to by game state */ 00186 } SetStateTeamMessage_data_t; 00187 #pragma pack(pop) 00188 00189 SetStateTeamMessage_data_t *data; 00190 00191 public: 00192 SetStateTeamMessage(const if_gamestate_team_t ini_state_team); 00193 SetStateTeamMessage(); 00194 ~SetStateTeamMessage(); 00195 00196 SetStateTeamMessage(const SetStateTeamMessage *m); 00197 /* Methods */ 00198 if_gamestate_team_t state_team() const; 00199 void set_state_team(const if_gamestate_team_t new_state_team); 00200 size_t maxlenof_state_team() const; 00201 virtual Message * clone() const; 00202 }; 00203 00204 virtual bool message_valid(const Message *message) const; 00205 private: 00206 GameStateInterface(); 00207 ~GameStateInterface(); 00208 00209 public: 00210 /* Methods */ 00211 uint32_t game_state() const; 00212 void set_game_state(const uint32_t new_game_state); 00213 size_t maxlenof_game_state() const; 00214 if_gamestate_team_t state_team() const; 00215 void set_state_team(const if_gamestate_team_t new_state_team); 00216 size_t maxlenof_state_team() const; 00217 if_gamestate_team_t our_team() const; 00218 void set_our_team(const if_gamestate_team_t new_our_team); 00219 size_t maxlenof_our_team() const; 00220 if_gamestate_goalcolor_t our_goal_color() const; 00221 void set_our_goal_color(const if_gamestate_goalcolor_t new_our_goal_color); 00222 size_t maxlenof_our_goal_color() const; 00223 if_gamestate_half_t half() const; 00224 void set_half(const if_gamestate_half_t new_half); 00225 size_t maxlenof_half() const; 00226 bool is_kickoff() const; 00227 void set_kickoff(const bool new_kickoff); 00228 size_t maxlenof_kickoff() const; 00229 if_gamestate_role_t role() const; 00230 void set_role(const if_gamestate_role_t new_role); 00231 size_t maxlenof_role() const; 00232 uint32_t score_cyan() const; 00233 void set_score_cyan(const uint32_t new_score_cyan); 00234 size_t maxlenof_score_cyan() const; 00235 uint32_t score_magenta() const; 00236 void set_score_magenta(const uint32_t new_score_magenta); 00237 size_t maxlenof_score_magenta() const; 00238 virtual Message * create_message(const char *type) const; 00239 00240 virtual void copy_values(const Interface *other); 00241 virtual const char * enum_tostring(const char *enumtype, int val) const; 00242 00243 }; 00244 00245 } // end namespace fawkes 00246 00247 #endif