Fawkes API  Fawkes Development Version
SoccerPenaltyInterface.h
1 
2 /***************************************************************************
3  * SoccerPenaltyInterface.h - Fawkes BlackBoard Interface - SoccerPenaltyInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008-2010 Tim Niemueller
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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _INTERFACES_SOCCERPENALTYINTERFACE_H_
25 #define _INTERFACES_SOCCERPENALTYINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
33 class SoccerPenaltyInterface : public Interface
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(SoccerPenaltyInterface)
37  /// @endcond
38  public:
39  /* constants */
40  static const uint16_t SPL_PENALTY_NONE;
41  static const uint16_t SPL_PENALTY_BALL_HOLDING;
42  static const uint16_t SPL_PENALTY_PLAYER_PUSHING;
43  static const uint16_t SPL_PENALTY_OBSTRUCTION;
44  static const uint16_t SPL_PENALTY_INACTIVE_PLAYER;
45  static const uint16_t SPL_PENALTY_ILLEGAL_DEFENDER;
46  static const uint16_t SPL_PENALTY_LEAVING_THE_FIELD;
47  static const uint16_t SPL_PENALTY_PLAYING_WITH_HANDS;
48  static const uint16_t SPL_PENALTY_REQ_FOR_PICKUP;
49  static const uint16_t SPL_PENALTY_MANUAL;
50 
51  private:
52  /** Internal data storage, do NOT modify! */
53  typedef struct {
54  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
55  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
56  uint16_t penalty; /**< Current penalty code. */
57  uint16_t remaining; /**< Estimated time in seconds until the robot is unpenalized. */
58  } SoccerPenaltyInterface_data_t;
59 
60  SoccerPenaltyInterface_data_t *data;
61 
62  public:
63  /* messages */
64  class SetPenaltyMessage : public Message
65  {
66  private:
67  /** Internal data storage, do NOT modify! */
68  typedef struct {
69  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
70  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
71  uint16_t penalty; /**< Current penalty code. */
72  } SetPenaltyMessage_data_t;
73 
74  SetPenaltyMessage_data_t *data;
75 
76  public:
77  SetPenaltyMessage(const uint16_t ini_penalty);
80 
81  explicit SetPenaltyMessage(const SetPenaltyMessage *m);
82  /* Methods */
83  uint16_t penalty() const;
84  void set_penalty(const uint16_t new_penalty);
85  size_t maxlenof_penalty() const;
86  virtual Message * clone() const;
87  };
88 
89  virtual bool message_valid(const Message *message) const;
90  private:
93 
94  public:
95  /* Methods */
96  uint16_t penalty() const;
97  void set_penalty(const uint16_t new_penalty);
98  size_t maxlenof_penalty() const;
99  uint16_t remaining() const;
100  void set_remaining(const uint16_t new_remaining);
101  size_t maxlenof_remaining() const;
102  virtual Message * create_message(const char *type) const;
103 
104  virtual void copy_values(const Interface *other);
105  virtual const char * enum_tostring(const char *enumtype, int val) const;
106 
107 };
108 
109 } // end namespace fawkes
110 
111 #endif
fawkes::SoccerPenaltyInterface::remaining
uint16_t remaining() const
Get remaining value.
Definition: SoccerPenaltyInterface.cpp:128
fawkes::SoccerPenaltyInterface::SPL_PENALTY_OBSTRUCTION
static const uint16_t SPL_PENALTY_OBSTRUCTION
SPL_PENALTY_OBSTRUCTION constant.
Definition: SoccerPenaltyInterface.h:52
fawkes::SoccerPenaltyInterface::SPL_PENALTY_ILLEGAL_DEFENDER
static const uint16_t SPL_PENALTY_ILLEGAL_DEFENDER
SPL_PENALTY_ILLEGAL_DEFENDER constant.
Definition: SoccerPenaltyInterface.h:54
fawkes::SoccerPenaltyInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: SoccerPenaltyInterface.cpp:283
fawkes::Message
Definition: message.h:40
fawkes::SoccerPenaltyInterface::maxlenof_remaining
size_t maxlenof_remaining() const
Get maximum length of remaining value.
Definition: SoccerPenaltyInterface.cpp:138
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition: interface.cpp:643
fawkes::SoccerPenaltyInterface::SetPenaltyMessage::SetPenaltyMessage
SetPenaltyMessage()
Constructor.
Definition: SoccerPenaltyInterface.cpp:209
fawkes::SoccerPenaltyInterface::create_message
virtual Message * create_message(const char *type) const
Definition: SoccerPenaltyInterface.cpp:156
fawkes::SoccerPenaltyInterface::SPL_PENALTY_INACTIVE_PLAYER
static const uint16_t SPL_PENALTY_INACTIVE_PLAYER
SPL_PENALTY_INACTIVE_PLAYER constant.
Definition: SoccerPenaltyInterface.h:53
fawkes::SoccerPenaltyInterface::SPL_PENALTY_NONE
static const uint16_t SPL_PENALTY_NONE
SPL_PENALTY_NONE constant.
Definition: SoccerPenaltyInterface.h:49
fawkes::SoccerPenaltyInterface::SetPenaltyMessage
Definition: SoccerPenaltyInterface.h:73
fawkes::SoccerPenaltyInterface::SetPenaltyMessage::set_penalty
void set_penalty(const uint16_t new_penalty)
Set penalty value.
Definition: SoccerPenaltyInterface.cpp:263
fawkes::SoccerPenaltyInterface::set_remaining
void set_remaining(const uint16_t new_remaining)
Set remaining value.
Definition: SoccerPenaltyInterface.cpp:148
fawkes::SoccerPenaltyInterface::SPL_PENALTY_PLAYING_WITH_HANDS
static const uint16_t SPL_PENALTY_PLAYING_WITH_HANDS
SPL_PENALTY_PLAYING_WITH_HANDS constant.
Definition: SoccerPenaltyInterface.h:56
fawkes::SoccerPenaltyInterface::SetPenaltyMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SoccerPenaltyInterface.cpp:274
fawkes::SoccerPenaltyInterface::set_penalty
void set_penalty(const uint16_t new_penalty)
Set penalty value.
Definition: SoccerPenaltyInterface.cpp:117
fawkes
fawkes::SoccerPenaltyInterface::SPL_PENALTY_BALL_HOLDING
static const uint16_t SPL_PENALTY_BALL_HOLDING
SPL_PENALTY_BALL_HOLDING constant.
Definition: SoccerPenaltyInterface.h:50
fawkes::Interface
Definition: interface.h:77
fawkes::SoccerPenaltyInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition: SoccerPenaltyInterface.cpp:171
fawkes::SoccerPenaltyInterface::SPL_PENALTY_REQ_FOR_PICKUP
static const uint16_t SPL_PENALTY_REQ_FOR_PICKUP
SPL_PENALTY_REQ_FOR_PICKUP constant.
Definition: SoccerPenaltyInterface.h:57
fawkes::SoccerPenaltyInterface::SPL_PENALTY_LEAVING_THE_FIELD
static const uint16_t SPL_PENALTY_LEAVING_THE_FIELD
SPL_PENALTY_LEAVING_THE_FIELD constant.
Definition: SoccerPenaltyInterface.h:55
fawkes::SoccerPenaltyInterface::maxlenof_penalty
size_t maxlenof_penalty() const
Get maximum length of penalty value.
Definition: SoccerPenaltyInterface.cpp:107
fawkes::SoccerPenaltyInterface::SetPenaltyMessage::maxlenof_penalty
size_t maxlenof_penalty() const
Get maximum length of penalty value.
Definition: SoccerPenaltyInterface.cpp:253
fawkes::SoccerPenaltyInterface::SPL_PENALTY_MANUAL
static const uint16_t SPL_PENALTY_MANUAL
SPL_PENALTY_MANUAL constant.
Definition: SoccerPenaltyInterface.h:58
fawkes::SoccerPenaltyInterface::penalty
uint16_t penalty() const
Get penalty value.
Definition: SoccerPenaltyInterface.cpp:97
fawkes::SoccerPenaltyInterface::SetPenaltyMessage::~SetPenaltyMessage
~SetPenaltyMessage()
Destructor.
Definition: SoccerPenaltyInterface.cpp:220
fawkes::SoccerPenaltyInterface
Definition: SoccerPenaltyInterface.h:37
fawkes::SoccerPenaltyInterface::SPL_PENALTY_PLAYER_PUSHING
static const uint16_t SPL_PENALTY_PLAYER_PUSHING
SPL_PENALTY_PLAYER_PUSHING constant.
Definition: SoccerPenaltyInterface.h:51
fawkes::SoccerPenaltyInterface::SetPenaltyMessage::penalty
uint16_t penalty() const
Get penalty value.
Definition: SoccerPenaltyInterface.cpp:243
fawkes::SoccerPenaltyInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Definition: SoccerPenaltyInterface.cpp:182