BatteryInterface.h

00001
00002 /***************************************************************************
00003  *  BatteryInterface.h - Fawkes BlackBoard Interface - BatteryInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2008  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_BATTERYINTERFACE_H_
00025 #define __INTERFACES_BATTERYINTERFACE_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 BatteryInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(BatteryInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040
00041  private:
00042   /** Internal data storage, do NOT modify! */
00043   typedef struct {
00044     unsigned int current; /**< Battery Current [mA] */
00045     unsigned int voltage; /**< Battery Voltage [mV] */
00046     unsigned int temperature; /**< Battery Temperature [°C] */
00047     float absolute_soc; /**< Absolute state of charge [%] */
00048     float relative_soc; /**< Relative state of charge [%] */
00049   } BatteryInterface_data_t;
00050
00051   BatteryInterface_data_t *data;
00052
00053  public:
00054   /* messages */
00055   class PushButtonMessage : public Message
00056   {
00057    public:
00058     PushButtonMessage();
00059     ~PushButtonMessage();
00060
00061     PushButtonMessage(const PushButtonMessage *m);
00062     /* Methods */
00063     virtual Message * clone() const;
00064   };
00065
00066   class SleepMessage : public Message
00067   {
00068    public:
00069     SleepMessage();
00070     ~SleepMessage();
00071
00072     SleepMessage(const SleepMessage *m);
00073     /* Methods */
00074     virtual Message * clone() const;
00075   };
00076
00077   virtual bool message_valid(const Message *message) const;
00078  private:
00079   BatteryInterface();
00080   ~BatteryInterface();
00081
00082  public:
00083   /* Methods */
00084   unsigned int current() const;
00085   void set_current(const unsigned int new_current);
00086   size_t maxlenof_current() const;
00087   unsigned int voltage() const;
00088   void set_voltage(const unsigned int new_voltage);
00089   size_t maxlenof_voltage() const;
00090   unsigned int temperature() const;
00091   void set_temperature(const unsigned int new_temperature);
00092   size_t maxlenof_temperature() const;
00093   float absolute_soc() const;
00094   void set_absolute_soc(const float new_absolute_soc);
00095   size_t maxlenof_absolute_soc() const;
00096   float relative_soc() const;
00097   void set_relative_soc(const float new_relative_soc);
00098   size_t maxlenof_relative_soc() const;
00099   virtual Message * create_message(const char *type) const;
00100
00101   virtual void copy_values(const Interface *other);
00102
00103 };
00104
00105 } // end namespace fawkes
00106
00107 #endif