24 #ifndef GOBY_MOOS_MIDDLEWARE_MOOS_PLUGIN_TRANSLATOR_H
25 #define GOBY_MOOS_MIDDLEWARE_MOOS_PLUGIN_TRANSLATOR_H
35 #include <MOOS/libMOOS/Comms/MOOSMsg.h>
36 #include <MOOS/libMOOS/DB/MsgFilter.h>
37 #include <boost/units/quantity.hpp>
38 #include <boost/units/systems/si/frequency.hpp>
40 #include "MOOS/libMOOS/Comms/MOOSAsyncCommClient.h"
45 class CMOOSCommClient;
62 ss << std::this_thread::get_id();
63 return std::string(
"goby::moos::Translator::" + ss.str());
71 const std::function<
void(
const CMOOSMsg&)>& func)
73 trigger_vars_.insert(std::make_pair(moos_var, func));
75 moos_register(moos_var);
79 const std::string& moos_app_wildcard,
80 const std::function<
void(
const CMOOSMsg&)>& func)
82 MOOS::MsgFilter moos_filter(moos_app_wildcard, moos_var_wildcard);
83 trigger_wildcard_vars_.insert(std::make_pair(moos_filter, func));
85 moos_wildcard_register(moos_filter);
90 buffer_vars_.insert(moos_var);
92 moos_register(moos_var);
94 std::map<std::string, CMOOSMsg>&
buffer() {
return buffer_; }
95 CMOOSCommClient&
comms() {
return comms_; }
102 void moos_register(
const std::string& moos_var)
104 comms_.Register(moos_var);
108 void moos_wildcard_register(
const MOOS::MsgFilter& moos_filter)
110 comms_.Register(moos_filter.var_filter(), moos_filter.app_filter(), 0);
112 goby::glog <<
"Subscribed for MOOS wildcard: variable: " << moos_filter.var_filter()
113 <<
", app: " << moos_filter.app_filter() << std::endl;
117 std::map<std::string, std::function<
void(
const CMOOSMsg&)>> trigger_vars_;
118 std::map<MOOS::MsgFilter, std::function<
void(
const CMOOSMsg&)>> trigger_wildcard_vars_;
119 std::set<std::string> buffer_vars_;
120 std::map<std::string, CMOOSMsg> buffer_;
121 MOOS::MOOSAsyncCommClient comms_;
123 bool connected_{
false};
135 template <
template <
class>
class ThreadType>
137 public ThreadType<goby::apps::moos::protobuf::GobyMOOSGatewayConfig>
142 ThreadType<
goby::apps::
moos::protobuf::GobyMOOSGatewayConfig>(
149 ThreadType<goby::apps::moos::protobuf::GobyMOOSGatewayConfig>&
goby() {
return *
this; }