4#include "ArduinoJson.h"
12 :
Startable{0}, max_buffer_size{max_buffer_size}, meta_sent_{
false} {
30 if (get_buffer_size() >= max_buffer_size) {
33 buffer.push_front(
val);
53unsigned int SKDeltaQueue::get_doc_size_estimate() {
63 for (
auto item : buffer) {
71unsigned int SKDeltaQueue::get_metadata_size_estimate() {
73 int estimate = JSON_ARRAY_SIZE(num_metadata);
76 auto update_estimate = [&](String& field) {
77 if (!field.isEmpty()) {
79 estimate += field.length() + 1;
83 for (
auto const& source : SKEmitter::get_sources()) {
85 auto metadata = source->get_metadata();
86 if (metadata == NULL) {
89 update_estimate(metadata->units_);
90 update_estimate(metadata->display_name_);
91 update_estimate(metadata->description_);
92 update_estimate(metadata->short_name_);
94 estimate += JSON_OBJECT_SIZE(num_fields);
123 while (!buffer.empty()) {
131 debugD(
"delta: %s", output.c_str());
void attach(std::function< void()> observer)
SKDeltaQueue(unsigned int max_buffer_size=20)
void get_delta(String &output)
virtual void start() override
bool take_semaphore(unsigned long int timeout_ms=0)
void append(const String val)
A class that produces Signal K output to be forwarded to the Signal K server (if the system is connec...
static const std::vector< SKEmitter * > & get_sources()
static String get_hostname()
Get the current hostname.
Automatic calling of the start() method at startup.