22 #ifndef __PLUGINS_PLEXIL_PROTOBUF_ADAPTER_H_
23 #define __PLUGINS_PLEXIL_PROTOBUF_ADAPTER_H_
25 #include <config/config.h>
26 #include <logging/logger.h>
27 #include <protobuf_comm/peer.h>
28 #include <utils/time/clock.h>
29 #include <utils/time/time.h>
31 #include <InterfaceAdapter.hh>
64 std::vector<std::string> messages;
65 std::vector<PLEXIL::Command *> recipients;
71 std::string from_host;
73 std::shared_ptr<google::protobuf::Message> message;
77 void proc_receive_command(PLEXIL::Command *cmd);
78 void proc_get_param_command(PLEXIL::Command *cmd);
79 void proc_send_rv_command(PLEXIL::Command *cmd);
81 void add_recipient(
const std::string &msg_type, PLEXIL::Command *cmd);
82 void remove_recipient(
const std::string &msg_type, PLEXIL::Command *cmd);
84 std::string gen_msgid(
const std::string &msg_type);
85 void add_message(
const std::string &msg_type, message_meta &&msg);
86 void release_message(
const std::string &msg_id);
87 std::shared_ptr<google::protobuf::Message> get_message(
const std::string &msg_id);
89 void proc_queue(
const std::string &msg_type);
90 queue_entry &get_queue(
const std::string &msg_type);
92 void pb_create(PLEXIL::Command *cmd);
93 void pb_destroy(PLEXIL::Command *cmd);
94 void pb_set_value(PLEXIL::Command *cmd);
95 void pb_get_value(PLEXIL::Command *cmd, PLEXIL::ValueType value_type);
96 void pb_get_length(PLEXIL::Command *cmd);
97 void pb_has_field(PLEXIL::Command *cmd);
98 void pb_tostring(PLEXIL::Command *cmd);
99 void pb_broadcast(PLEXIL::Command *cmd);
101 void pb_peer_create(PLEXIL::Command *cmd);
102 void pb_peer_create_local(PLEXIL::Command *cmd);
103 void pb_peer_create_crypto(PLEXIL::Command *cmd);
104 void pb_peer_create_local_crypto(PLEXIL::Command * cmd,
105 const std::vector<PLEXIL::Value> *args =
nullptr);
106 void pb_peer_destroy(PLEXIL::Command *cmd);
107 void pb_peer_setup_crypto(PLEXIL::Command *cmd);
109 void handle_peer_msg(
int peer_id,
110 boost::asio::ip::udp::endpoint & endpoint,
111 uint16_t component_id,
113 std::shared_ptr<google::protobuf::Message> msg);
115 handle_peer_recv_error(
int peer_id, boost::asio::ip::udp::endpoint &endpoint, std::string msg);
116 void handle_peer_send_error(
int peer_id, std::string msg);
123 std::mutex queue_mutex_;
124 std::map<std::string, queue_entry> queue_;
125 std::map<std::string, message_meta> messages_;
126 unsigned long int msg_counter_;
128 typedef std::map<int, std::shared_ptr<protobuf_comm::ProtobufBroadcastPeer>> PeerMap;
131 std::mutex map_mutex_;
132 std::shared_ptr<protobuf_comm::MessageRegister> message_register_;
135 std::map<std::string, std::function<void(PLEXIL::Command *)>> commands_;
139 void initProtobufCommAdapter();
Interface adapter to provide logging facilities.
virtual bool initialize()
Initialize adapter.
virtual bool start()
Start adapter.
void executeCommand(PLEXIL::Command *cmd)
Perform given command.
void invokeAbort(PLEXIL::Command *cmd)
Abort currently running execution.
virtual bool shutdown()
Shut adapter down.
virtual ~ProtobufCommPlexilAdapter()
Destructor.
virtual bool reset()
Reset adapter.
ProtobufCommPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
virtual bool stop()
Stop adapter.
This is supposed to be the central clock in Fawkes.
Interface for configuration handling.
A class for handling time.