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 #pragma pack(push,4)
43  /** Internal data storage, do NOT modify! */
44  typedef struct {
45  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
46  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
47  uint32_t current; /**< Battery Current [mA] */
48  uint32_t voltage; /**< Battery Voltage [mV] */
49  uint32_t temperature; /**< Battery Temperature [°C] */
50  float absolute_soc; /**< Absolute state of charge [%] */
51  float relative_soc; /**< Relative state of charge [%] */
52  } BatteryInterface_data_t;
53 #pragma pack(pop)
54 
55  BatteryInterface_data_t *data;
56 
57  public:
58  /* messages */
59  class PushButtonMessage : public Message
60  {
61  private:
62 #pragma pack(push,4)
63  /** Internal data storage, do NOT modify! */
64  typedef struct {
65  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
66  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
67  } PushButtonMessage_data_t;
68 #pragma pack(pop)
69 
70  PushButtonMessage_data_t *data;
71 
72  public:
75 
77  /* Methods */
78  virtual Message * clone() const;
79  };
80 
81  class SleepMessage : public Message
82  {
83  private:
84 #pragma pack(push,4)
85  /** Internal data storage, do NOT modify! */
86  typedef struct {
87  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
88  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
89  } SleepMessage_data_t;
90 #pragma pack(pop)
91 
92  SleepMessage_data_t *data;
93 
94  public:
95  SleepMessage();
96  ~SleepMessage();
97 
98  SleepMessage(const SleepMessage *m);
99  /* Methods */
100  virtual Message * clone() const;
101  };
102 
103  virtual bool message_valid(const Message *message) const;
104  private:
106  ~BatteryInterface();
107 
108  public:
109  /* Methods */
110  uint32_t current() const;
111  void set_current(const uint32_t new_current);
112  size_t maxlenof_current() const;
113  uint32_t voltage() const;
114  void set_voltage(const uint32_t new_voltage);
115  size_t maxlenof_voltage() const;
116  uint32_t temperature() const;
117  void set_temperature(const uint32_t new_temperature);
118  size_t maxlenof_temperature() const;
119  float absolute_soc() const;
120  void set_absolute_soc(const float new_absolute_soc);
121  size_t maxlenof_absolute_soc() const;
122  float relative_soc() const;
123  void set_relative_soc(const float new_relative_soc);
124  size_t maxlenof_relative_soc() const;
125  virtual Message * create_message(const char *type) const;
126 
127  virtual void copy_values(const Interface *other);
128  virtual const char * enum_tostring(const char *enumtype, int val) const;
129 
130 };
131 
132 } // end namespace fawkes
133 
134 #endif
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
void set_absolute_soc(const float new_absolute_soc)
Set absolute_soc value.
size_t maxlenof_temperature() const
Get maximum length of temperature value.
virtual Message * clone() const
Clone this message.
Fawkes library namespace.
size_t maxlenof_voltage() const
Get maximum length of voltage value.
size_t maxlenof_absolute_soc() const
Get maximum length of absolute_soc value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
BatteryInterface Fawkes BlackBoard Interface.
void set_voltage(const uint32_t new_voltage)
Set voltage value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
void set_temperature(const uint32_t new_temperature)
Set temperature value.
void set_relative_soc(const float new_relative_soc)
Set relative_soc value.
size_t maxlenof_current() const
Get maximum length of current value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
SleepMessage Fawkes BlackBoard Interface Message.
uint32_t current() const
Get current value.
PushButtonMessage Fawkes BlackBoard Interface Message.
virtual Message * create_message(const char *type) const
Create message based on type name.
float relative_soc() const
Get relative_soc value.
virtual Message * clone() const
Clone this message.
void set_current(const uint32_t new_current)
Set current value.
uint32_t voltage() const
Get voltage value.
float absolute_soc() const
Get absolute_soc value.
size_t maxlenof_relative_soc() const
Get maximum length of relative_soc value.
const char * type() const
Get type of interface.
Definition: interface.cpp:635
virtual void copy_values(const Interface *other)
Copy values from other interface.
uint32_t temperature() const
Get temperature value.