Fawkes API
Fawkes Development Version
qa_remote_beep.cpp
1
2
/***************************************************************************
3
* qa_beep.cpp - Order beep via remote b
4
*
5
* Created: Sun Apr 11 22:21:58 2010
6
* Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
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
/// @cond QA
25
26
#include <blackboard/remote.h>
27
#include <interfaces/SwitchInterface.h>
28
#include <utils/system/argparser.h>
29
30
#include <cstdio>
31
32
using namespace
fawkes
;
33
34
int
35
main(
int
argc,
char
**argv)
36
{
37
ArgumentParser
argp(argc, argv,
"01f:d:"
);
38
39
BlackBoard
* rbb =
new
RemoteBlackBoard
(
"localhost"
, 1910);
40
SwitchInterface
*si = rbb->
open_for_reading
<
SwitchInterface
>(
"Beep"
);
41
42
if
(argp.has_arg(
"1"
)) {
43
si->
msgq_enqueue
(
new
SwitchInterface::EnableSwitchMessage
());
44
}
else
if
(argp.has_arg(
"0"
)) {
45
si->
msgq_enqueue
(
new
SwitchInterface::DisableSwitchMessage
());
46
}
else
if
(argp.has_arg(
"d"
)) {
47
if
(!argp.has_arg(
"f"
)) {
48
printf(
"Argument -d requires to have -f as well\n"
);
49
}
else
{
50
float
d = argp.parse_float(
"d"
);
51
float
f = argp.parse_float(
"f"
);
52
si->
msgq_enqueue
(
new
SwitchInterface::EnableDurationMessage
(d, f));
53
}
54
}
else
if
(argp.has_arg(
"f"
)) {
55
float
f = argp.parse_float(
"f"
);
56
si->
msgq_enqueue
(
new
SwitchInterface::SetMessage
(
true
, f));
57
}
58
59
rbb->
close
(si);
60
delete
rbb;
61
}
62
63
/// @endcond
fawkes::SwitchInterface::SetMessage
Definition:
SwitchInterface.h:89
fawkes::SwitchInterface
Definition:
SwitchInterface.h:37
fawkes::SwitchInterface::EnableDurationMessage
Definition:
SwitchInterface.h:164
fawkes::BlackBoard
Definition:
blackboard.h:48
fawkes::RemoteBlackBoard
Definition:
remote.h:51
fawkes::SwitchInterface::DisableSwitchMessage
Definition:
SwitchInterface.h:144
fawkes::SwitchInterface::EnableSwitchMessage
Definition:
SwitchInterface.h:124
fawkes::BlackBoard::close
virtual void close(Interface *interface)=0
fawkes
fawkes::ArgumentParser
Definition:
argparser.h:67
fawkes::BlackBoard::open_for_reading
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
fawkes::Interface::msgq_enqueue
unsigned int msgq_enqueue(Message *message)
Enqueue message at end of queue.
Definition:
interface.cpp:882
src
tools
beep_daemon
qa
qa_remote_beep.cpp
Generated by
1.8.16