Commit 9a424b21 authored by Alessio Netti's avatar Alessio Netti

Analytics: smoothing sensors are published as operations automatically

- Can be disabled by toggling the isOperation metadata field for each
sensor
parent f296b1db
...@@ -812,7 +812,6 @@ For this reason, pattern expressions specified on output sensors (e.g., _<bottom ...@@ -812,7 +812,6 @@ For this reason, pattern expressions specified on output sensors (e.g., _<bottom
| Value | Explanation | | Value | Explanation |
|:----- |:----------- | |:----- |:----------- |
| separator | Character used to separate the MQTT prefix of output sensors (which is the input sensor's name) from the suffix (which is the average's identifier). Default is "#". | separator | Character used to separate the MQTT prefix of output sensors (which is the input sensor's name) from the suffix (which is the average's identifier). Default is "#".
| updateMetadata | Boolean. If _true_, the operator will automatically update the metadata entries of all sensors for which averages are computed, to expose the new operations. Enabled by default.
| exclude | String containing a regular expression, defining which sensors must be excluded from the smoothing process. | exclude | String containing a regular expression, defining which sensors must be excluded from the smoothing process.
Additionally, output sensors in operators of the _Smoothing_ plugin accept the following parameters: Additionally, output sensors in operators of the _Smoothing_ plugin accept the following parameters:
...@@ -821,7 +820,7 @@ Additionally, output sensors in operators of the _Smoothing_ plugin accept the f ...@@ -821,7 +820,7 @@ Additionally, output sensors in operators of the _Smoothing_ plugin accept the f
|:----- |:----------- | |:----- |:----------- |
| range | Range in milliseconds of the average to be stored in this output sensor. | range | Range in milliseconds of the average to be stored in this output sensor.
> NOTE &ensp;&ensp;&ensp;&ensp;&ensp; The _Smoothing_ plugin will automatically update the metadata table of the input sensors in the units to expose the computed averages. This behavior can be altered by setting the _updateMetadata_ operator parameter to _false_. The sensors of the averages themselves are not published by default. > NOTE &ensp;&ensp;&ensp;&ensp;&ensp; The _Smoothing_ plugin will automatically update the metadata table of the input sensors in the units to expose the computed averages. This behavior can be altered by setting the _isOperation_ metadata attribute to _false_ for each output sensor. This way, the sensors associated to the averages will be published as independent entries.
## Regressor Plugin <a name="regressorPlugin"></a> ## Regressor Plugin <a name="regressorPlugin"></a>
......
...@@ -39,8 +39,6 @@ void SmoothingConfigurator::operatorAttributes(SmoothingOperator& op, CFG_VAL co ...@@ -39,8 +39,6 @@ void SmoothingConfigurator::operatorAttributes(SmoothingOperator& op, CFG_VAL co
{ {
if (boost::iequals(val.first, "separator")) { if (boost::iequals(val.first, "separator")) {
op.setSeparator(val.second.data()); op.setSeparator(val.second.data());
} else if (boost::iequals(val.first, "updateMetadata")) {
op.setUpdateMetadata(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "exclude")) { } else if (boost::iequals(val.first, "exclude")) {
op.setExclude(val.second.data()); op.setExclude(val.second.data());
} }
......
...@@ -30,13 +30,11 @@ ...@@ -30,13 +30,11 @@
SmoothingOperator::SmoothingOperator(const std::string& name) : OperatorTemplate(name) { SmoothingOperator::SmoothingOperator(const std::string& name) : OperatorTemplate(name) {
_separator = "-"; _separator = "-";
_exclude = ""; _exclude = "";
_updateMetadata = true;
} }
SmoothingOperator::SmoothingOperator(const SmoothingOperator &other) : OperatorTemplate(other) { SmoothingOperator::SmoothingOperator(const SmoothingOperator &other) : OperatorTemplate(other) {
_separator = other._separator; _separator = other._separator;
_exclude = ""; _exclude = "";
_updateMetadata = other._updateMetadata;
} }
SmoothingOperator::~SmoothingOperator() {} SmoothingOperator::~SmoothingOperator() {}
......
...@@ -47,11 +47,9 @@ public: ...@@ -47,11 +47,9 @@ public:
virtual ~SmoothingOperator(); virtual ~SmoothingOperator();
void setSeparator(std::string& s) { _separator = s; } void setSeparator(std::string& s) { _separator = s; }
void setUpdateMetadata(bool u) { _updateMetadata = u; }
void setExclude(std::string& e) { _exclude = e; } void setExclude(std::string& e) { _exclude = e; }
std::string getSeparator() { return _separator; } std::string getSeparator() { return _separator; }
bool getUpdateMetadata() { return _updateMetadata; }
std::string getExclude() { return _exclude; } std::string getExclude() { return _exclude; }
void printConfig(LOG_LEVEL ll) override; void printConfig(LOG_LEVEL ll) override;
...@@ -65,7 +63,6 @@ protected: ...@@ -65,7 +63,6 @@ protected:
vector<reading_t> _buffer; vector<reading_t> _buffer;
std::string _separator; std::string _separator;
std::string _exclude; std::string _exclude;
bool _updateMetadata;
}; };
......
...@@ -45,7 +45,10 @@ public: ...@@ -45,7 +45,10 @@ public:
_currValue = 0.0; _currValue = 0.0;
_currTs = 0; _currTs = 0;
_last = 0; _last = 0;
_publish = false; // Declaring the sensor as an operation by default
SensorMetadata sm;
sm.setIsOperation(true);
setMetadata(sm);
} }
// Copy constructor // Copy constructor
...@@ -54,7 +57,6 @@ public: ...@@ -54,7 +57,6 @@ public:
_currValue = 0.0; _currValue = 0.0;
_currTs = 0; _currTs = 0;
_last = 0; _last = 0;
_publish = false;
} }
virtual ~SmoothingSensorBase() {} virtual ~SmoothingSensorBase() {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment