SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_output.h
Go to the documentation of this file.
1#ifndef _signalk_output_H_
2#define _signalk_output_H_
3
5#include "signalk_emitter.h"
6
7namespace sensesp {
8
9static const char SIGNALKOUTPUT_SCHEMA[] PROGMEM = R"({
10 "type": "object",
11 "properties": {
12 "sk_path": { "title": "Signal K Path", "type": "string" }
13 }
14 })";
15
20template <typename T>
21class SKOutput : public SKEmitter, public SymmetricTransform<T> {
22 public:
24
43
45
46 virtual void set_input(T new_value, uint8_t input_channel = 0) override {
47 this->ValueProducer<T>::emit(new_value);
48 }
49
50 virtual String as_signalk() override {
53 json_doc["path"] = this->get_sk_path();
54 json_doc["value"] = ValueProducer<T>::output;
56 return json;
57 }
58
59 virtual void get_configuration(JsonObject& root) override {
60 root["sk_path"] = this->get_sk_path();
61 }
62
64
65 virtual bool set_configuration(const JsonObject& config) override {
66 if (!config.containsKey("sk_path")) {
67 return false;
68 }
69 this->set_sk_path(config["sk_path"].as<String>());
70 return true;
71 }
72
79 virtual void set_metadata(SKMetadata* meta) { this->meta_ = meta; }
80
81 virtual SKMetadata* get_metadata() override { return meta_; }
82
83 protected:
85};
86
90class SKOutputRawJson : public SKOutput<String> {
91 public:
95
96 virtual String as_signalk() override {
99 json_doc["path"] = this->get_sk_path();
100 json_doc["value"] = serialized(ValueProducer<String>::output);
102 return json;
103 }
104};
105
110template <typename T>
131
136
137} // namespace sensesp
138
139#endif
virtual void load_configuration()
Construct a new transform based on a single function.
A class that produces Signal K output to be forwarded to the Signal K server (if the system is connec...
void set_sk_path(const String &path)
Holds Signal K meta data that is associated with the sk_path an SKEmitter class may optionally send t...
A specialized transform whose primary purpose is to output Signal K data on the Signal K network.
virtual void set_metadata(SKMetadata *meta)
virtual String as_signalk() override
virtual void get_configuration(JsonObject &root) override
SKOutput(String sk_path, String config_path="", SKMetadata *meta=NULL)
virtual bool set_configuration(const JsonObject &config) override
virtual SKMetadata * get_metadata() override
virtual void set_input(T new_value, uint8_t input_channel=0) override
SKMetadata * meta_
String get_config_schema() override
SKOutput(String sk_path, SKMetadata *meta)
A special class for sending numeric values to the Signal K server on a specific Signal K path.
SKOutputNumeric(String sk_path, String config_path, String units)
SKOutputNumeric(String sk_path, SKMetadata *meta)
Class for sending raw Json strings on a specific Signal K path.
SKOutputRawJson(String sk_path, String config_path="", SKMetadata *meta=NULL)
virtual String as_signalk() override
void set_start_priority(int priority)
Definition startable.h:32
A common type of transform that consumes, transforms, then outputs values of the same data type.
Definition transform.h:95
A base class for any sensor or piece of code that outputs a value for consumption elsewhere.
void emit(T new_value)
const uint8_t PAGE_css_bootstrap[] PROGMEM
SKOutput< String > SKOutputString
SKOutputNumeric< int > SKOutputInt
SKOutputNumeric< float > SKOutputFloat
SKOutput< bool > SKOutputBool