KickerInterface.h

00001
00002 /***************************************************************************
00003  *  KickerInterface.h - Fawkes BlackBoard Interface - KickerInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2007  Daniel Beck
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __INTERFACES_KICKERINTERFACE_H_
00025 #define __INTERFACES_KICKERINTERFACE_H_
00026 
00027 #include <interface/interface.h>
00028 #include <interface/message.h>
00029 #include <interface/field_iterator.h>
00030
00031 namespace fawkes {
00032
00033 class KickerInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(KickerInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040 
00041   /** 
00042         Enumeration defining on which side of the robot the ball shall be
00043         guided (and thus on which side the arm is to be erected).
00044        */
00045   typedef enum {
00046     GUIDE_BALL_LEFT /**< 
00047         Constant defining that the kicker shall activate the ball guidance device
00048         in such a way that the left arm is erected.
00049        */,
00050     GUIDE_BALL_RIGHT /**< 
00051         Constant defining that the kicker shall activate the ball guidance device
00052         in such a way that the right arm is erected.
00053        */
00054   } GuideBallSideEnum;
00055
00056  private:
00057   /** Internal data storage, do NOT modify! */
00058   typedef struct {
00059     unsigned int current_intensity; /**< 
00060       The currently set intensity.
00061      */
00062     int num_kicks_left; /**< 
00063       Number of Left-Kicks
00064      */
00065     int num_kicks_center; /**< 
00066       Number of Center-Kicks
00067      */
00068     int num_kicks_right; /**< 
00069       Number of Right-Kicks
00070      */
00071     GuideBallSideEnum guide_ball_side; /**< Side where the ball
00072       guidance arm is currently erected. */
00073   } KickerInterface_data_t;
00074
00075   KickerInterface_data_t *data;
00076
00077  public:
00078   /* messages */
00079   class KickMessage : public Message
00080   {
00081    private:
00082     /** Internal data storage, do NOT modify! */
00083     typedef struct {
00084       unsigned int intensity; /**< Intensity in the range [0..255]. */
00085       bool left; /**< True to kick with left kicker. */
00086       bool center; /**< True to kick with central kicker. */
00087       bool right; /**< True to kick with right kicker. */
00088     } KickMessage_data_t;
00089
00090     KickMessage_data_t *data;
00091
00092    public:
00093     KickMessage(const bool ini_left, const bool ini_center, const bool ini_right, const unsigned int ini_intensity);
00094     KickMessage();
00095     ~KickMessage();
00096
00097     KickMessage(const KickMessage *m);
00098     /* Methods */
00099     bool is_left() const;
00100     void set_left(const bool new_left);
00101     size_t maxlenof_left() const;
00102     bool is_center() const;
00103     void set_center(const bool new_center);
00104     size_t maxlenof_center() const;
00105     bool is_right() const;
00106     void set_right(const bool new_right);
00107     size_t maxlenof_right() const;
00108     unsigned int intensity() const;
00109     void set_intensity(const unsigned int new_intensity);
00110     size_t maxlenof_intensity() const;
00111     virtual Message * clone() const;
00112   };
00113
00114   class ResetCounterMessage : public Message
00115   {
00116    public:
00117     ResetCounterMessage();
00118     ~ResetCounterMessage();
00119
00120     ResetCounterMessage(const ResetCounterMessage *m);
00121     /* Methods */
00122     virtual Message * clone() const;
00123   };
00124
00125   class GuideBallMessage : public Message
00126   {
00127    private:
00128     /** Internal data storage, do NOT modify! */
00129     typedef struct {
00130       GuideBallSideEnum guide_ball_side; /**< Side where to guide the ball and erect the arm. */
00131     } GuideBallMessage_data_t;
00132
00133     GuideBallMessage_data_t *data;
00134
00135    public:
00136     GuideBallMessage(const GuideBallSideEnum ini_guide_ball_side);
00137     GuideBallMessage();
00138     ~GuideBallMessage();
00139
00140     GuideBallMessage(const GuideBallMessage *m);
00141     /* Methods */
00142     GuideBallSideEnum guide_ball_side() const;
00143     void set_guide_ball_side(const GuideBallSideEnum new_guide_ball_side);
00144     size_t maxlenof_guide_ball_side() const;
00145     virtual Message * clone() const;
00146   };
00147
00148   virtual bool message_valid(const Message *message) const;
00149  private:
00150   KickerInterface();
00151   ~KickerInterface();
00152
00153  public:
00154   /* Methods */
00155   int num_kicks_left() const;
00156   void set_num_kicks_left(const int new_num_kicks_left);
00157   size_t maxlenof_num_kicks_left() const;
00158   int num_kicks_center() const;
00159   void set_num_kicks_center(const int new_num_kicks_center);
00160   size_t maxlenof_num_kicks_center() const;
00161   int num_kicks_right() const;
00162   void set_num_kicks_right(const int new_num_kicks_right);
00163   size_t maxlenof_num_kicks_right() const;
00164   GuideBallSideEnum guide_ball_side() const;
00165   void set_guide_ball_side(const GuideBallSideEnum new_guide_ball_side);
00166   size_t maxlenof_guide_ball_side() const;
00167   unsigned int current_intensity() const;
00168   void set_current_intensity(const unsigned int new_current_intensity);
00169   size_t maxlenof_current_intensity() const;
00170   virtual Message * create_message(const char *type) const;
00171
00172   virtual void copy_values(const Interface *other);
00173
00174 };
00175
00176 } // end namespace fawkes
00177
00178 #endif