|
SensESP 3.5.1-alpha
Universal Signal K sensor toolkit ESP32
|
A ValueProducer that listens to the metadata stream for a single Signal K path and emits a typed SKMetaView whenever it changes.
More...
#include <sensesp/signalk/signalk_metadata_listener.h>
Public Member Functions | |
| SKMetadataListener (const String &sk_path, int listen_delay=1000, const String &config_path="") | |
| bool | wants_meta () const override |
| void | parse_meta (const std::shared_ptr< const JsonDocument > &meta_doc) override |
Public Member Functions inherited from sensesp::SKListener | |
| SKListener (const String &sk_path, int listen_delay, const String &config_path="") | |
| virtual | ~SKListener () |
| String & | get_sk_path () |
| int | get_listen_delay () |
| virtual bool | matches (const String &path) const |
| virtual void | parse_value (const JsonObject &json) |
Public Member Functions inherited from sensesp::Observable | |
| Observable () | |
| Observable (Observable &&other) | |
| Move constructor. | |
| void | notify () |
| int | attach (std::function< void()> observer) |
| Attach an observer callback. | |
| void | detach (int id) |
| Remove a previously attached observer by its ID. | |
Public Member Functions inherited from sensesp::FileSystemSaveable | |
| FileSystemSaveable (const String &config_path) | |
| virtual bool | load () override |
| Load and populate the object from a persistent storage. | |
| virtual bool | save () override |
| Save the object to a persistent storage. | |
| virtual bool | clear () override |
| Delete the data from a persistent storage. | |
| bool | find_config_file (const String &config_path, String &filename) |
Public Member Functions inherited from sensesp::Saveable | |
| Saveable (const String &config_path) | |
| virtual bool | refresh () |
| Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state. | |
| const String & | get_config_path () const |
Public Member Functions inherited from sensesp::ValueProducer< SKMetaView > | |
| ValueProducer () | |
| ValueProducer (const SKMetaView &initial_value) | |
| virtual const SKMetaView & | get () const |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< SKMetaView, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type | connect_to (std::shared_ptr< VConsumer > consumer) |
| Connect a producer to a transform with a different input type. | |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< SKMetaView, typenameVConsumer::input_type >::value, VConsumer * >::type | connect_to (VConsumer *consumer) |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< SKMetaView, typenameVConsumer::input_type >::value, VConsumer * >::type | connect_to (VConsumer &consumer) |
| void | emit (const SKMetaView &new_value) |
Additional Inherited Members | |
Static Public Member Functions inherited from sensesp::SKListener | |
| static const std::vector< SKListener * > & | get_listeners () |
| static void | clear_registry () |
| static bool | take_semaphore (uint64_t timeout_ms=0) |
| static void | release_semaphore () |
Protected Attributes inherited from sensesp::SKListener | |
| String | sk_path {} |
Protected Attributes inherited from sensesp::Saveable | |
| const String | config_path_ |
Protected Attributes inherited from sensesp::ValueProducer< SKMetaView > | |
| SKMetaView | output_ |
A ValueProducer that listens to the metadata stream for a single Signal K path and emits a typed SKMetaView whenever it changes.
Mirrors SKValueListener but consumes updates[].meta[] entries instead of updates[].values[]. Metadata deltas are only pushed by the server when the stream is subscribed with sendMeta=all (the SKWSClient default).
The emitted SKMetaView exposes the common fields (units, displayName, zones, ...) as typed members and retains the full meta object in raw, so it is both ergonomic and lossless. It is safe for any deferred consumer (e.g. UI work marshalled onto the event loop): the typed members are owned values and raw is a refcounted owned document, so nothing aliases the transient receive document.
Because it is-a SKListener, its path is subscribed automatically by SKWSClient::subscribe_listeners(), and process_received_updates routes meta deltas to it via the out-of-band queue tag plus wants_meta().
Example:
Definition at line 121 of file signalk_metadata_listener.h.
|
inline |
| sk_path | The Signal K path to listen to for metadata changes |
| listen_delay | The minimum interval between updates in ms |
| config_path | Optional configuration path |
Definition at line 129 of file signalk_metadata_listener.h.
|
inlineoverridevirtual |
Called on the main task by SKWSClient::process_received_updates with an already-owned, read-only metadata document moved off the receive queue (shape {path, value: {...meta...}}). Parses the typed view and emits it; the owned document backs SKMetaView::raw so the lossless data outlives any deferred consumer with no extra deep copy.
Reimplemented from sensesp::SKListener.
Definition at line 147 of file signalk_metadata_listener.h.
|
inlineoverridevirtual |
Whether this listener consumes metadata deltas (updates[].meta[]) rather than value deltas (updates[].values[]). Defaults to false; SKMetadataListener overrides it to true. Used by SKWSClient::process_received_updates to route a queued delta to the correct listener kind without RTTI (RTTI is commonly disabled on ESP32).
Reimplemented from sensesp::SKListener.
Definition at line 138 of file signalk_metadata_listener.h.