2024-03-16 21:15:15 +01:00
|
|
|
#ifndef DTU_H
|
|
|
|
|
#define DTU_H
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
2024-03-17 21:33:21 +01:00
|
|
|
#include <memory>
|
|
|
|
|
#include <mutex>
|
2024-03-16 21:15:15 +01:00
|
|
|
|
|
|
|
|
#include "microinverter.h"
|
|
|
|
|
|
|
|
|
|
struct _modbus;
|
|
|
|
|
typedef _modbus modbus_t;
|
|
|
|
|
|
|
|
|
|
class Dtu {
|
|
|
|
|
private:
|
2024-03-17 21:33:21 +01:00
|
|
|
std::shared_ptr<modbus_t*> modbus_context;
|
|
|
|
|
std::mutex modbus_context_mutex;
|
2024-03-16 21:15:15 +01:00
|
|
|
|
|
|
|
|
std::vector<Microinverter> microinverters;
|
|
|
|
|
|
2024-03-19 12:54:05 +01:00
|
|
|
bool connected;
|
|
|
|
|
|
2024-03-16 21:15:15 +01:00
|
|
|
void populateMicroinverters();
|
|
|
|
|
|
2024-03-18 22:49:32 +01:00
|
|
|
std::pair<bool, Microinverter*> getMicroinverterBySerialNumber(long serialNumber);
|
|
|
|
|
|
2024-03-16 21:15:15 +01:00
|
|
|
public:
|
|
|
|
|
Dtu(const char *ip_address, int port);
|
|
|
|
|
|
2024-03-19 12:54:05 +01:00
|
|
|
bool isConnected();
|
|
|
|
|
|
2024-03-16 21:15:15 +01:00
|
|
|
void updateMicroinverters();
|
|
|
|
|
|
2024-03-18 23:48:37 +01:00
|
|
|
void printMicroinverters();
|
|
|
|
|
|
2024-03-16 21:15:15 +01:00
|
|
|
~Dtu();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|