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  /** Internal data storage, do NOT modify! */
53  typedef struct __attribute__((packed)) {
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 __attribute__((packed)) {
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 
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
virtual void copy_values(const Interface *other)
Copy values from other interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
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:44
uint16_t remaining() const
Get remaining value.
uint16_t penalty() const
Get penalty value.
Fawkes library namespace.
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:79
static const uint16_t SPL_PENALTY_NONE
SPL_PENALTY_NONE constant.
size_t maxlenof_remaining() const
Get maximum length of remaining value.
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.
virtual Message * create_message(const char *type) const
Create message based on type name.
static const uint16_t SPL_PENALTY_LEAVING_THE_FIELD
SPL_PENALTY_LEAVING_THE_FIELD constant.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
static const uint16_t SPL_PENALTY_REQ_FOR_PICKUP
SPL_PENALTY_REQ_FOR_PICKUP constant.
size_t maxlenof_penalty() const
Get maximum length of penalty value.
static const uint16_t SPL_PENALTY_MANUAL
SPL_PENALTY_MANUAL constant.
void set_remaining(const uint16_t new_remaining)
Set remaining value.
static const uint16_t SPL_PENALTY_PLAYER_PUSHING
SPL_PENALTY_PLAYER_PUSHING constant.
static const uint16_t SPL_PENALTY_BALL_HOLDING
SPL_PENALTY_BALL_HOLDING constant.
static const uint16_t SPL_PENALTY_OBSTRUCTION
SPL_PENALTY_OBSTRUCTION constant.