Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 #pragma pack(push,4)
45  /** Internal data storage, do NOT modify! */
46  typedef struct {
47  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
48  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
49  float intensity; /**< Intensity value. */
50  } LedInterface_data_t;
51 #pragma pack(pop)
52 
53  LedInterface_data_t *data;
54 
55  public:
56  /* messages */
58  {
59  private:
60 #pragma pack(push,4)
61  /** Internal data storage, do NOT modify! */
62  typedef struct {
63  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
64  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
65  float time_sec; /**<
66  Time in seconds when to reach the intensity.
67  */
68  float intensity; /**< Intensity value. */
69  } SetIntensityMessage_data_t;
70 #pragma pack(pop)
71 
72  SetIntensityMessage_data_t *data;
73 
74  public:
75  SetIntensityMessage(const float ini_time_sec, const float ini_intensity);
78 
80  /* Methods */
81  float time_sec() const;
82  void set_time_sec(const float new_time_sec);
83  size_t maxlenof_time_sec() const;
84  float intensity() const;
85  void set_intensity(const float new_intensity);
86  size_t maxlenof_intensity() const;
87  virtual Message * clone() const;
88  };
89 
90  class TurnOnMessage : public Message
91  {
92  private:
93 #pragma pack(push,4)
94  /** Internal data storage, do NOT modify! */
95  typedef struct {
96  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
97  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
98  } TurnOnMessage_data_t;
99 #pragma pack(pop)
100 
101  TurnOnMessage_data_t *data;
102 
103  public:
104  TurnOnMessage();
105  ~TurnOnMessage();
106 
107  TurnOnMessage(const TurnOnMessage *m);
108  /* Methods */
109  virtual Message * clone() const;
110  };
111 
112  class TurnOffMessage : public Message
113  {
114  private:
115 #pragma pack(push,4)
116  /** Internal data storage, do NOT modify! */
117  typedef struct {
118  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
119  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
120  } TurnOffMessage_data_t;
121 #pragma pack(pop)
122 
123  TurnOffMessage_data_t *data;
124 
125  public:
126  TurnOffMessage();
127  ~TurnOffMessage();
128 
129  TurnOffMessage(const TurnOffMessage *m);
130  /* Methods */
131  virtual Message * clone() const;
132  };
133 
134  virtual bool message_valid(const Message *message) const;
135  private:
136  LedInterface();
137  ~LedInterface();
138 
139  public:
140  /* Methods */
141  float intensity() const;
142  void set_intensity(const float new_intensity);
143  size_t maxlenof_intensity() const;
144  virtual Message * create_message(const char *type) const;
145 
146  virtual void copy_values(const Interface *other);
147  virtual const char * enum_tostring(const char *enumtype, int val) const;
148 
149 };
150 
151 } // end namespace fawkes
152 
153 #endif