Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
acomms/libmodemdriver/driver_base.h
00001 // copyright 2009-2011 t. schneider tes@mit.edu
00002 // 
00003 // this file is part of the goby-acomms acoustic modem driver.
00004 // goby-acomms is a collection of libraries 
00005 // for acoustic underwater networking
00006 //
00007 // This program is free software: you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation, either version 3 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // This software is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this software.  If not, see <http://www.gnu.org/licenses/>.
00019 
00020 #ifndef DriverBase20091214H
00021 #define DriverBase20091214H
00022 
00023 #include <boost/thread.hpp>
00024 #include <boost/signal.hpp>
00025 
00026 #include "goby/acomms/acomms_constants.h"
00027 #include "goby/protobuf/modem_message.pb.h"
00028 #include "goby/protobuf/driver_base.pb.h"
00029 #include "goby/util/linebasedcomms.h"
00030 #include "goby/protobuf/acomms_proto_helpers.h"
00031 
00032 namespace goby
00033 {
00034     namespace util { class FlexOstream; }    
00035 
00036     namespace acomms
00037     {
00042         class ModemDriverBase
00043         {
00044           public:
00046 
00047 
00051             virtual void startup(const protobuf::DriverConfig& cfg) = 0;
00052 
00054             virtual void shutdown() = 0;
00055 
00059             virtual void do_work() = 0;
00061 
00063 
00064 
00065 
00066 
00067             virtual void handle_initiate_transmission(protobuf::ModemMsgBase* m) = 0;            
00071             virtual void handle_initiate_ranging(protobuf::ModemRangingRequest* m) {};
00072             
00074 
00076 
00077 
00081             boost::signal<void (const protobuf::ModemDataTransmission& message)>
00082                 signal_receive;
00083 
00087             boost::signal<void (const protobuf::ModemDataRequest& msg_request, protobuf::ModemDataTransmission* msg_data)>
00088                 signal_data_request;
00089             
00093             boost::signal<void (const protobuf::ModemRangingReply& message)>
00094                 signal_range_reply;
00095 
00099             boost::signal<void (const protobuf::ModemDataAck& message)>
00100                 signal_ack;
00101 
00105             boost::signal<void (const protobuf::ModemMsgBase& msg_data)>
00106                 signal_all_incoming;
00107             
00111             boost::signal<void (const protobuf::ModemMsgBase& msg_data)>
00112                 signal_all_outgoing;
00114 
00116 
00117 
00118 
00119 
00120             static void add_flex_groups(util::FlexOstream* tout);
00122 
00124             virtual ~ModemDriverBase();
00125             
00126           protected:
00128 
00129             
00133             ModemDriverBase(std::ostream* log = 0);
00134 
00136 
00137             
00139 
00140             
00144             void modem_write(const std::string& out);
00145 
00146         
00151             bool modem_read(std::string* in);
00152 
00158             void modem_start(const protobuf::DriverConfig& cfg);
00159 
00161             void modem_close();
00162 
00163             
00165 
00166           private:
00167             std::ostream* log_;
00168 
00169             // represents the line based communications interface to the modem
00170             util::LineBasedInterface* modem_;
00171         };
00172     }
00173 }
00174 #endif
00175 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends