hoymilesClient/inc/hoymiles/portParameters/portParametersGeneric.h

70 lines
1.6 KiB
C
Raw Normal View History

#ifndef PORTPARAMETERSGENERIC_H
#define PORTPARAMETERSGENERIC_H
2024-03-20 19:55:36 +01:00
#include <memory>
#include <stdint.h>
#include <string>
struct _modbus;
typedef _modbus modbus_t;
class PortParameter {
protected:
uint16_t parameterAddressOffset;
int registerSize;
public:
2024-03-20 20:17:15 +01:00
PortParameter(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize);
virtual ~PortParameter();
enum PortParameterValueType { Int, Float };
union PortParameterValue {
2024-03-20 16:39:25 +01:00
long long i;
float f;
};
protected:
2024-03-20 19:55:36 +01:00
PortParameterValueType valueType;
PortParameterValue value;
public:
std::string name;
2024-03-20 20:17:15 +01:00
std::string shortName;
// int age;
std::pair<PortParameterValue, PortParameterValueType> getValue();
virtual std::string getOutputValue();
virtual void setValueFromRegisters(uint8_t *registers, int addressOffset);
// void updateValue(std::shared_ptr<class modbus> modubs, uint16_t portStartAddress);
};
2024-03-20 20:17:15 +01:00
class PortParameterFloat : public PortParameter {
protected:
2024-03-20 19:55:36 +01:00
int decimalPlaces;
2024-03-20 19:55:36 +01:00
public:
2024-03-20 20:17:15 +01:00
PortParameterFloat(std::string name, std::string shortName, int decimalPlaces, uint16_t parameterAddressOffset, int registerSize);
std::string getOutputValue();
virtual void setValueFromRegisters(uint8_t *registers, int addressOffset);
};
2024-03-20 20:17:15 +01:00
class PortParameterInt : public PortParameter {
2024-03-20 19:55:36 +01:00
protected:
2024-03-20 19:55:36 +01:00
public:
2024-03-20 20:17:15 +01:00
PortParameterInt(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize);
std::string getOutputValue();
virtual void setValueFromRegisters(uint8_t *registers, int addressOffset);
};
#endif