Removed multithreading for now, corrected connected

This commit is contained in:
TraYali 2024-03-19 12:54:05 +01:00
parent 089c7a77b5
commit e0135b6753
4 changed files with 34 additions and 20 deletions

View file

@ -1,4 +1,4 @@
#include <thread>
// #include <thread>
#include <iostream>
#include <memory>
@ -18,16 +18,16 @@ Microinverter::Microinverter(std::shared_ptr<modbus_t*> modbus_context, std::mut
}
void Microinverter::updatePorts() {
std::vector<std::thread> updateThreads;
// std::vector<std::thread> updateThreads;
for(Port port : this->ports){
updateThreads.push_back(std::thread(&Port::updateParameters, port));
// port.updateParameters();
}
std::vector<std::thread>::iterator updateThreadsIterator = updateThreads.begin();
while(updateThreadsIterator != updateThreads.end()) {
updateThreadsIterator->join();
updateThreadsIterator++;
// updateThreads.push_back(std::thread(&Port::updateParameters, port));
port.updateParameters();
}
// std::vector<std::thread>::iterator updateThreadsIterator = updateThreads.begin();
// while(updateThreadsIterator != updateThreads.end()) {
// updateThreadsIterator->join();
// updateThreadsIterator++;
// }
}
void Microinverter::printPorts() {