Fawkes API
Fawkes Development Version
|
23 #include <blackboard/remote.h>
24 #include <core/threading/thread.h>
25 #include <interfaces/SkillerInterface.h>
26 #include <netcomm/fawkes/client.h>
27 #include <netcomm/fawkes/client_handler.h>
28 #include <readline/history.h>
29 #include <readline/readline.h>
30 #include <utils/system/argparser.h>
31 #include <utils/system/signal.h>
43 print_usage(
const char *program_name)
45 printf(
"Usage: %s [-h] [-r host[:port]]\n"
46 " -h This help message\n"
47 " -r host[:port] Remote host (and optionally port) to connect to\n",
74 just_connected =
true;
75 connection_died_recently =
false;
80 rl_event_hook = event_hook;
82 char * host = (
char *)
"localhost";
83 unsigned short int port = 1910;
91 c->register_handler(
this, FAWKES_CID_SKILLER_PLUGIN);
98 printf(
"Finalizing\n");
101 sif->msgq_enqueue(rcm);
109 c->deregister_handler(FAWKES_CID_SKILLER_PLUGIN);
117 if (c->connected()) {
118 if (just_connected) {
119 just_connected =
false;
125 sif->msgq_enqueue(aqm);
133 if (argp->num_items() > 0) {
135 const std::vector<const char *> &items = argp->items();
137 std::vector<const char *>::const_iterator i = items.begin();
140 for (; i != items.end(); ++i) {
147 sif->msgq_enqueue(esm);
152 char *line = readline(prompt);
154 if (strcmp(line,
"") != 0) {
155 if (strcmp(line,
"stop") == 0) {
156 printf(
"Stopping skill execution\n");
158 sif->msgq_enqueue(sm);
160 printf(
"Executing: %s\n", line);
163 sif->msgq_enqueue(esm);
169 if (!connection_died_recently) {
175 if (connection_died_recently) {
176 connection_died_recently =
false;
177 printf(
"Connection died\n");
210 connection_died_recently =
true;
220 printf(
"Connection established\n");
221 just_connected =
true;
232 bool connection_died_recently;
240 main(
int argc,
char **argv)
244 if (argp.has_arg(
"h")) {
245 print_usage(argv[0]);
bool parse_hostport(const char *argn, char **host, unsigned short int *port)
Parse host:port string.
virtual void deregistered(unsigned int id)
This handler has been deregistered.
ReleaseControlMessage Fawkes BlackBoard Interface Message.
SkillShellThread(ArgumentParser *argp)
Constructor.
The BlackBoard abstract class.
AcquireControlMessage Fawkes BlackBoard Interface Message.
ExecSkillMessage Fawkes BlackBoard Interface Message.
StopExecMessage Fawkes BlackBoard Interface Message.
Message handler for FawkesNetworkClient.
virtual void connection_established(unsigned int id)
Client has established a connection.
Fawkes library namespace.
Parse command line arguments.
virtual void loop()
Code to execute in the thread.
void print_trace()
Prints trace to stderr.
virtual void connection_died(unsigned int id)
Client connection died.
SkillerInterface Fawkes BlackBoard Interface.
~SkillShellThread()
Destructor.
Thread class encapsulation of pthreads.
Representation of a message that is sent over the network.
Simple Fawkes network client.
virtual void inbound_received(FawkesNetworkMessage *m, unsigned int id)
Called for incoming messages.
Base class for exceptions in Fawkes.