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]);
Message handler for FawkesNetworkClient.
SkillShellThread(ArgumentParser *argp)
Constructor.
virtual void deregistered(unsigned int id)
This handler has been deregistered.
bool parse_hostport(const char *argn, char **host, unsigned short int *port)
Parse host:port string.
Simple Fawkes network client.
Fawkes library namespace.
StopExecMessage Fawkes BlackBoard Interface Message.
Representation of a message that is sent over the network.
Parse command line arguments.
ReleaseControlMessage Fawkes BlackBoard Interface Message.
Thread class encapsulation of pthreads.
AcquireControlMessage Fawkes BlackBoard Interface Message.
Base class for exceptions in Fawkes.
ExecSkillMessage Fawkes BlackBoard Interface Message.
virtual void connection_established(unsigned int id)
Client has established a connection.
void print_trace()
Prints trace to stderr.
virtual void loop()
Code to execute in the thread.
virtual void connection_died(unsigned int id)
Client connection died.
SkillerInterface Fawkes BlackBoard Interface.
The BlackBoard abstract class.
~SkillShellThread()
Destructor.
virtual void inbound_received(FawkesNetworkMessage *m, unsigned int id)
Called for incoming messages.