|
bitsim
Model, simulate, estimate and control robots in C++
|
The topic a sensor on a board publishes its readings to. More...
#include <mqtt_sensor_channel.h>
Classes | |
| struct | Config |
Public Types | |
| using | Clock = std::chrono::steady_clock |
Public Member Functions | |
| MQTT_SensorChannel ()=default | |
| A channel that makes its own subscriber when connect() is called. | |
| MQTT_SensorChannel (network::MqttSubscriber &subscriber) | |
| A channel that reads the given subscriber. It must outlive the channel. | |
| const Config & | config () const noexcept |
| void | set_config (const Config &config) |
| void | connect () |
| Connect to the broker, unless the subscriber already is. | |
| bool | is_connected () const |
| template<typename Receive> | |
| void | read (Receive &&receive) |
| Pass every message that has arrived to receive, oldest first, without waiting. receive returns true if it accepted the message. | |
| void | mark_received () |
| Record that a valid reading arrived now. read() does it for the messages receive accepts; call it when feeding messages by hand. | |
| bool | is_alive () const |
| uint_t | n_received () const noexcept |
| uint_t | n_rejected () const noexcept |
The topic a sensor on a board publishes its readings to.
The channel either uses a subscriber the application connected, or makes and connects its own from config() when connect() is called. Reading the channel never waits: it hands over every message that has arrived since the last read, so a simulation that reads it every step keeps up with a board that publishes often, and sees the latest reading.
| using bitsim::sensors::backends::MQTT_SensorChannel::Clock = std::chrono::steady_clock |
|
default |
A channel that makes its own subscriber when connect() is called.
|
explicit |
A channel that reads the given subscriber. It must outlive the channel.
|
inlinenoexcept |
| void bitsim::sensors::backends::MQTT_SensorChannel::connect | ( | ) |
Connect to the broker, unless the subscriber already is.
| std::logic_error | If the channel has no topic to subscribe to |
| bool bitsim::sensors::backends::MQTT_SensorChannel::is_alive | ( | ) | const |
| bool bitsim::sensors::backends::MQTT_SensorChannel::is_connected | ( | ) | const |
| void bitsim::sensors::backends::MQTT_SensorChannel::mark_received | ( | ) |
Record that a valid reading arrived now. read() does it for the messages receive accepts; call it when feeding messages by hand.
|
inlinenoexcept |
|
inlinenoexcept |
| void bitsim::sensors::backends::MQTT_SensorChannel::read | ( | Receive && | receive | ) |
Pass every message that has arrived to receive, oldest first, without waiting. receive returns true if it accepted the message.
| std::logic_error | If the channel is not connected |
|
inline |