23 #include "refbox_state_sender.h"
25 #include <netcomm/worldinfo/transceiver.h>
26 #include <core/macros.h>
31 using namespace fawkes;
48 const char *key,
const char *iv,
54 __transceiver->set_loop(
true );
63 __timeout_thread = NULL;
80 __timeout_thread = NULL;
87 if ( __timeout_thread ) {
88 __timeout_thread->cancel();
89 __timeout_thread->join();
90 delete __timeout_thread;
105 printf(
"Setting gamestate to '%d' for team '%s'\n",
109 __game_state = game_state;
110 __state_team = state_team;
122 printf(
"Setting score to %u:%u (cyan:magenta)\n", score_cyan, score_magenta);
124 __score_cyan = score_cyan;
125 __score_magenta = score_magenta;
138 printf(
"Setting team color to '%s' and goal color to '%s'\n",
142 __our_team = our_team;
143 __our_goal_color = goal_color;
154 printf(
"Setting half to '%s'\n",
168 unsigned int seconds_remaining)
173 p.seconds_remaining = seconds_remaining;
174 __penalties[player] = p;
183 printf(
"Sending worldinfo\n");
186 if ( __timeout_thread ) {
187 __timeout_thread->cancel();
188 __timeout_thread->join();
189 delete __timeout_thread;
192 __timeout_thread->start();
200 RefBoxStateSender::execute_send()
202 if (unlikely(! __transceiver)) {
205 __transceiver->set_gamestate(__game_state, __state_team);
206 __transceiver->set_score(__score_cyan, __score_magenta);
207 __transceiver->set_team_goal(__our_team, __our_goal_color);
208 __transceiver->set_half(__half);
209 for (__pit = __penalties.begin(); __pit != __penalties.end(); ++__pit) {
210 __transceiver->add_penalty(__pit->second.player, __pit->second.penalty,
211 __pit->second.seconds_remaining);
214 __transceiver->send();
229 :
Thread(
"RefBoxStateSender::TimeoutThread",
Thread::OPMODE_CONTINUOUS)
245 __rss->execute_send();
247 switch (__timeout_usec) {
248 case 0: __timeout_usec = 1;
break;
249 case 1: __timeout_usec = 2;
break;
250 case 2: __timeout_usec = 50000;
break;
256 usleep(__timeout_usec);