Commit 242b102e authored by Alessio Netti's avatar Alessio Netti
Browse files

Analytics: fixes to Cooling Control plugin

parent d153944d
......@@ -99,6 +99,7 @@ void CoolingControlOperator::compute(U_Ptr unit) {
newSetting = steppedControl(buffer, unit);
}
// LOG(debug) << "New setting: " << newSetting;
// Enacting control
if( newSetting >= 0 && _controller.open() ) {
try {
......@@ -114,11 +115,11 @@ void CoolingControlOperator::compute(U_Ptr unit) {
int CoolingControlOperator::continuousControl(std::vector<std::vector<reading_t>> &readings, U_Ptr unit) {
if( _currTemp == 0 ) {
_currTemp = (_maxTemp - _minTemp) / 2;
_currTemp = (_maxTemp + _minTemp) / 2;
} else {
// If there are less hot nodes than our hot threshold, we increase the inlet temperature - and vice versa
uint64_t percHotNodes = (getNumHotNodes(readings, unit) * 100) / readings.size();
_currTemp += (_hotPerc - percHotNodes) * (_maxTemp - _minTemp) / 100;
_currTemp = (int64_t)_currTemp + ((int64_t)_hotPerc - (int64_t)percHotNodes) * ((int64_t)_maxTemp - (int64_t)_minTemp) / 100;
_currTemp = clipTemperature(_currTemp);
}
return (int)_currTemp;
......@@ -128,12 +129,12 @@ int CoolingControlOperator::steppedControl(std::vector<std::vector<reading_t>> &
uint64_t oldTemp = _currTemp;
int ret = -1;
if(_currTemp == 0) {
_currTemp = (_maxTemp - _minTemp) / 2;
_currTemp = (_maxTemp + _minTemp) / 2;
return _currTemp;
} else {
// If there are less hot nodes than our hot threshold, we increase the inlet temperature - and vice versa
uint64_t percHotNodes = (getNumHotNodes(readings, unit) * 100) / readings.size();
_currTemp += (_hotPerc - percHotNodes) * (_maxTemp - _minTemp) / 100;
_currTemp = (int64_t)_currTemp + ((int64_t)_hotPerc - (int64_t)percHotNodes) * ((int64_t)_maxTemp - (int64_t)_minTemp) / 100;
_currTemp = clipTemperature(_currTemp);
// We're crossing to a new bin - assigning the new setting
if(getBinForValue(oldTemp) != getBinForValue(_currTemp)) {
......
......@@ -53,7 +53,7 @@ public:
// Copy constructor
CoolingControlSensorBase(CoolingControlSensorBase& other) : SNMPSensorBase(other) {
_hotThreshold = 70;
_hotThreshold = other._hotThreshold;
}
virtual ~CoolingControlSensorBase() {}
......
......@@ -57,4 +57,10 @@ void SNMPController::set(const oid *const OID, size_t OIDLen, unsigned char type
if (response) {
snmp_free_pdu(response);
}
}
void SNMPController::printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "OIDSuffix: " << getOIDSuffix();
SNMPConnection::printEntityConfig(ll, leadingSpaces);
}
\ No newline at end of file
......@@ -55,6 +55,8 @@ public:
}
}
}
void printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) override;
protected:
......
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