|
waterlinkedsonar
C++ client library for the Water Linked Sonar 3D-15
|
Receives datagrams on a thread of its own, decodes them and passes the messages to the registered callbacks. More...
#include <waterlinkedsonar/udp/receiver.hpp>
Public Member Functions | |
| Receiver (UdpSocket socket, ReceiverOptions options={}) | |
Takes over socket. | |
| ~Receiver () | |
| Calls stop(). | |
| Receiver (const Receiver &)=delete | |
| Receiver & | operator= (const Receiver &)=delete |
| Receiver (Receiver &&)=delete | |
| Receiver & | operator= (Receiver &&)=delete |
| void | on_range_image (std::function< void(const RangeImageView &)> callback) |
| Sets the callback for range images, replacing any earlier one. | |
| void | on_bitmap_image (std::function< void(const BitmapImageView &)> callback) |
| Sets the callback for bitmap images; see on_range_image(). | |
| void | on_imu_batch (std::function< void(const ImuBatchView &)> callback) |
| Sets the callback for IMU batches; see on_range_image(). | |
| void | on_decode_error (std::function< void(rip::DecodeStatus)> callback) |
| Sets the callback for datagrams that fail to decode; see on_range_image(). | |
| void | on_socket_error (std::function< void(const std::error_code &)> callback) |
| Sets the callback for the socket error that ends the receive thread; see on_range_image(). | |
| void | start () |
| Starts the receive thread. | |
| void | stop () |
| Stops the receive thread and joins it unless called from a callback. | |
| bool | running () const noexcept |
| Whether the receive thread is running; false once a socket error has ended it. | |
| ReceiverStats | stats () const noexcept |
| Current counters; callable from any thread. | |
Receives datagrams on a thread of its own, decodes them and passes the messages to the registered callbacks.
Callbacks run one at a time on the receive thread and must not throw. A view passed to a callback is valid until the callback returns.
|
explicit |
Takes over socket.
No callbacks run before start(); datagrams that arrive earlier wait in the socket's receive buffer.
| waterlinked::sonar::Receiver::~Receiver | ( | ) |
| void waterlinked::sonar::Receiver::on_decode_error | ( | std::function< void(rip::DecodeStatus)> | callback | ) |
Sets the callback for datagrams that fail to decode; see on_range_image().
Packets of unpublished types are only counted.
| void waterlinked::sonar::Receiver::on_range_image | ( | std::function< void(const RangeImageView &)> | callback | ) |
Sets the callback for range images, replacing any earlier one.
| std::logic_error | after start(). |
| void waterlinked::sonar::Receiver::start | ( | ) |
Starts the receive thread.
A Receiver starts at most once.
| std::logic_error | if it was started before. |
| std::system_error | if the thread cannot be created. |
| void waterlinked::sonar::Receiver::stop | ( | ) |
Stops the receive thread and joins it unless called from a callback.
Idempotent.