6.5.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 5c5539d6 authored by Alessio Netti's avatar Alessio Netti

Metadata: minor improvements

- The interval field now defaults to the value inherited from the
sensor groups that the sensor belongs to
- Metadata blocks in templates can now be overwritten completely or
only in part
parent 67742d12
......@@ -493,6 +493,8 @@ protected:
sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) {
SensorMetadata sm;
if(sBase.getMetadata())
sm = *sBase.getMetadata();
try {
sm.parsePTREE(val.second);
sBase.setMetadata(sm);
......@@ -625,6 +627,8 @@ protected:
sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt();
sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)op.getInterval() * 1000000;
}
}
for(auto& subUnit: u.getSubUnits())
......@@ -635,6 +639,8 @@ protected:
sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt();
sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)op.getInterval() * 1000000;
}
}
return true;
......
......@@ -392,6 +392,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) {
SensorMetadata sm;
if(sBase.getMetadata())
sm = *sBase.getMetadata();
try {
sm.parsePTREE(val.second);
sBase.setMetadata(sm);
......@@ -687,6 +689,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt();
sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)g->getInterval() * 1000000;
}
}
g->releaseSensors();
......@@ -989,6 +993,8 @@ class ConfiguratorTemplate<SBase, SGroup, nullptr_t> : public ConfiguratorInterf
sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) {
SensorMetadata sm;
if(sBase.getMetadata())
sm = *sBase.getMetadata();
try {
sm.parsePTREE(val.second);
sBase.setMetadata(sm);
......@@ -1113,6 +1119,8 @@ class ConfiguratorTemplate<SBase, SGroup, nullptr_t> : public ConfiguratorInterf
sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt();
sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)g->getInterval() * 1000000;
}
}
g->releaseSensors();
......
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