Fawkes API  Fawkes Development Version
BatteryInterface.h
1 
2 /***************************************************************************
3  * BatteryInterface.h - Fawkes BlackBoard Interface - BatteryInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 Daniel Beck
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_BATTERYINTERFACE_H_
25 #define __INTERFACES_BATTERYINTERFACE_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(BatteryInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42  /** Internal data storage, do NOT modify! */
43  typedef struct __attribute__((packed)) {
44  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
45  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
46  uint32_t current; /**< Battery Current [mA] */
47  uint32_t voltage; /**< Battery Voltage [mV] */
48  uint32_t temperature; /**< Battery Temperature [°C] */
49  float absolute_soc; /**< Absolute state of charge [%] */
50  float relative_soc; /**< Relative state of charge [%] */
51  } BatteryInterface_data_t;
52 
53  BatteryInterface_data_t *data;
54 
55  public:
56  /* messages */
57  class PushButtonMessage : public Message
58  {
59  private:
60  /** Internal data storage, do NOT modify! */
61  typedef struct __attribute__((packed)) {
62  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
63  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
64  } PushButtonMessage_data_t;
65 
66  PushButtonMessage_data_t *data;
67 
68  public:
71 
73  /* Methods */
74  virtual Message * clone() const;
75  };
76 
77  class SleepMessage : public Message
78  {
79  private:
80  /** Internal data storage, do NOT modify! */
81  typedef struct __attribute__((packed)) {
82  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
83  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
84  } SleepMessage_data_t;
85 
86  SleepMessage_data_t *data;
87 
88  public:
89  SleepMessage();
90  ~SleepMessage();
91 
92  SleepMessage(const SleepMessage *m);
93  /* Methods */
94  virtual Message * clone() const;
95  };
96 
97  virtual bool message_valid(const Message *message) const;
98  private:
100  ~BatteryInterface();
101 
102  public:
103  /* Methods */
104  uint32_t current() const;
105  void set_current(const uint32_t new_current);
106  size_t maxlenof_current() const;
107  uint32_t voltage() const;
108  void set_voltage(const uint32_t new_voltage);
109  size_t maxlenof_voltage() const;
110  uint32_t temperature() const;
111  void set_temperature(const uint32_t new_temperature);
112  size_t maxlenof_temperature() const;
113  float absolute_soc() const;
114  void set_absolute_soc(const float new_absolute_soc);
115  size_t maxlenof_absolute_soc() const;
116  float relative_soc() const;
117  void set_relative_soc(const float new_relative_soc);
118  size_t maxlenof_relative_soc() const;
119  virtual Message * create_message(const char *type) const;
120 
121  virtual void copy_values(const Interface *other);
122  virtual const char * enum_tostring(const char *enumtype, int val) const;
123 
124 };
125 
126 } // end namespace fawkes
127 
128 #endif
float relative_soc() const
Get relative_soc value.
virtual Message * create_message(const char *type) const
Create message based on type name.
uint32_t voltage() const
Get voltage value.
size_t maxlenof_relative_soc() const
Get maximum length of relative_soc value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
size_t maxlenof_current() const
Get maximum length of current value.
size_t maxlenof_absolute_soc() const
Get maximum length of absolute_soc value.
void set_absolute_soc(const float new_absolute_soc)
Set absolute_soc value.
Fawkes library namespace.
BatteryInterface Fawkes BlackBoard Interface.
float absolute_soc() const
Get absolute_soc value.
void set_voltage(const uint32_t new_voltage)
Set voltage value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
uint32_t current() const
Get current value.
void set_temperature(const uint32_t new_temperature)
Set temperature value.
void set_relative_soc(const float new_relative_soc)
Set relative_soc value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
size_t maxlenof_voltage() const
Get maximum length of voltage value.
SleepMessage Fawkes BlackBoard Interface Message.
PushButtonMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_temperature() const
Get maximum length of temperature value.
void set_current(const uint32_t new_current)
Set current value.
uint32_t temperature() const
Get temperature value.
virtual void copy_values(const Interface *other)
Copy values from other interface.