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