2024-03-13 00:18:10 +01:00
|
|
|
#ifndef HOYMILES_H
|
|
|
|
|
#define HOYMILES_H
|
|
|
|
|
|
2024-03-13 16:54:03 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2024-03-13 00:18:10 +01:00
|
|
|
struct _modbus;
|
|
|
|
|
typedef _modbus modbus_t;
|
|
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
class Microinverter{
|
2024-03-13 00:18:10 +01:00
|
|
|
private:
|
2024-03-13 19:51:10 +01:00
|
|
|
modbus_t *modbus_context;
|
|
|
|
|
uint16_t address;
|
2024-03-13 00:18:10 +01:00
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
void updatePortNumber();
|
2024-03-13 16:54:03 +01:00
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
void updatePlantVoltage();
|
|
|
|
|
void updatePlantCurrent();
|
2024-03-13 00:18:10 +01:00
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
void updateGridVoltage();
|
|
|
|
|
void updateGridFrequency();
|
2024-03-13 00:18:10 +01:00
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
void updatePlantPower();
|
2024-03-13 00:18:10 +01:00
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
void updateTodayProduction();
|
|
|
|
|
void updateTotalProduction();
|
|
|
|
|
|
|
|
|
|
void updateTemperature();
|
|
|
|
|
|
|
|
|
|
void updateOperatingStatus();
|
|
|
|
|
void updateAlarmCode();
|
|
|
|
|
void updateAlarmCount();
|
|
|
|
|
|
|
|
|
|
void updateLinkStatus();
|
2024-03-13 16:54:03 +01:00
|
|
|
|
|
|
|
|
public:
|
2024-03-13 19:51:10 +01:00
|
|
|
int serialNumber;
|
2024-03-13 16:54:03 +01:00
|
|
|
std::pair<int, int> portNumber;
|
|
|
|
|
|
|
|
|
|
std::pair<float, int> plantVoltage;
|
|
|
|
|
std::pair<float, int> plantCurrent;
|
|
|
|
|
|
|
|
|
|
std::pair<float, int> gridVoltage;
|
|
|
|
|
std::pair<float, int> gridFrequency;
|
|
|
|
|
|
|
|
|
|
std::pair<float, int> plantPower;
|
|
|
|
|
|
|
|
|
|
std::pair<long, int> todayProduction;
|
|
|
|
|
std::pair<long, int> totalProduction;
|
|
|
|
|
|
|
|
|
|
std::pair<int, int> temperature;
|
|
|
|
|
|
|
|
|
|
std::pair<int, int> operatingStatus;
|
|
|
|
|
std::pair<int, int> alarmCode;
|
|
|
|
|
std::pair<int, int> alarmCount;
|
|
|
|
|
|
|
|
|
|
std::pair<int, int> linkStatus;
|
|
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
Microinverter(modbus_t *modbus_t, uint16_t address);
|
2024-03-13 16:54:03 +01:00
|
|
|
|
|
|
|
|
void updateValues();
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-13 19:51:10 +01:00
|
|
|
class Dtu{
|
|
|
|
|
private:
|
|
|
|
|
modbus_t *modbus_context;
|
|
|
|
|
|
|
|
|
|
std::vector<Microinverter> microinverters;
|
|
|
|
|
|
|
|
|
|
void populateMicroinverters();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Dtu(const char *ip_address, int port);
|
|
|
|
|
|
|
|
|
|
void updateMicroinverters();
|
|
|
|
|
|
|
|
|
|
~Dtu();
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-13 00:18:10 +01:00
|
|
|
#endif
|