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

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: ...@@ -493,6 +493,8 @@ protected:
sBase.setPublish(to_bool(val.second.data())); sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) { } else if (boost::iequals(val.first, "metadata")) {
SensorMetadata sm; SensorMetadata sm;
if(sBase.getMetadata())
sm = *sBase.getMetadata();
try { try {
sm.parsePTREE(val.second); sm.parsePTREE(val.second);
sBase.setMetadata(sm); sBase.setMetadata(sm);
...@@ -625,6 +627,8 @@ protected: ...@@ -625,6 +627,8 @@ protected:
sm->publicName = s->getMqtt(); sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt(); sm->pattern = s->getMqtt();
sm->isVirtual = false; sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)op.getInterval() * 1000000;
} }
} }
for(auto& subUnit: u.getSubUnits()) for(auto& subUnit: u.getSubUnits())
...@@ -635,6 +639,8 @@ protected: ...@@ -635,6 +639,8 @@ protected:
sm->publicName = s->getMqtt(); sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt(); sm->pattern = s->getMqtt();
sm->isVirtual = false; sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)op.getInterval() * 1000000;
} }
} }
return true; return true;
......
...@@ -392,6 +392,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface { ...@@ -392,6 +392,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
sBase.setPublish(to_bool(val.second.data())); sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) { } else if (boost::iequals(val.first, "metadata")) {
SensorMetadata sm; SensorMetadata sm;
if(sBase.getMetadata())
sm = *sBase.getMetadata();
try { try {
sm.parsePTREE(val.second); sm.parsePTREE(val.second);
sBase.setMetadata(sm); sBase.setMetadata(sm);
...@@ -687,6 +689,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface { ...@@ -687,6 +689,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
sm->publicName = s->getMqtt(); sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt(); sm->pattern = s->getMqtt();
sm->isVirtual = false; sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)g->getInterval() * 1000000;
} }
} }
g->releaseSensors(); g->releaseSensors();
...@@ -989,6 +993,8 @@ class ConfiguratorTemplate<SBase, SGroup, nullptr_t> : public ConfiguratorInterf ...@@ -989,6 +993,8 @@ class ConfiguratorTemplate<SBase, SGroup, nullptr_t> : public ConfiguratorInterf
sBase.setPublish(to_bool(val.second.data())); sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) { } else if (boost::iequals(val.first, "metadata")) {
SensorMetadata sm; SensorMetadata sm;
if(sBase.getMetadata())
sm = *sBase.getMetadata();
try { try {
sm.parsePTREE(val.second); sm.parsePTREE(val.second);
sBase.setMetadata(sm); sBase.setMetadata(sm);
...@@ -1113,6 +1119,8 @@ class ConfiguratorTemplate<SBase, SGroup, nullptr_t> : public ConfiguratorInterf ...@@ -1113,6 +1119,8 @@ class ConfiguratorTemplate<SBase, SGroup, nullptr_t> : public ConfiguratorInterf
sm->publicName = s->getMqtt(); sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt(); sm->pattern = s->getMqtt();
sm->isVirtual = false; sm->isVirtual = false;
if(sm->interval==0)
sm->interval = (unsigned long long)g->getInterval() * 1000000;
} }
} }
g->releaseSensors(); 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