00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <blackboard/remote.h>
00028 #include <interfaces/SwitchInterface.h>
00029 #include <utils/system/argparser.h>
00030
00031 #include <cstdio>
00032
00033 using namespace fawkes;
00034
00035 int
00036 main(int argc, char **argv)
00037 {
00038 ArgumentParser argp(argc, argv, "01f:d:");
00039
00040 BlackBoard *rbb = new RemoteBlackBoard("localhost", 1910);
00041 SwitchInterface *si = rbb->open_for_reading<SwitchInterface>("Beep");
00042
00043 if (argp.has_arg("1")) {
00044 si->msgq_enqueue(new SwitchInterface::EnableSwitchMessage());
00045 } else if (argp.has_arg("0")) {
00046 si->msgq_enqueue(new SwitchInterface::DisableSwitchMessage());
00047 } else if (argp.has_arg("d")) {
00048 if ( ! argp.has_arg("f") ) {
00049 printf("Argument -d requires to have -f as well\n");
00050 } else {
00051 float d = argp.parse_float("d");
00052 float f = argp.parse_float("f");
00053 si->msgq_enqueue(new SwitchInterface::EnableDurationMessage(d, f));
00054 }
00055 } else if (argp.has_arg("f")) {
00056 float f = argp.parse_float("f");
00057 si->msgq_enqueue(new SwitchInterface::SetMessage(true, f));
00058 }
00059
00060 rbb->close(si);
00061 delete rbb;
00062 }
00063
00064
00065