2024-03-19 12:54:05 +01:00
|
|
|
// #include <thread>
|
2024-03-18 23:48:37 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <memory>
|
2024-03-17 21:33:21 +01:00
|
|
|
|
|
|
|
|
#include "modbus.h"
|
|
|
|
|
|
2024-03-16 21:15:15 +01:00
|
|
|
#include "microinverter.h"
|
|
|
|
|
#include "port.h"
|
|
|
|
|
|
2024-03-17 21:33:21 +01:00
|
|
|
struct _modbus;
|
|
|
|
|
typedef _modbus modbus_t;
|
|
|
|
|
|
2024-03-19 13:02:41 +01:00
|
|
|
Microinverter::Microinverter(std::shared_ptr<modbus_t*> modbus_context, long serialNumber) {
|
2024-03-16 21:15:15 +01:00
|
|
|
this->modbus_context = modbus_context;
|
2024-03-19 13:02:41 +01:00
|
|
|
// this->modbus_context_mutex = modbus_context_mutex;
|
2024-03-16 21:15:15 +01:00
|
|
|
|
2024-03-18 22:49:32 +01:00
|
|
|
this->serialNumber = serialNumber;
|
2024-03-16 21:15:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Microinverter::updatePorts() {
|
2024-03-19 12:54:05 +01:00
|
|
|
// std::vector<std::thread> updateThreads;
|
2024-03-16 21:15:15 +01:00
|
|
|
for(Port port : this->ports){
|
2024-03-19 12:54:05 +01:00
|
|
|
// updateThreads.push_back(std::thread(&Port::updateParameters, port));
|
|
|
|
|
port.updateParameters();
|
2024-03-16 21:15:15 +01:00
|
|
|
}
|
2024-03-19 12:54:05 +01:00
|
|
|
// std::vector<std::thread>::iterator updateThreadsIterator = updateThreads.begin();
|
|
|
|
|
// while(updateThreadsIterator != updateThreads.end()) {
|
|
|
|
|
// updateThreadsIterator->join();
|
|
|
|
|
// updateThreadsIterator++;
|
|
|
|
|
// }
|
2024-03-18 23:48:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-16 21:15:15 +01:00
|
|
|
}
|