hoymilesClient/src/hoymiles/microinverter.cpp

59 lines
1.7 KiB
C++
Raw Normal View History

// #include <thread>
#include <iostream>
#include <memory>
2024-03-20 11:28:43 +01:00
#include <string>
#include "modbus.h"
2024-03-16 21:15:15 +01:00
#include "microinverter.h"
#include "port.h"
2024-03-19 18:13:27 +01:00
Microinverter::Microinverter(std::shared_ptr<class modbus> modbus, long serialNumber) {
this->modbus = modbus;
// this->modbus_context_mutex = modbus_context_mutex;
2024-03-16 21:15:15 +01:00
this->serialNumber = serialNumber;
2024-03-16 21:15:15 +01:00
}
void Microinverter::updatePorts() {
// std::vector<std::thread> updateThreads;
2024-03-16 21:15:15 +01:00
for(Port port : this->ports){
// updateThreads.push_back(std::thread(&Port::updateParameters, port));
port.updateParameters();
2024-03-16 21:15:15 +01:00
}
// std::vector<std::thread>::iterator updateThreadsIterator = updateThreads.begin();
// while(updateThreadsIterator != updateThreads.end()) {
// updateThreadsIterator->join();
// updateThreadsIterator++;
// }
}
2024-03-20 11:28:43 +01:00
void Microinverter::updatePorts(std::vector<std::string> &parametersToGet) {
std::vector<Port>::iterator portsIterator = this->ports.begin();
while(portsIterator != this->ports.end()) {
portsIterator->updateParameters(parametersToGet);
portsIterator++;
}
}
void Microinverter::printPorts() {
std::cout << "Microinverter: " << this->serialNumber << std::endl;
std::vector<Port>::iterator portsIterator = this->ports.begin();
while(portsIterator != this->ports.end()) {
portsIterator->printParameters();
std::cout << std::endl;
portsIterator++;
}
2024-03-20 11:28:43 +01:00
}
void Microinverter::printPorts(std::vector<std::string> &parametersToGet) {
std::cout << "Microinverter: " << this->serialNumber << std::endl;
std::vector<Port>::iterator portsIterator = this->ports.begin();
while(portsIterator != this->ports.end()) {
portsIterator->printParameters(parametersToGet);
std::cout << std::endl;
portsIterator++;
}
2024-03-16 21:15:15 +01:00
}