Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit d8b0a672 authored by Michael Ott's avatar Michael Ott
Browse files

Remove factor parameter from BACnet and IPMI plugins and introduce a generic...

Remove factor parameter from BACnet and IPMI plugins and introduce a generic factor parameter in SensorBase
parent 5cfee0d8
......@@ -52,6 +52,7 @@ public:
_cacheInterval(900000),
_subsamplingFactor(1),
_subsamplingIndex(0),
_factor(1),
_cache(nullptr),
_delta(false),
_deltaMax(LLONG_MAX),
......@@ -79,6 +80,7 @@ public:
_cacheInterval(other._cacheInterval),
_subsamplingFactor(other._subsamplingFactor),
_subsamplingIndex(0),
_factor(other._factor),
_cache(nullptr),
_delta(other._delta),
_deltaMax(other._deltaMax),
......@@ -103,6 +105,7 @@ public:
_cacheInterval = other._cacheInterval;
_subsamplingFactor = other._subsamplingFactor;
_subsamplingIndex = 0;
_factor = other._factor;
_cache.reset(nullptr);
_delta = other._delta;
_deltaMax = other._deltaMax;
......@@ -132,6 +135,8 @@ public:
bool getDelta() const { return _delta; }
unsigned getCacheInterval() const { return _cacheInterval; }
int getSubsampling() const { return _subsamplingFactor; }
double getFactor() const { return _factor; }
const CacheEntry* const getCache() const { return _cache.get(); }
const reading_t& getLatestValue() const { return _latestValue; }
const bool isInit() const { return _cache && _readingQueue; }
......@@ -150,6 +155,7 @@ public:
void setMqtt(const std::string& mqtt) { _mqtt = mqtt; }
void setCacheInterval(unsigned cacheInterval) { _cacheInterval = cacheInterval; }
void setSubsampling(int factor) { _subsamplingFactor = factor; }
void setFactor(const double &factor) { _factor = factor; }
void setLastRaw(int64_t raw) { _lastRawValue.value = raw; }
void setLastURaw(uint64_t raw) { _lastRawUValue.value = raw; }
......@@ -186,9 +192,9 @@ public:
if( _delta ) {
if (!_firstReading) {
if (rawReading.value < _lastRawValue.value)
reading.value = (rawReading.value + ((int64_t)_deltaMax - _lastRawValue.value)) * factor;
reading.value = (rawReading.value + ((int64_t)_deltaMax - _lastRawValue.value)) * factor * _factor;
else
reading.value = (rawReading.value - _lastRawValue.value) * factor;
reading.value = (rawReading.value - _lastRawValue.value) * factor * _factor;
} else {
_firstReading = false;
_lastRawValue = rawReading;
......@@ -197,7 +203,7 @@ public:
_lastRawValue = rawReading;
}
else
reading.value = rawReading.value * factor;
reading.value = rawReading.value * factor * _factor;
storeReadingLocal(reading);
if (storeGlobal) {
......@@ -285,6 +291,7 @@ public:
if (getSubsampling() != 1) {
LOG_VAR(ll) << leading << " SubSampling: " << getSubsampling();
}
LOG_VAR(ll) << leading << " Factor: " << _factor;
LOG_VAR(ll) << leading << " Skip const values: " << (_skipConstVal ? "true" : "false");
LOG_VAR(ll) << leading << " Store delta only: " << (_delta ? "true" : "false");
if(_delta) {
......@@ -302,6 +309,7 @@ protected:
unsigned int _cacheInterval;
int _subsamplingFactor;
unsigned int _subsamplingIndex;
double _factor;
std::unique_ptr<CacheEntry> _cache;
bool _delta;
uint64_t _deltaMax;
......
......@@ -308,6 +308,8 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
sBase.setDeltaMaxValue(std::stoull(val.second.data()));
} else if (boost::iequals(val.first, "subSampling")) {
sBase.setSubsampling(std::stoi(val.second.data()));
} else if (boost::iequals(val.first, "factor")) {
sBase.setFactor(std::stod(val.second.data()));
} else if (boost::iequals(val.first, "publish")) {
sBase.setPublish(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "metadata")) {
......
......@@ -44,7 +44,6 @@ void BACnetConfigurator::sensorBase(BACnetSensorBase &s, CFG_VAL config) {
ATTRIBUTE("objectInstance", setObjectInstance);
ATTRIBUTE("objectType", setObjectType);
ATTRIBUTE("id", setPropertyId);
ATTRIBUTE("factor", setFactor);
}
}
......
......@@ -50,7 +50,6 @@ class BACnetSensorBase : public SensorBase {
public:
BACnetSensorBase(const std::string &name)
: SensorBase(name),
_factor(1),
_objectInstance(0) {
_objectType = OBJECT_DEVICE;
_propertyId = PROP_PRESENT_VALUE;
......@@ -59,7 +58,6 @@ class BACnetSensorBase : public SensorBase {
BACnetSensorBase(const BACnetSensorBase &other)
: SensorBase(other),
_factor(other._factor),
_objectInstance(other._objectInstance),
_objectType(other._objectType),
_propertyId(other._propertyId),
......@@ -69,7 +67,6 @@ class BACnetSensorBase : public SensorBase {
BACnetSensorBase &operator=(const BACnetSensorBase &other) {
SensorBase::operator=(other);
_factor = other._factor;
_objectInstance = other._objectInstance;
_objectType = other._objectType;
_propertyId = other._propertyId;
......@@ -78,13 +75,11 @@ class BACnetSensorBase : public SensorBase {
return *this;
}
double getFactor() const { return _factor; }
uint32_t getObjectInstance() const { return _objectInstance; }
BACNET_OBJECT_TYPE getObjectType() const { return _objectType; }
BACNET_PROPERTY_ID getPropertyId() const { return _propertyId; }
int32_t getObjectIndex() const { return _objectIndex; }
void setFactor(const std::string &factor) { _factor = std::stod(factor); }
void setObjectInstance(const std::string &objectInstance) { _objectInstance = stoul(objectInstance); }
void setObjectType(const std::string &objectType) { _objectType = static_cast<BACNET_OBJECT_TYPE>(stoul(objectType)); }
void setPropertyId(const std::string &property) { _propertyId = static_cast<BACNET_PROPERTY_ID>(stoul(property)); }
......@@ -92,7 +87,6 @@ class BACnetSensorBase : public SensorBase {
void printConfig(LOG_LEVEL ll, LOGGER &lg, unsigned leadingSpaces = 16) override {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << " Factor: " << _factor;
LOG_VAR(ll) << leading << " objectInstance: " << _objectInstance;
LOG_VAR(ll) << leading << " objectType: " << _objectType;
LOG_VAR(ll) << leading << " propertyId: " << _propertyId;
......@@ -100,7 +94,6 @@ class BACnetSensorBase : public SensorBase {
}
protected:
double _factor;
uint32_t _objectInstance;
BACNET_OBJECT_TYPE _objectType;
BACNET_PROPERTY_ID _propertyId;
......
......@@ -56,7 +56,7 @@ void BACnetSensorGroup::read() {
#ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
#endif
s->storeReading(reading, s->getFactor());
s->storeReading(reading);
} catch (const std::exception &e) {
LOG(error) << _groupName << "::" << s->getName() << " could not read value: " << e.what();
continue;
......
......@@ -62,7 +62,6 @@ void IPMIConfigurator::sensorBase(IPMISensorBase &s, CFG_VAL config) {
ATTRIBUTE("lsb", setLsb);
ATTRIBUTE("msb", setMsb);
ATTRIBUTE("recordId", setRecordId);
ATTRIBUTE("factor", setFactor);
ATTRIBUTE("type", setType);
}
......
......@@ -56,7 +56,6 @@ class IPMISensorBase : public SensorBase {
: SensorBase(name),
_type(undefined),
_recordId(0),
_factor(1),
_lsb(0),
_msb(0) {}
......@@ -65,7 +64,6 @@ class IPMISensorBase : public SensorBase {
_type(other._type),
_recordId(other._recordId),
_sdrRecord(other._sdrRecord),
_factor(other._factor),
_rawCmd(other._rawCmd),
_lsb(other._lsb),
_msb(other._msb) {}
......@@ -77,7 +75,6 @@ class IPMISensorBase : public SensorBase {
_type = other._type;
_recordId = other._recordId;
_sdrRecord = other._sdrRecord;
_factor = other._factor;
_rawCmd = other._rawCmd;
_lsb = other._lsb;
_msb = other._msb;
......@@ -97,7 +94,6 @@ class IPMISensorBase : public SensorBase {
uint16_t getRecordId() const { return _recordId; }
const std::vector<uint8_t> &getSdrRecord() const { return _sdrRecord; }
double getFactor() const { return _factor; }
const std::vector<uint8_t> &getRawCmd() const { return _rawCmd; }
std::string getRawCmdString() const {
std::stringstream ss;
......@@ -134,7 +130,6 @@ class IPMISensorBase : public SensorBase {
_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) {
boost::regex expr("(?:0x)?([0-9a-fA-F]+)");
boost::regex_token_iterator<std::string::iterator> it{rawCmd.begin(), rawCmd.end(), expr, 1};
......@@ -181,14 +176,12 @@ class IPMISensorBase : public SensorBase {
default:
break;
}
LOG_VAR(ll) << leading << " Factor: " << _factor;
}
protected:
sensorType _type;
uint16_t _recordId;
std::vector<uint8_t> _sdrRecord;
double _factor;
std::vector<uint8_t> _rawCmd;
uint8_t _lsb;
......
......@@ -120,7 +120,7 @@ void IPMISensorGroup::read() {
LenovoXCC xcc(_entity);
if (_entity->getXCC()->getDatastorePower(readings) == 0) {
for (unsigned int i=0; i<readings.size(); i++) {
s->storeReading(readings[i], s->getFactor());
s->storeReading(readings[i]);
}
reading = readings.back();
}
......@@ -128,7 +128,7 @@ void IPMISensorGroup::read() {
}
case IPMISensorBase::sensorType::xccSingleEnergy: {
if (_entity->getXCC()->getSingleEnergy(reading) == 0) {
s->storeReading(reading, s->getFactor());
s->storeReading(reading);
}
break;
}
......@@ -136,7 +136,7 @@ void IPMISensorGroup::read() {
std::vector<reading_t> readings;
if (_entity->getXCC()->getBulkPower(readings) == 0) {
for (unsigned int i=0; i<readings.size(); i++) {
s->storeReading(readings[i], s->getFactor());
s->storeReading(readings[i]);
}
reading = readings.back();
}
......@@ -146,7 +146,7 @@ void IPMISensorGroup::read() {
std::vector<reading_t> readings;
if (_entity->getXCC()->getBulkEnergy(readings) == 0) {
for (unsigned int i=0; i<readings.size(); i++) {
s->storeReading(readings[i], s->getFactor());
s->storeReading(readings[i]);
}
reading = readings.back();
}
......@@ -159,12 +159,12 @@ void IPMISensorGroup::read() {
s->setSdrRecord(sdrRecord);
}
reading.value = _entity->readSensorRecord(sdrRecord);
s->storeReading(reading, s->getFactor());
s->storeReading(reading);
break;
}
case IPMISensorBase::sensorType::raw: {
reading.value = readRaw(s->getRawCmd(), s->getLsb(), s->getMsb());
s->storeReading(reading, s->getFactor());
s->storeReading(reading);
break;
}
default:
......
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