tetea
This commit is contained in:
parent
b10fe4880f
commit
089c7a77b5
2 changed files with 22 additions and 0 deletions
|
|
@ -15,6 +15,8 @@ Port::Port(std::shared_ptr<modbus_t*> modbus_context, std::mutex *modbus_context
|
|||
|
||||
this->portStartAddress = portStartAddress;
|
||||
|
||||
this->currentFixed = false;
|
||||
|
||||
this->populateParameters();
|
||||
}
|
||||
|
||||
|
|
@ -50,12 +52,29 @@ void Port::populateParameters() {
|
|||
this->parameters.push_back(std::make_shared<PortParameterLinkStatus>());
|
||||
}
|
||||
|
||||
void Port::fixCurrent() {
|
||||
if(this->currentFixed) {
|
||||
return;
|
||||
}
|
||||
if(this->parameters.at(7).get()->getValue().first.f == 0) {
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
this->parameters.erase(this->parameters.begin() + 4);
|
||||
}
|
||||
else {
|
||||
this->parameters.erase(this->parameters.begin() + 3);
|
||||
}
|
||||
this->currentFixed = true;
|
||||
}
|
||||
|
||||
void Port::updateParameters() {
|
||||
std::vector<std::shared_ptr<PortParameter>>::iterator parametersIterator{this->parameters.begin()};
|
||||
while (parametersIterator != this->parameters.end()) {
|
||||
parametersIterator->get()->updateValue(this->modbus_context, this->modbus_context_mutex, this->portStartAddress);
|
||||
parametersIterator++;
|
||||
}
|
||||
this->fixCurrent();
|
||||
}
|
||||
|
||||
void Port::printParameters() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue