hoymilesClient/inc/hoymiles.h

99 lines
1.7 KiB
C
Raw Normal View History

#ifndef HOYMILES_H
#define HOYMILES_H
#include <stdint.h>
2024-03-15 09:26:41 +01:00
#include <string>
#include <vector>
#include <memory>
struct _modbus;
typedef _modbus modbus_t;
class PortParameter {
protected:
uint16_t addressOffset;
int registerSize;
void setValue(uint16_t *readArray, int registerCount);
public:
PortParameter(std::string name, uint16_t addressOffset, int registerSize);
std::string name;
int age;
int value;
2024-03-13 19:51:10 +01:00
virtual void updateValue(modbus_t *modbus_context, uint16_t portStartAddress);
2024-03-15 09:26:41 +01:00
};
2024-03-13 19:51:10 +01:00
class PortParameterSerialNumber : public PortParameter {
private:
void setValue(uint16_t *readArray, int registerCount);
public:
PortParameterSerialNumber();
};
2024-03-13 19:51:10 +01:00
class PortParameterFloat : public PortParameter {
private:
int decimalPlaces;
void setValue(uint16_t *readArray, int registerCount);
public:
PortParameterFloat(std::string name, uint16_t addressOffset, int registerSize, int decimalPlaces);
float value;
};
class Port {
private:
modbus_t *modbus_context;
uint16_t portStartAddress;
std::vector<std::shared_ptr<PortParameter>> parameters;
void populateParameters();
public:
Port(modbus_t *modbus_context, uint16_t portStartAddress);
2024-03-15 09:26:41 +01:00
void updateParameters();
};
class Microinverter {
private:
modbus_t *modbus_context;
std::vector<Port> ports;
void populatePorts();
public:
Microinverter(modbus_t *modbus_t);
void updatePorts();
void updatePort(int i);
Port getPort(int i);
};
class Dtu {
private:
modbus_t *modbus_context;
2024-03-13 19:51:10 +01:00
std::vector<Microinverter> microinverters;
2024-03-13 19:51:10 +01:00
void populateMicroinverters();
2024-03-13 19:51:10 +01:00
public:
Dtu(const char *ip_address, int port);
2024-03-13 19:51:10 +01:00
void updateMicroinverters();
2024-03-13 19:51:10 +01:00
~Dtu();
2024-03-13 19:51:10 +01:00
};
#endif