Reimplemented fixing current
This commit is contained in:
parent
2c27810dfe
commit
3c37cfd65f
1 changed files with 37 additions and 31 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "modbus.h"
|
#include "modbus.h"
|
||||||
|
|
||||||
|
|
@ -71,20 +71,24 @@ void Port::fixCurrent() {
|
||||||
if (this->currentFixed) {
|
if (this->currentFixed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this->parameters.size() < 8) {
|
|
||||||
|
if (!this->getParameterByName("pvCurrentMI").second != !this->getParameterByName("pvCurrentHM").second) {
|
||||||
|
this->currentFixed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this->parameters.at(7).get()->getValue().first.f == 0) {
|
|
||||||
return;
|
if (this->getParameterByName("pvVoltage").second && this->getParameterByName("pvPower").second) {
|
||||||
}
|
if (this->getParameterByName("pvCurrentMI").second && this->getParameterByName("pvCurrentHM").second) {
|
||||||
if(this->parameters.at(2).get()->getValue().first.f * this->parameters.at(4).get()->getValue().first.f < this->parameters.at(7).get()->getValue().first.f) {
|
if(this->getParameterByName("pvPower").first->getValue().first.f > this->getParameterByName("pvVoltage").first->getValue().first.f * this->getParameterByName("pvCurrentMI").first->getValue().first.f) {
|
||||||
this->parameters.erase(this->parameters.begin() + 4);
|
this->parameters.erase(std::find(this->parameters.begin(), this->parameters.end(), this->getParameterByName("pvCurrentHM").first));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->parameters.erase(this->parameters.begin() + 3);
|
this->parameters.erase(std::find(this->parameters.begin(), this->parameters.end(), this->getParameterByName("pvCurrentM").first));
|
||||||
}
|
}
|
||||||
this->currentFixed = true;
|
this->currentFixed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Port::updateParameters(std::vector<std::string> ¶metersToGet, bool allParameters) {
|
void Port::updateParameters(std::vector<std::string> ¶metersToGet, bool allParameters) {
|
||||||
if (allParameters && parametersToGet.size() < this->parameters.size()) {
|
if (allParameters && parametersToGet.size() < this->parameters.size()) {
|
||||||
|
|
@ -105,6 +109,9 @@ void Port::updateParameters(std::vector<std::string> ¶metersToGet, bool allP
|
||||||
if (parameterPair.second) {
|
if (parameterPair.second) {
|
||||||
parameterPair.first->updateValue(this->modbus, this->portStartAddress);
|
parameterPair.first->updateValue(this->modbus, this->portStartAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->fixCurrent();
|
||||||
|
|
||||||
parametersToGetIterator++;
|
parametersToGetIterator++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -134,5 +141,4 @@ void Port::printParameters(std::vector<std::string> ¶metersToGet, bool allPa
|
||||||
}
|
}
|
||||||
parametersToGetIterator++;
|
parametersToGetIterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue