qa_remote_beep.cpp

00001 
00002 /***************************************************************************
00003  *  qa_beep.cpp - Order beep via remote b
00004  *
00005  *  Created: Sun Apr 11 22:21:58 2010
00006  *  Copyright  2006-2010  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 
00025 /// @cond QA
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 /// @endcond

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1