hoymilesClient/inc/hoymiles.h

65 lines
1.2 KiB
C
Raw Normal View History

#ifndef HOYMILES_H
#define HOYMILES_H
#include <stdint.h>
#include <vector>
2024-03-15 09:26:41 +01:00
#include <string>
struct _modbus;
typedef _modbus modbus_t;
2024-03-15 09:26:41 +01:00
class MicroinverterParameter {
public:
std::string name;
2024-03-15 09:26:41 +01:00
int valueInt;
float valueFloat;
2024-03-15 09:26:41 +01:00
int age;
2024-03-15 09:26:41 +01:00
uint16_t addressOffset;
int registerSize;
2024-03-15 09:26:41 +01:00
MicroinverterParameter(std::string name, uint16_t addressOffset, int registerSize);
2024-03-13 19:51:10 +01:00
2024-03-15 09:26:41 +01:00
void updateValue(modbus_t *modbus_context, uint16_t microinverterAddress);
};
2024-03-13 19:51:10 +01:00
2024-03-15 09:26:41 +01:00
class Microinverter{
private:
modbus_t *modbus_context;
uint16_t address;
2024-03-13 19:51:10 +01:00
2024-03-15 09:26:41 +01:00
std::vector<MicroinverterParameter> parameters;
public:
2024-03-15 09:26:41 +01:00
Microinverter(modbus_t *modbus_t, uint16_t address);
2024-03-15 09:26:41 +01:00
void updateParameters();
2024-03-15 09:26:41 +01:00
void updateParameterByIndex(int i);
2024-03-15 09:26:41 +01:00
void updateParameterByName(std::string name);
2024-03-15 09:26:41 +01:00
MicroinverterParameter getParameterByIndex(int i);
2024-03-15 09:26:41 +01:00
MicroinverterParameter getParameterByName(std::string name);
};
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();
};
#endif