Fawkes API
Fawkes Development Version
|
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 #pragma pack(push,4) 00043 /** Internal data storage, do NOT modify! */ 00044 typedef struct { 00045 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00046 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00047 uint32_t current; /**< Battery Current [mA] */ 00048 uint32_t voltage; /**< Battery Voltage [mV] */ 00049 uint32_t temperature; /**< Battery Temperature [°C] */ 00050 float absolute_soc; /**< Absolute state of charge [%] */ 00051 float relative_soc; /**< Relative state of charge [%] */ 00052 } BatteryInterface_data_t; 00053 #pragma pack(pop) 00054 00055 BatteryInterface_data_t *data; 00056 00057 public: 00058 /* messages */ 00059 class PushButtonMessage : public Message 00060 { 00061 private: 00062 #pragma pack(push,4) 00063 /** Internal data storage, do NOT modify! */ 00064 typedef struct { 00065 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00066 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00067 } PushButtonMessage_data_t; 00068 #pragma pack(pop) 00069 00070 PushButtonMessage_data_t *data; 00071 00072 public: 00073 PushButtonMessage(); 00074 ~PushButtonMessage(); 00075 00076 PushButtonMessage(const PushButtonMessage *m); 00077 /* Methods */ 00078 virtual Message * clone() const; 00079 }; 00080 00081 class SleepMessage : public Message 00082 { 00083 private: 00084 #pragma pack(push,4) 00085 /** Internal data storage, do NOT modify! */ 00086 typedef struct { 00087 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00088 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00089 } SleepMessage_data_t; 00090 #pragma pack(pop) 00091 00092 SleepMessage_data_t *data; 00093 00094 public: 00095 SleepMessage(); 00096 ~SleepMessage(); 00097 00098 SleepMessage(const SleepMessage *m); 00099 /* Methods */ 00100 virtual Message * clone() const; 00101 }; 00102 00103 virtual bool message_valid(const Message *message) const; 00104 private: 00105 BatteryInterface(); 00106 ~BatteryInterface(); 00107 00108 public: 00109 /* Methods */ 00110 uint32_t current() const; 00111 void set_current(const uint32_t new_current); 00112 size_t maxlenof_current() const; 00113 uint32_t voltage() const; 00114 void set_voltage(const uint32_t new_voltage); 00115 size_t maxlenof_voltage() const; 00116 uint32_t temperature() const; 00117 void set_temperature(const uint32_t new_temperature); 00118 size_t maxlenof_temperature() const; 00119 float absolute_soc() const; 00120 void set_absolute_soc(const float new_absolute_soc); 00121 size_t maxlenof_absolute_soc() const; 00122 float relative_soc() const; 00123 void set_relative_soc(const float new_relative_soc); 00124 size_t maxlenof_relative_soc() const; 00125 virtual Message * create_message(const char *type) const; 00126 00127 virtual void copy_values(const Interface *other); 00128 virtual const char * enum_tostring(const char *enumtype, int val) const; 00129 00130 }; 00131 00132 } // end namespace fawkes 00133 00134 #endif