Fawkes API  Fawkes Development Version
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  /** Internal data storage, do NOT modify! */
54  typedef struct __attribute__((packed)) {
55  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
56  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
57  char skill_string[1024]; /**<
58  Currently executed skill string, at least the first 1023 bytes of it.
59  Must be properly null-terminated.
60  */
61  char error[128]; /**<
62  String describing the error. Can be set by a skill when it fails.
63  */
64  uint32_t exclusive_controller; /**<
65  Instance serial of the exclusive controller of the skiller. If this does not
66  carry your instance serial your exec messages will be ignored. Aquire control with
67  the AquireControlMessage. Make sure you release control before exiting.
68  */
69  uint32_t msgid; /**<
70  The ID of the message that is currently being processed,
71  or 0 if no message is being processed.
72  */
73  int32_t status; /**<
74  The status of the current skill execution.
75  */
76  } SkillerInterface_data_t;
77 
78  SkillerInterface_data_t *data;
79 
80  interface_enum_map_t enum_map_SkillStatusEnum;
81  public:
82  /* messages */
83  class ExecSkillMessage : public Message
84  {
85  private:
86  /** Internal data storage, do NOT modify! */
87  typedef struct __attribute__((packed)) {
88  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
89  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
90  char skill_string[1024]; /**<
91  Currently executed skill string, at least the first 1023 bytes of it.
92  Must be properly null-terminated.
93  */
94  } ExecSkillMessage_data_t;
95 
96  ExecSkillMessage_data_t *data;
97 
98  interface_enum_map_t enum_map_SkillStatusEnum;
99  public:
100  ExecSkillMessage(const char * ini_skill_string);
102  ~ExecSkillMessage();
103 
105  /* Methods */
106  char * skill_string() const;
107  void set_skill_string(const char * new_skill_string);
108  size_t maxlenof_skill_string() const;
109  virtual Message * clone() const;
110  };
111 
113  {
114  private:
115  /** Internal data storage, do NOT modify! */
116  typedef struct __attribute__((packed)) {
117  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
118  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
119  } RestartInterpreterMessage_data_t;
120 
121  RestartInterpreterMessage_data_t *data;
122 
123  interface_enum_map_t enum_map_SkillStatusEnum;
124  public:
127 
129  /* Methods */
130  virtual Message * clone() const;
131  };
132 
133  class StopExecMessage : public Message
134  {
135  private:
136  /** Internal data storage, do NOT modify! */
137  typedef struct __attribute__((packed)) {
138  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
139  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
140  } StopExecMessage_data_t;
141 
142  StopExecMessage_data_t *data;
143 
144  interface_enum_map_t enum_map_SkillStatusEnum;
145  public:
146  StopExecMessage();
147  ~StopExecMessage();
148 
150  /* Methods */
151  virtual Message * clone() const;
152  };
153 
155  {
156  private:
157  /** Internal data storage, do NOT modify! */
158  typedef struct __attribute__((packed)) {
159  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
160  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
161  bool steal_control; /**<
162  If set to true steal the control from someone else who has it
163  atm. Use this with caution. But sometimes it is necessary to
164  ensure a successful operation, e.g. if the agent tries to
165  acquire control.
166  */
167  } AcquireControlMessage_data_t;
168 
169  AcquireControlMessage_data_t *data;
170 
171  interface_enum_map_t enum_map_SkillStatusEnum;
172  public:
173  AcquireControlMessage(const bool ini_steal_control);
176 
178  /* Methods */
179  bool is_steal_control() const;
180  void set_steal_control(const bool new_steal_control);
181  size_t maxlenof_steal_control() const;
182  virtual Message * clone() const;
183  };
184 
186  {
187  private:
188  /** Internal data storage, do NOT modify! */
189  typedef struct __attribute__((packed)) {
190  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
191  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
192  } ReleaseControlMessage_data_t;
193 
194  ReleaseControlMessage_data_t *data;
195 
196  interface_enum_map_t enum_map_SkillStatusEnum;
197  public:
200 
202  /* Methods */
203  virtual Message * clone() const;
204  };
205 
206  virtual bool message_valid(const Message *message) const;
207  private:
209  ~SkillerInterface();
210 
211  public:
212  /* Methods */
213  char * skill_string() const;
214  void set_skill_string(const char * new_skill_string);
215  size_t maxlenof_skill_string() const;
216  char * error() const;
217  void set_error(const char * new_error);
218  size_t maxlenof_error() const;
219  uint32_t exclusive_controller() const;
220  void set_exclusive_controller(const uint32_t new_exclusive_controller);
221  size_t maxlenof_exclusive_controller() const;
222  uint32_t msgid() const;
223  void set_msgid(const uint32_t new_msgid);
224  size_t maxlenof_msgid() const;
225  SkillStatusEnum status() const;
226  void set_status(const SkillStatusEnum new_status);
227  size_t maxlenof_status() const;
228  virtual Message * create_message(const char *type) const;
229 
230  virtual void copy_values(const Interface *other);
231  virtual const char * enum_tostring(const char *enumtype, int val) const;
232 
233 };
234 
235 } // end namespace fawkes
236 
237 #endif
char * skill_string() const
Get skill_string value.
size_t maxlenof_error() const
Get maximum length of error value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
The skill string has been successfully processed.
size_t maxlenof_skill_string() const
Get maximum length of skill_string value.
void set_exclusive_controller(const uint32_t new_exclusive_controller)
Set exclusive_controller value.
Fawkes library namespace.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
StopExecMessage Fawkes BlackBoard Interface Message.
virtual void copy_values(const Interface *other)
Copy values from other interface.
char * error() const
Get error value.
ReleaseControlMessage Fawkes BlackBoard Interface Message.
SkillStatusEnum
This determines the current status of skill execution.
uint32_t exclusive_controller() const
Get exclusive_controller value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
AcquireControlMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_exclusive_controller() const
Get maximum length of exclusive_controller value.
void set_error(const char *new_error)
Set error value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
SkillStatusEnum status() const
Get status value.
ExecSkillMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_status() const
Get maximum length of status value.
RestartInterpreterMessage Fawkes BlackBoard Interface Message.
The execution failed and cannot succeed anymore.
void set_skill_string(const char *new_skill_string)
Set skill_string value.
uint32_t msgid() const
Get msgid value.
SkillerInterface Fawkes BlackBoard Interface.
void set_status(const SkillStatusEnum new_status)
Set status value.
virtual Message * create_message(const char *type) const
Create message based on type name.
const char * tostring_SkillStatusEnum(SkillStatusEnum value) const
Convert SkillStatusEnum constant to string.
The execution is still running.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:53
void set_msgid(const uint32_t new_msgid)
Set msgid value.