Fawkes API Fawkes Development Version
remote_adapter.h
1
2/***************************************************************************
3 * remote_adapter.h - Access Fawkes remotely from PLEXIL
4 *
5 * Created: Mon Aug 20 12:58:05 2018
6 * Copyright 2006-2018 Tim Niemueller [www.niemueller.de]
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef __PLUGINS_PLEXIL_REMOTE_ADAPTER_H_
23#define __PLUGINS_PLEXIL_REMOTE_ADAPTER_H_
24
25#include <core/utils/lockptr.h>
26#include <utils/system/fam.h>
27
28#include <InterfaceAdapter.hh>
29#include <Value.hh>
30#include <functional>
31#include <map>
32#include <memory>
33#include <mutex>
34#include <string>
35#include <thread>
36
37namespace fawkes {
38class BlackBoard;
39class Logger;
40class NavGraph;
41class Clock;
42class NetworkConfiguration;
43class FawkesNetworkClient;
44class FileAlterationMonitor;
45} // namespace fawkes
46
47/** Interface adapter to provide logging facilities. */
48class FawkesRemotePlexilAdapter : public PLEXIL::InterfaceAdapter, public fawkes::FamListener
49{
50public:
51 FawkesRemotePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface);
52 FawkesRemotePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface, pugi::xml_node const xml);
53
54 /// @cond DELETED
57 FawkesRemotePlexilAdapter &operator=(const FawkesRemotePlexilAdapter &) = delete;
58 /// @endcond
59
61
62 virtual bool initialize();
63 virtual bool start();
64 virtual bool stop();
65 virtual bool reset();
66 virtual bool shutdown();
67
68 void executeCommand(PLEXIL::Command *cmd);
69 void invokeAbort(PLEXIL::Command *cmd);
70
71 virtual void fam_event(const char *filename, unsigned int mask);
72
73private:
74 std::string cfg_navgraph_filename_;
75
76 fawkes::Clock * clock_;
77 std::unique_ptr<fawkes::FawkesNetworkClient> client_;
78 std::unique_ptr<fawkes::Logger> logger_;
79 std::unique_ptr<fawkes::BlackBoard> blackboard_;
80 std::unique_ptr<fawkes::NetworkConfiguration> config_;
82 std::unique_ptr<fawkes::FileAlterationMonitor> navgraph_fam_;
83 std::mutex navgraph_fam_mutex_;
84 std::thread navgraph_fam_thread_;
85
86 std::map<std::string, std::function<void(PLEXIL::Command *)>> commands_;
87};
88
89extern "C" {
90void initNavGraphAdapter();
91}
92
93#endif
Interface adapter to provide logging facilities.
virtual bool reset()
Reset adapter.
virtual bool shutdown()
Shut adapter down.
void executeCommand(PLEXIL::Command *cmd)
Perform given command.
virtual void fam_event(const char *filename, unsigned int mask)
Event has been raised.
virtual bool initialize()
Initialize adapter.
void invokeAbort(PLEXIL::Command *cmd)
Abort currently running execution.
virtual ~FawkesRemotePlexilAdapter()
Destructor.
virtual bool stop()
Stop adapter.
virtual bool start()
Start adapter.
FawkesRemotePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
This is supposed to be the central clock in Fawkes.
Definition: clock.h:35
File Alteration Monitor Listener.
Definition: fam.h:36
Fawkes library namespace.