Goby3  3.1.5a
2024.05.23
waveglider_sv2_frontseat_driver.h
Go to the documentation of this file.
1 // Copyright 2017-2021:
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_MIDDLEWARE_FRONTSEAT_WAVEGLIDER_WAVEGLIDER_SV2_FRONTSEAT_DRIVER_H
25 #define GOBY_MIDDLEWARE_FRONTSEAT_WAVEGLIDER_WAVEGLIDER_SV2_FRONTSEAT_DRIVER_H
26 
27 #include <cstdint>
28 #include <memory>
29 #include <string>
30 
31 #include <boost/asio/io_service.hpp>
32 #include <boost/circular_buffer.hpp>
33 #include <dccl/codec.h>
34 
38 #include "goby/time/system_clock.h"
39 
40 namespace google
41 {
42 namespace protobuf
43 {
44 class Message;
45 } // namespace protobuf
46 } // namespace google
47 
48 namespace goby
49 {
50 namespace middleware
51 {
52 namespace frontseat
53 {
54 class SV2SerialConnection;
55 namespace protobuf
56 {
57 class Config;
58 class SV2CommandFollowFixedHeading;
59 class SV2RequestEnumerate;
60 class SV2RequestQueuedMessage;
61 class SV2RequestStatus;
62 } // namespace protobuf
63 
65 {
66  public:
68 
69  private: // virtual methods from InterfaceBase
70  void loop() override;
71 
72  void send_command_to_frontseat(const protobuf::CommandRequest& command) override;
73  void send_data_to_frontseat(const protobuf::InterfaceData& data) override;
74  void send_raw_to_frontseat(const protobuf::Raw& data) override;
75  protobuf::FrontSeatState frontseat_state() const override;
76  bool frontseat_providing_data() const override;
77 
78  void handle_sv2_message(const std::string& message);
79  void handle_enumeration_request(const protobuf::SV2RequestEnumerate& msg);
80  void handle_request_status(const protobuf::SV2RequestStatus& request);
81  void handle_request_queued_message(const protobuf::SV2RequestQueuedMessage& request);
82 
83  void check_crc(const std::string& message, uint16_t expected);
84  void add_crc(std::string* message);
85  void encode_and_write(const google::protobuf::Message& message);
86 
87  private: // internal non-virtual methods
88  void check_connection_state();
89 
90  private:
91  const protobuf::WavegliderSV2Config waveglider_sv2_config_;
92 
93  bool frontseat_providing_data_;
94  goby::time::SystemClock::time_point last_frontseat_data_time_;
95  protobuf::FrontSeatState frontseat_state_;
96 
97  boost::asio::io_service io_;
98  std::shared_ptr<SV2SerialConnection> serial_;
99 
100  boost::circular_buffer<std::shared_ptr<protobuf::SV2CommandFollowFixedHeading>>
101  queued_messages_;
102 
103  dccl::Codec dccl_;
104 };
105 } // namespace frontseat
106 } // namespace middleware
107 } // namespace goby
108 
109 #endif
goby::middleware::frontseat::protobuf::SV2RequestEnumerate
Definition: waveglider_sv2_frontseat_driver.pb.h:544
system_clock.h
goby::middleware::frontseat::protobuf::FrontSeatState
FrontSeatState
Definition: frontseat.pb.h:136
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::middleware::frontseat::protobuf::WavegliderSV2Config
Definition: waveglider_sv2_frontseat_driver_config.pb.h:77
frontseat.pb.h
goby::middleware::frontseat::InterfaceBase
Definition: interface.h:59
goby::middleware::frontseat::protobuf::SV2RequestStatus
Definition: waveglider_sv2_frontseat_driver.pb.h:996
goby::middleware::frontseat::protobuf::InterfaceData
Definition: frontseat.pb.h:795
goby::middleware::frontseat::protobuf::Config
Definition: frontseat_config.pb.h:81
goby::middleware::frontseat::InterfaceBase::cfg
const protobuf::Config & cfg() const
Definition: interface.h:103
goby::time::SystemClock::time_point
std::chrono::time_point< SystemClock > time_point
Definition: system_clock.h:55
goby::middleware::frontseat::protobuf::CommandRequest
Definition: frontseat.pb.h:488
interface.h
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
waveglider_sv2_frontseat_driver_config.pb.h
google::protobuf::Message
Definition: message.h:189
goby::middleware::frontseat::WavegliderSV2::WavegliderSV2
WavegliderSV2(const protobuf::Config &cfg)
goby::middleware::frontseat::protobuf::Raw
Definition: frontseat.pb.h:950
goby::middleware::frontseat::protobuf::SV2RequestQueuedMessage
Definition: waveglider_sv2_frontseat_driver.pb.h:1440
google
Definition: dccl.h:57
goby::middleware::frontseat::WavegliderSV2
Definition: waveglider_sv2_frontseat_driver.h:64