Fawkes API  Fawkes Development Version
refbox_state_sender.h
1 
2 /***************************************************************************
3  * refbox_state_sender.h - Fawkes RefBox state sender
4  *
5  * Created: Wed Apr 09 09:56:57 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __TOOLS_REFBOXREP_REFBOX_STATE_SENDER_H_
24 #define __TOOLS_REFBOXREP_REFBOX_STATE_SENDER_H_
25 
26 #include <core/threading/thread.h>
27 #include <netcomm/worldinfo/enums.h>
28 #include <map>
29 
30 namespace fawkes {
31  class WorldInfoTransceiver;
32 }
33 
35 {
36  public:
37  RefBoxStateSender(const char *addr, unsigned short port,
38  const char *key, const char *iv,
39  bool debug = false);
40  virtual ~RefBoxStateSender();
41 
42  virtual void send();
43  virtual void set_gamestate(int game_state,
45  virtual void set_score(unsigned int score_cyan, unsigned int score_magenta);
46  virtual void set_team_goal(fawkes::worldinfo_gamestate_team_t our_team,
48  virtual void set_half(fawkes::worldinfo_gamestate_half_t half);
49  virtual void add_penalty(unsigned int player, unsigned int penalty,
50  unsigned int seconds_remaining);
51 
53  {
54  public:
56  virtual ~TimeoutThread();
57  virtual void loop();
58  private:
59  unsigned int __timeout_usec;
60  RefBoxStateSender *__rss;
61  };
62 
63  protected:
65 
66  private:
67  void execute_send();
68 
69  private:
70  bool __debug;
71  fawkes::WorldInfoTransceiver *__transceiver;
72  TimeoutThread *__timeout_thread;
73 
74  int __game_state;
76  unsigned int __score_cyan;
77  unsigned int __score_magenta;
81 
82  /// @cond INTERNALS
83  typedef struct {
84  unsigned int player;
85  unsigned int penalty;
86  unsigned int seconds_remaining;
87  } rss_penalty_t;
88  /// @endcond
89  std::map<unsigned int, rss_penalty_t> __penalties;
90  std::map<unsigned int, rss_penalty_t>::iterator __pit;
91 
92 };
93 
94 #endif
Class to send and receive world information.
Definition: transceiver.h:52
RefBox repeater state sender.
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:70
worldinfo_gamestate_team_t
Team.
Definition: enums.h:54
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:63