Goby3  3.1.5a
2024.05.23
store_server_driver.h
Go to the documentation of this file.
1 // Copyright 2024:
2 // GobySoft, LLC (2013-)
3 // Community contributors (see AUTHORS file)
4 // File authors:
5 // Toby Schneider <toby@gobysoft.org>
6 //
7 //
8 // This file is part of the Goby Underwater Autonomy Project Libraries
9 // ("The Goby Libraries").
10 //
11 // The Goby Libraries are free software: you can redistribute them and/or modify
12 // them under the terms of the GNU Lesser General Public License as published by
13 // the Free Software Foundation, either version 2.1 of the License, or
14 // (at your option) any later version.
15 //
16 // The Goby Libraries are distributed in the hope that they will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public License
22 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
23 
24 #ifndef GOBY_ACOMMS_MODEMDRIVER_STORE_SERVER_DRIVER_H
25 #define GOBY_ACOMMS_MODEMDRIVER_STORE_SERVER_DRIVER_H
26 
27 #include "goby/time/system_clock.h"
28 
33 
34 namespace goby
35 {
36 namespace acomms
37 {
39 {
40  public:
42  void startup(const protobuf::DriverConfig& cfg);
43  void shutdown();
44  void do_work();
46 
47  constexpr static const char* eol{"\r"};
48  constexpr static int default_port{11244};
49 
50  template <typename StoreServerMessage>
51  static void parse_store_server_message(const std::string& bytes, StoreServerMessage* msg)
52  {
53  std::string pb_encoded;
54  goby::acomms::parse_rudics_packet(&pb_encoded, bytes, std::string(eol));
55  msg->ParseFromString(pb_encoded);
56  }
57 
58  template <typename StoreServerMessage>
59  static void serialize_store_server_message(const StoreServerMessage& msg, std::string* bytes)
60  {
61  std::string pb_encoded;
62  msg.SerializeToString(&pb_encoded);
63  goby::acomms::serialize_rudics_packet(pb_encoded, bytes, std::string(eol));
64  }
65 
66  private:
67  void handle_response(const protobuf::StoreServerResponse& response);
68 
69  private:
70  protobuf::DriverConfig driver_cfg_;
71  store_server::protobuf::Config store_server_driver_cfg_;
73  std::uint64_t last_send_time_;
74  double query_interval_seconds_;
75  double reset_interval_seconds_;
76  bool waiting_for_reply_;
77  std::uint32_t next_frame_;
78 };
79 } // namespace acomms
80 } // namespace goby
81 #endif
goby::acomms::protobuf::DriverConfig
Definition: driver_base.pb.h:123
goby::acomms::protobuf::ModemTransmission
Definition: modem_message.pb.h:166
goby::acomms::parse_rudics_packet
void parse_rudics_packet(std::string *bytes, std::string rudics_pkt, const std::string &reserved=std::string("\0\r\n", 3)+std::string(1, 0xff), bool include_crc=true)
goby::acomms::StoreServerDriver::eol
constexpr static const char * eol
Definition: store_server_driver.h:47
system_clock.h
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::acomms::StoreServerDriver::startup
void startup(const protobuf::DriverConfig &cfg)
Starts the modem driver. Must be called before poll().
goby::acomms::StoreServerDriver::StoreServerDriver
StoreServerDriver()
goby::acomms::serialize_rudics_packet
void serialize_rudics_packet(std::string bytes, std::string *rudics_pkt, const std::string &reserved=std::string("\0\r\n", 3)+std::string(1, 0xff), bool include_crc=true)
iridium_rudics_packet.h
goby::acomms::StoreServerDriver
Definition: store_server_driver.h:38
goby::acomms::store_server::protobuf::Config
Definition: store_server_driver.pb.h:102
driver_base.h
goby::acomms::StoreServerDriver::serialize_store_server_message
static void serialize_store_server_message(const StoreServerMessage &msg, std::string *bytes)
Definition: store_server_driver.h:59
goby::msg
extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, ::google::protobuf::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
Definition: option_extensions.pb.h:1327
store_server.pb.h
goby::acomms::StoreServerDriver::do_work
void do_work()
Allows the modem driver to do its work.
goby::acomms::StoreServerDriver::parse_store_server_message
static void parse_store_server_message(const std::string &bytes, StoreServerMessage *msg)
Definition: store_server_driver.h:51
goby::acomms::ModemDriverBase
provides an abstract base class for acoustic modem drivers. This is subclassed by the various drivers...
Definition: driver_base.h:58
goby::acomms::protobuf::StoreServerResponse
Definition: store_server.pb.h:214
goby::acomms::protobuf::StoreServerRequest
Definition: store_server.pb.h:77
store_server_driver.pb.h
goby::acomms::StoreServerDriver::default_port
constexpr static int default_port
Definition: store_server_driver.h:48
goby::acomms::StoreServerDriver::shutdown
void shutdown()
Shuts down the modem driver.
goby::acomms::StoreServerDriver::handle_initiate_transmission
void handle_initiate_transmission(const protobuf::ModemTransmission &m)
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...