Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
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
39
40namespace google
41{
42namespace protobuf
43{
44class Message;
45} // namespace protobuf
46} // namespace google
47
48namespace goby
49{
50namespace middleware
51{
52namespace frontseat
53{
54class SV2SerialConnection;
55namespace protobuf
56{
57class Config;
58class SV2CommandFollowFixedHeading;
59class SV2RequestEnumerate;
60class SV2RequestQueuedMessage;
61class 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
const protobuf::Config & cfg() const
Definition interface.h:104
WavegliderSV2(const protobuf::Config &cfg)
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
Definition dccl.h:58
std::chrono::time_point< SystemClock > time_point