23 #include "naoqi_broker.h"
25 #include <baseapp/run.h>
26 #include <baseapp/main_thread.h>
27 #include <core/exception.h>
28 #include <core/threading/thread.h>
29 #include <plugin/manager.h>
30 #include <utils/system/dynamic_module/module.h>
32 #include <alcore/altypes.h>
33 #include <alcommon/albroker.h>
34 #include <alcommon/albrokermanager.h>
35 #include <alcommon/almodule.h>
36 #include <alproxies/allauncherproxy.h>
37 #include <alproxies/alaudioplayerproxy.h>
38 #include <alproxies/alloggerproxy.h>
60 : AL::ALModule(broker, name), broker(broker)
62 setModuleDescription(
"Fawkes integration module");
64 AL::ALPtr<AL::ALLoggerProxy> logger = broker->getLoggerProxy();
67 logger->info(
"NaoQiFawkes",
"*** Initializing embedded Fawkes");
79 .
loggers(
"console;syslog:NaoQiFawkes")
83 if (fawkes::runtime::init(init_options) != 0) {
85 logger->info(
"NaoQiFawkes",
"--- Fawkes initialization failed");
86 play_sound(RESDIR
"/sounds/naoshutdown.wav");
89 logger->info(
"NaoQiFawkes",
"*** Starting embedded Fawkes");
91 logger->info(
"NaoQiFawkes",
"*** Embedded Fawkes initialization done");
92 play_sound(RESDIR
"/sounds/naostartup.wav");
97 if (i != e.
begin()) message +=
"\n";
100 logger->info(
"NaoQiFawkes",
101 "--- Fawkes initialization failed, exception follows.");
102 logger->info(
"NaoQiFawkes", message);
103 play_sound(RESDIR
"/sounds/naoshutdown.wav");
114 fawkes::runtime::main_thread->
cancel();
115 fawkes::runtime::main_thread->
join();
116 fawkes::runtime::cleanup();
123 play_sound(
const char *filename)
127 AL::ALPtr<AL::ALLauncherProxy> launcher(
new AL::ALLauncherProxy(broker));
128 bool is_auplayer_available = launcher->isModulePresent(
"ALAudioPlayer");
130 if (is_auplayer_available) {
131 AL::ALPtr<AL::ALAudioPlayerProxy>
132 auplayer(
new AL::ALAudioPlayerProxy(broker));
133 auplayer->playFile(filename);
135 }
catch (AL::ALError& e) {}
138 AL::ALPtr<AL::ALBroker> broker;
148 _createModule(AL::ALPtr<AL::ALBroker> broker)
153 AL::ALPtr<AL::ALLoggerProxy> logger = broker->getLoggerProxy();
155 logger->info(
"NaoQiFawkes",
"*** Setting broker stuff");
156 AL::ALBrokerManager::setInstance(broker->fBrokerManager.lock());
157 AL::ALBrokerManager::getInstance()->addBroker(broker);
159 fawkes::naoqi::broker = broker;
162 logger->info(
"NaoQiFawkes",
"*** Instantiating Module");
163 AL::ALModule::createModule<NaoFawkesModule>(broker,
"NaoFawkesModule");