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 
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 #pragma pack(push,4)
53  /** Internal data storage, do NOT modify! */
54  typedef struct {
55  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
56  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
57  uint16_t penalty; /**< Current penalty code. */
58  uint16_t remaining; /**< Estimated time in seconds until the robot is unpenalized. */
59  } SoccerPenaltyInterface_data_t;
60 #pragma pack(pop)
61 
62  SoccerPenaltyInterface_data_t *data;
63 
64  public:
65  /* messages */
66  class SetPenaltyMessage : public Message
67  {
68  private:
69 #pragma pack(push,4)
70  /** Internal data storage, do NOT modify! */
71  typedef struct {
72  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
73  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
74  uint16_t penalty; /**< Current penalty code. */
75  } SetPenaltyMessage_data_t;
76 #pragma pack(pop)
77 
78  SetPenaltyMessage_data_t *data;
79 
80  public:
81  SetPenaltyMessage(const uint16_t ini_penalty);
84 
86  /* Methods */
87  uint16_t penalty() const;
88  void set_penalty(const uint16_t new_penalty);
89  size_t maxlenof_penalty() const;
90  virtual Message * clone() const;
91  };
92 
93  virtual bool message_valid(const Message *message) const;
94  private:
97 
98  public:
99  /* Methods */
100  uint16_t penalty() const;
101  void set_penalty(const uint16_t new_penalty);
102  size_t maxlenof_penalty() const;
103  uint16_t remaining() const;
104  void set_remaining(const uint16_t new_remaining);
105  size_t maxlenof_remaining() const;
106  virtual Message * create_message(const char *type) const;
107 
108  virtual void copy_values(const Interface *other);
109  virtual const char * enum_tostring(const char *enumtype, int val) const;
110 
111 };
112 
113 } // end namespace fawkes
114 
115 #endif
virtual void copy_values(const Interface *other)
Copy values from other interface.
static const uint16_t SPL_PENALTY_ILLEGAL_DEFENDER
SPL_PENALTY_ILLEGAL_DEFENDER constant.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
size_t maxlenof_remaining() const
Get maximum length of remaining value.
size_t maxlenof_penalty() const
Get maximum length of penalty value.
Fawkes library namespace.
void set_penalty(const uint16_t new_penalty)
Set penalty value.
uint16_t penalty() const
Get penalty value.
static const uint16_t SPL_PENALTY_PLAYING_WITH_HANDS
SPL_PENALTY_PLAYING_WITH_HANDS constant.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
static const uint16_t SPL_PENALTY_NONE
SPL_PENALTY_NONE constant.
virtual Message * create_message(const char *type) const
Create message based on type name.
SoccerPenaltyInterface Fawkes BlackBoard Interface.
SetPenaltyMessage Fawkes BlackBoard Interface Message.
void set_penalty(const uint16_t new_penalty)
Set penalty value.
static const uint16_t SPL_PENALTY_INACTIVE_PLAYER
SPL_PENALTY_INACTIVE_PLAYER constant.
static const uint16_t SPL_PENALTY_LEAVING_THE_FIELD
SPL_PENALTY_LEAVING_THE_FIELD constant.
virtual Message * clone() const
Clone this message.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
static const uint16_t SPL_PENALTY_REQ_FOR_PICKUP
SPL_PENALTY_REQ_FOR_PICKUP constant.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
static const uint16_t SPL_PENALTY_MANUAL
SPL_PENALTY_MANUAL constant.
void set_remaining(const uint16_t new_remaining)
Set remaining value.
uint16_t remaining() const
Get remaining value.
static const uint16_t SPL_PENALTY_PLAYER_PUSHING
SPL_PENALTY_PLAYER_PUSHING constant.
size_t maxlenof_penalty() const
Get maximum length of penalty value.
static const uint16_t SPL_PENALTY_BALL_HOLDING
SPL_PENALTY_BALL_HOLDING constant.
static const uint16_t SPL_PENALTY_OBSTRUCTION
SPL_PENALTY_OBSTRUCTION constant.
const char * type() const
Get type of interface.
Definition: interface.cpp:635