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