Commit 4110c1e5 authored by Michael Ott's avatar Michael Ott
Browse files

Introduce type field for IPMI sensors

parent 5cfdaab5
......@@ -50,6 +50,7 @@ void IPMIConfigurator::sensorBase(IPMISensorBase& s, CFG_VAL config) {
ATTRIBUTE("msb", setMsb);
ATTRIBUTE("recordId", setRecordId);
ATTRIBUTE("factor", setFactor);
ATTRIBUTE("type", setType);
}
if (s.getLsb() < s.getMsb()) {
......
......@@ -41,6 +41,7 @@
#include <boost/tokenizer.hpp>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include <vector>
#include <sstream>
......@@ -53,12 +54,14 @@ class IPMISensorBase: public SensorBase {
public:
IPMISensorBase(const std::string& name) :
SensorBase(name),
_type(undefined),
_recordId(0),
_factor(1),
_lsb(0),
_msb(0) {}
IPMISensorBase(const IPMISensorBase& other) : SensorBase(other),
_type(other._type),
_recordId(other._recordId),
_sdrRecord(other._sdrRecord),
_factor(other._factor),
......@@ -70,6 +73,7 @@ public:
IPMISensorBase& operator=(const IPMISensorBase& other) {
SensorBase::operator=(other);
_type = other._type;
_recordId = other._recordId;
_sdrRecord = other._sdrRecord;
_factor = other._factor;
......@@ -79,6 +83,12 @@ public:
return *this;
}
enum sensorType {
undefined = 0,
raw,
sdr
};
uint16_t getRecordId() const { return _recordId; }
const std::vector<uint8_t>& getSdrRecord() const { return _sdrRecord; }
......@@ -94,8 +104,18 @@ public:
}
uint8_t getLsb() const { return _lsb; }
uint8_t getMsb() const { return _msb; }
std::string getType() const {
switch(_type) {
case raw: return std::string("raw");
case sdr: return std::string("sdr");
default: return std::string("undefined");
}
}
void setRecordId(const std::string& recordId) { _recordId = stoul(recordId); }
void setRecordId(const std::string& recordId) {
_recordId = stoul(recordId);
_type = sdr;
}
void setSdrRecord(const std::vector<uint8_t>& sdrRecord) { _sdrRecord = sdrRecord; }
void setFactor(const std::string& factor) { _factor = stod(factor); }
void setRawCmd(std::string& rawCmd) {
......@@ -105,23 +125,36 @@ public:
while (it != end) {
_rawCmd.push_back(stoi(*it++, NULL, 16));
}
_type = raw;
}
void setLsb(const std::string& lsb) { _lsb = stoi(lsb); }
void setLsb(uint8_t lsb) { _lsb = lsb; }
void setMsb(const std::string& msb) { _msb = stoi(msb); }
void setMsb(uint8_t msb) { _msb = msb; }
void setType(const std::string& type) {
if (boost::iequals(type, "raw")) {
_type = raw;
} else if (boost::iequals(type, "sdr")) {
_type = sdr;
} else {
_type = undefined;
}
}
void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
if (_recordId > 0) {
LOG_VAR(ll) << leading << " Record Id: " << _recordId;
} else {
LOG_VAR(ll) << leading << " Raw Cmd: " << getRawCmdString();
LOG_VAR(ll) << leading << " lsb: " << (int) _lsb;
LOG_VAR(ll) << leading << " msb: " << (int) _msb;
LOG_VAR(ll) << leading << " Type: " << getType();
switch(_type) {
case raw:
LOG_VAR(ll) << leading << " Raw Cmd: " << getRawCmdString();
LOG_VAR(ll) << leading << " lsb: " << (int) _lsb;
LOG_VAR(ll) << leading << " msb: " << (int) _msb;
break;
case sdr:
LOG_VAR(ll) << leading << " Record Id: " << _recordId;
break;
}
LOG_VAR(ll) << leading << " Factor: " << _factor;
}
protected:
......@@ -132,6 +165,7 @@ protected:
std::vector<uint8_t> _rawCmd;
uint8_t _lsb;
uint8_t _msb;
sensorType _type;
};
#endif /* SRC_SENSORS_IPMI_IPMISENSORBASE_H_ */
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