26 #include <boost/asio.hpp> 27 #include <boost/asio/time_traits.hpp> 28 #include <boost/bind.hpp> 29 #include <boost/foreach.hpp> 30 #include <boost/function.hpp> 31 #include <boost/lexical_cast.hpp> 33 #include "goby/acomms/modem_driver.h" 34 #include "goby/acomms/protobuf/amac.pb.h" 35 #include "goby/acomms/protobuf/amac_config.pb.h" 36 #include "goby/acomms/protobuf/modem_message.pb.h" 37 #include "goby/common/time.h" 38 #include "goby/util/as.h" 51 class MACManager :
public std::list<protobuf::ModemTransmission>
81 bool running() {
return started_up_; }
87 boost::signals2::signal<void(const protobuf::ModemTransmission& m)>
102 unsigned cycle_count() {
return std::list<protobuf::ModemTransmission>::size(); }
103 double cycle_duration();
105 boost::asio::io_service& get_io_service() {
return io_; }
107 const std::string& glog_mac_group()
const {
return glog_mac_group_; }
110 void begin_slot(
const boost::system::error_code&);
111 boost::posix_time::ptime next_cycle_time();
113 void increment_slot();
115 void restart_timer();
118 unsigned cycle_sum();
119 void position_blank();
124 ALLOWED_SKEW_SECONDS = 2
134 boost::asio::io_service io_;
136 boost::asio::basic_deadline_timer<goby::common::GobyTime> timer_;
138 boost::asio::io_service::work work_;
140 boost::posix_time::ptime next_cycle_t_;
141 boost::posix_time::ptime next_slot_t_;
143 std::list<protobuf::ModemTransmission>::iterator current_slot_;
145 unsigned cycles_since_reference_;
149 std::string glog_mac_group_;
155 inline bool operator==(
const ModemTransmission& a,
const ModemTransmission& b)
157 return a.SerializeAsString() == b.SerializeAsString();
161 inline std::ostream& operator<<(std::ostream& os,
const MACManager& mac)
163 for (std::list<protobuf::ModemTransmission>::const_iterator it = mac.begin(), n = mac.end();
165 { os << *it; }
return os;
void startup(const protobuf::MACConfig &cfg)
Starts the MAC with given configuration.
void do_work()
Allows the MAC timer to do its work. Does not block. If you prefer more control you can directly cont...
provides an API to the goby-acomms MAC library. MACManager is essentially a std::list<protobuf::Modem...
MACManager()
Default constructor.
void shutdown()
Shutdown the MAC.
The global namespace for the Goby project.
boost::signals2::signal< void(const protobuf::ModemTransmission &m)> signal_slot_start
Signals the start of all transmissions (even when we don't transmit)
void restart()
Restarts the MAC with original configuration.
void update()
You must call this after any change to the underlying list that would invalidate iterators or change ...
boost::signals2::signal< void(const protobuf::ModemTransmission &m)> signal_initiate_transmission
Signals when it is time for this platform to begin transmission of an acoustic message at the start o...