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

Commit 19bcc76b authored by Michael Ott's avatar Michael Ott

Add xccSingleEnergy sensor type

parent 8264f200
......@@ -89,7 +89,8 @@ class IPMISensorBase : public SensorBase {
undefined = 0,
raw,
sdr,
xccDatastorePower
xccDatastorePower,
xccSingleEnergy
};
uint16_t getRecordId() const { return _recordId; }
......@@ -115,6 +116,8 @@ class IPMISensorBase : public SensorBase {
return std::string("sdr");
case xccDatastorePower:
return std::string("xccDatastorePower");
case xccSingleEnergy:
return std::string("xccSingleEnergy");
default:
return std::string("undefined");
}
......@@ -146,6 +149,8 @@ class IPMISensorBase : public SensorBase {
_type = sdr;
} else if (boost::iequals(type, "xccDatastorePower")) {
_type = xccDatastorePower;
} else if (boost::iequals(type, "xccSingleEnergy")) {
_type = xccSingleEnergy;
} else {
_type = undefined;
}
......
......@@ -112,6 +112,13 @@ void IPMISensorGroup::read() {
}
break;
}
case IPMISensorBase::sensorType::xccSingleEnergy: {
LenovoXCC xcc(_entity);
if (xcc.getSingleEnergy(reading) == 0) {
s->storeReading(reading, s->getFactor());
}
break;
}
case IPMISensorBase::sensorType::sdr: {
std::vector<uint8_t> sdrRecord = s->getSdrRecord();
if (sdrRecord.size() == 0) {
......
......@@ -65,6 +65,19 @@ int LenovoXCC::getDatastorePower(std::vector<reading_t> &readings) {
}
}
int LenovoXCC::getSingleEnergy(reading_t &reading) {
if (_drift || getDrift() == 0) {
uint64_t ts, energy;
if (readSingleEnergyRaw(ts, energy) == 0) {
reading.timestamp = ts + _drift;
reading.value = energy;
return 0;
}
}
return 1;
}
int LenovoXCC::readSingleEnergyRaw(uint64_t &timeStamp, uint64_t &energy) {
uint8_t buf[256];
uint8_t getSingleEnergyCmd[] = {0x00, 0x3a, 0x32, 0x04, 0x02, 0x00, 0x00, 0x00};
......
......@@ -20,6 +20,7 @@ class LenovoXCC {
virtual ~LenovoXCC();
int getDatastorePower(std::vector<reading_t> &readings);
int getSingleEnergy(reading_t &reading);
private:
int openDatastore();
......
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