Commit 0d3ebfb8 authored by Michael Ott's avatar Michael Ott
Browse files

Override IPMISensorGroup::nextReadingTime() to account for xcc pecularities

parent 26383821
...@@ -43,6 +43,19 @@ IPMIConfigurator::IPMIConfigurator() { ...@@ -43,6 +43,19 @@ IPMIConfigurator::IPMIConfigurator() {
IPMIConfigurator::~IPMIConfigurator() {} IPMIConfigurator::~IPMIConfigurator() {}
bool IPMIConfigurator::readConfig(std::string cfgPath) {
if (ConfiguratorTemplate<IPMISensorBase, IPMISensorGroup, IPMIHost>::readConfig(cfgPath)) {
for(auto& g: _sensorGroups) {
if (!g->checkConfig()) {
return false;
}
}
return true;
} else {
return false;
}
}
void IPMIConfigurator::sensorBase(IPMISensorBase& s, CFG_VAL config) { void IPMIConfigurator::sensorBase(IPMISensorBase& s, CFG_VAL config) {
ADD { ADD {
ATTRIBUTE("cmd", setRawCmd); ATTRIBUTE("cmd", setRawCmd);
......
...@@ -48,6 +48,7 @@ class IPMIConfigurator: public ConfiguratorTemplate<IPMISensorBase, IPMISensorGr ...@@ -48,6 +48,7 @@ class IPMIConfigurator: public ConfiguratorTemplate<IPMISensorBase, IPMISensorGr
public: public:
IPMIConfigurator(); IPMIConfigurator();
virtual ~IPMIConfigurator(); virtual ~IPMIConfigurator();
bool readConfig(std::string cfgPath) override;
protected: protected:
/* Overwritten from ConfiguratorTemplate */ /* Overwritten from ConfiguratorTemplate */
......
...@@ -147,3 +147,32 @@ void IPMISensorGroup::read() { ...@@ -147,3 +147,32 @@ void IPMISensorGroup::read() {
} }
} }
} }
uint64_t IPMISensorGroup::nextReadingTime() {
if ((_sensors.size() == 1) && (_sensors.front()->getType() == IPMISensorBase::sensorType::xcc)) {
reading_t r = _sensors.front()->getLatestValue();
uint64_t now = getTimestamp();
if (r.timestamp < now - S_TO_NS(35)) {
// There was no reading yet or it is too old, so schedule next in 30s
return now + S_TO_NS(30);
} else {
// The first reading of the next 30s block is 10ms after the last reading in the current block.
// A block becomes available 30s after its first reading, adding 2s grace period
return r.timestamp + MS_TO_NS(32010);
}
}
return SensorGroupInterface::nextReadingTime();
}
bool IPMISensorGroup::checkConfig() {
if (_sensors.size() > 1) {
for(const auto& s : _sensors) {
if (s->getType() == IPMISensorBase::sensorType::xcc) {
LOG(error) << _groupName << " contains an XCC sensor among others, this is not possible";
return false;
}
}
}
return true;
}
...@@ -43,6 +43,8 @@ public: ...@@ -43,6 +43,8 @@ public:
IPMISensorGroup(const IPMISensorGroup& other); IPMISensorGroup(const IPMISensorGroup& other);
virtual ~IPMISensorGroup(); virtual ~IPMISensorGroup();
IPMISensorGroup& operator=(const IPMISensorGroup& other); IPMISensorGroup& operator=(const IPMISensorGroup& other);
uint64_t nextReadingTime();
bool checkConfig();
private: private:
void read() final override; void read() final override;
......
Supports Markdown
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