Fawkes API  Fawkes Development Version
LedInterface.h
1 
2 /***************************************************************************
3  * LedInterface.h - Fawkes BlackBoard Interface - LedInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 Tim Niemueller
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_LEDINTERFACE_H_
25 #define __INTERFACES_LEDINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
33 class LedInterface : public Interface
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(LedInterface)
37  /// @endcond
38  public:
39  /* constants */
40  static const float ON;
41  static const float OFF;
42 
43  private:
44  /** Internal data storage, do NOT modify! */
45  typedef struct __attribute__((packed)) {
46  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
47  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
48  float intensity; /**< Intensity value. */
49  } LedInterface_data_t;
50 
51  LedInterface_data_t *data;
52 
53  public:
54  /* messages */
56  {
57  private:
58  /** Internal data storage, do NOT modify! */
59  typedef struct __attribute__((packed)) {
60  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
61  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
62  float time_sec; /**<
63  Time in seconds when to reach the intensity.
64  */
65  float intensity; /**< Intensity value. */
66  } SetIntensityMessage_data_t;
67 
68  SetIntensityMessage_data_t *data;
69 
70  public:
71  SetIntensityMessage(const float ini_time_sec, const float ini_intensity);
74 
76  /* Methods */
77  float time_sec() const;
78  void set_time_sec(const float new_time_sec);
79  size_t maxlenof_time_sec() const;
80  float intensity() const;
81  void set_intensity(const float new_intensity);
82  size_t maxlenof_intensity() const;
83  virtual Message * clone() const;
84  };
85 
86  class TurnOnMessage : public Message
87  {
88  private:
89  /** Internal data storage, do NOT modify! */
90  typedef struct __attribute__((packed)) {
91  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
92  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
93  } TurnOnMessage_data_t;
94 
95  TurnOnMessage_data_t *data;
96 
97  public:
98  TurnOnMessage();
99  ~TurnOnMessage();
100 
101  TurnOnMessage(const TurnOnMessage *m);
102  /* Methods */
103  virtual Message * clone() const;
104  };
105 
106  class TurnOffMessage : public Message
107  {
108  private:
109  /** Internal data storage, do NOT modify! */
110  typedef struct __attribute__((packed)) {
111  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
112  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
113  } TurnOffMessage_data_t;
114 
115  TurnOffMessage_data_t *data;
116 
117  public:
118  TurnOffMessage();
119  ~TurnOffMessage();
120 
121  TurnOffMessage(const TurnOffMessage *m);
122  /* Methods */
123  virtual Message * clone() const;
124  };
125 
126  virtual bool message_valid(const Message *message) const;
127  private:
128  LedInterface();
129  ~LedInterface();
130 
131  public:
132  /* Methods */
133  float intensity() const;
134  void set_intensity(const float new_intensity);
135  size_t maxlenof_intensity() const;
136  virtual Message * create_message(const char *type) const;
137 
138  virtual void copy_values(const Interface *other);
139  virtual const char * enum_tostring(const char *enumtype, int val) const;
140 
141 };
142 
143 } // end namespace fawkes
144 
145 #endif
TurnOffMessage Fawkes BlackBoard Interface Message.
Definition: LedInterface.h:106
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Fawkes library namespace.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
static const float ON
ON constant.
Definition: LedInterface.h:40
virtual void copy_values(const Interface *other)
Copy values from other interface.
void set_intensity(const float new_intensity)
Set intensity value.
float intensity() const
Get intensity value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
static const float OFF
OFF constant.
Definition: LedInterface.h:41
size_t maxlenof_intensity() const
Get maximum length of intensity value.
SetIntensityMessage Fawkes BlackBoard Interface Message.
Definition: LedInterface.h:55
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
LedInterface Fawkes BlackBoard Interface.
Definition: LedInterface.h:33
TurnOnMessage Fawkes BlackBoard Interface Message.
Definition: LedInterface.h:86
virtual Message * create_message(const char *type) const
Create message based on type name.