Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SkillerInterface.h
1 
2 /***************************************************************************
3  * SkillerInterface.h - Fawkes BlackBoard Interface - SkillerInterface
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_SKILLERINTERFACE_H_
25 #define __INTERFACES_SKILLERINTERFACE_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(SkillerInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  /**
42  This determines the current status of skill execution.
43  */
44  typedef enum {
45  S_INACTIVE /**< No skill is running. */,
46  S_FINAL /**< The skill string has been successfully processed. */,
47  S_RUNNING /**< The execution is still running. */,
48  S_FAILED /**< The execution failed and cannot succeed anymore. */
50  const char * tostring_SkillStatusEnum(SkillStatusEnum value) const;
51 
52  private:
53 #pragma pack(push,4)
54  /** Internal data storage, do NOT modify! */
55  typedef struct {
56  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
57  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
58  char skill_string[1024]; /**<
59  Currently executed skill string, at least the first 1023 bytes of it.
60  Must be properly null-terminated.
61  */
62  char error[128]; /**<
63  String describing the error. Can be set by a skill when it fails.
64  */
65  uint32_t exclusive_controller; /**<
66  Instance serial of the exclusive controller of the skiller. If this does not
67  carry your instance serial your exec messages will be ignored. Aquire control with
68  the AquireControlMessage. Make sure you release control before exiting.
69  */
70  int32_t status; /**<
71  The status of the current skill execution.
72  */
73  bool continuous; /**<
74  True if continuous execution is in progress, false if no skill string is executed
75  at all or it is executed one-shot with ExecSkillMessage.
76  */
77  } SkillerInterface_data_t;
78 #pragma pack(pop)
79 
80  SkillerInterface_data_t *data;
81 
82  public:
83  /* messages */
84  class ExecSkillMessage : public Message
85  {
86  private:
87 #pragma pack(push,4)
88  /** Internal data storage, do NOT modify! */
89  typedef struct {
90  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
91  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
92  char skill_string[1024]; /**<
93  Currently executed skill string, at least the first 1023 bytes of it.
94  Must be properly null-terminated.
95  */
96  } ExecSkillMessage_data_t;
97 #pragma pack(pop)
98 
99  ExecSkillMessage_data_t *data;
100 
101  public:
102  ExecSkillMessage(const char * ini_skill_string);
105 
107  /* Methods */
108  char * skill_string() const;
109  void set_skill_string(const char * new_skill_string);
110  size_t maxlenof_skill_string() const;
111  virtual Message * clone() const;
112  };
113 
115  {
116  private:
117 #pragma pack(push,4)
118  /** Internal data storage, do NOT modify! */
119  typedef struct {
120  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
121  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
122  char skill_string[1024]; /**<
123  Currently executed skill string, at least the first 1023 bytes of it.
124  Must be properly null-terminated.
125  */
126  } ExecSkillContinuousMessage_data_t;
127 #pragma pack(pop)
128 
129  ExecSkillContinuousMessage_data_t *data;
130 
131  public:
132  ExecSkillContinuousMessage(const char * ini_skill_string);
135 
137  /* Methods */
138  char * skill_string() const;
139  void set_skill_string(const char * new_skill_string);
140  size_t maxlenof_skill_string() const;
141  virtual Message * clone() const;
142  };
143 
145  {
146  private:
147 #pragma pack(push,4)
148  /** Internal data storage, do NOT modify! */
149  typedef struct {
150  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
151  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
152  } RestartInterpreterMessage_data_t;
153 #pragma pack(pop)
154 
155  RestartInterpreterMessage_data_t *data;
156 
157  public:
160 
162  /* Methods */
163  virtual Message * clone() const;
164  };
165 
166  class StopExecMessage : public Message
167  {
168  private:
169 #pragma pack(push,4)
170  /** Internal data storage, do NOT modify! */
171  typedef struct {
172  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
173  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
174  } StopExecMessage_data_t;
175 #pragma pack(pop)
176 
177  StopExecMessage_data_t *data;
178 
179  public:
180  StopExecMessage();
182 
184  /* Methods */
185  virtual Message * clone() const;
186  };
187 
189  {
190  private:
191 #pragma pack(push,4)
192  /** Internal data storage, do NOT modify! */
193  typedef struct {
194  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
195  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
196  } AcquireControlMessage_data_t;
197 #pragma pack(pop)
198 
199  AcquireControlMessage_data_t *data;
200 
201  public:
204 
206  /* Methods */
207  virtual Message * clone() const;
208  };
209 
211  {
212  private:
213 #pragma pack(push,4)
214  /** Internal data storage, do NOT modify! */
215  typedef struct {
216  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
217  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
218  } ReleaseControlMessage_data_t;
219 #pragma pack(pop)
220 
221  ReleaseControlMessage_data_t *data;
222 
223  public:
226 
228  /* Methods */
229  virtual Message * clone() const;
230  };
231 
232  virtual bool message_valid(const Message *message) const;
233  private:
235  ~SkillerInterface();
236 
237  public:
238  /* Methods */
239  char * skill_string() const;
240  void set_skill_string(const char * new_skill_string);
241  size_t maxlenof_skill_string() const;
242  char * error() const;
243  void set_error(const char * new_error);
244  size_t maxlenof_error() const;
245  uint32_t exclusive_controller() const;
246  void set_exclusive_controller(const uint32_t new_exclusive_controller);
247  size_t maxlenof_exclusive_controller() const;
248  SkillStatusEnum status() const;
249  void set_status(const SkillStatusEnum new_status);
250  size_t maxlenof_status() const;
251  bool is_continuous() const;
252  void set_continuous(const bool new_continuous);
253  size_t maxlenof_continuous() const;
254  virtual Message * create_message(const char *type) const;
255 
256  virtual void copy_values(const Interface *other);
257  virtual const char * enum_tostring(const char *enumtype, int val) const;
258 
259 };
260 
261 } // end namespace fawkes
262 
263 #endif