It's asking but need to tweek setting values from registers
This commit is contained in:
parent
d0f8e5b885
commit
f3f1aa3903
8 changed files with 309 additions and 109 deletions
66
inc/hoymiles/portParameters/portParametersGeneric.h
Normal file
66
inc/hoymiles/portParameters/portParametersGeneric.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#ifndef PORTPARAMETERSGENERIC_H
|
||||
#define PORTPARAMETERSGENERIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
struct _modbus;
|
||||
typedef _modbus modbus_t;
|
||||
|
||||
class PortParameter {
|
||||
protected:
|
||||
uint16_t parameterAddressOffset;
|
||||
int registerSize;
|
||||
|
||||
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
|
||||
|
||||
public:
|
||||
PortParameter(std::string name, uint16_t parameterAddressOffset, int registerSize);
|
||||
|
||||
virtual ~PortParameter();
|
||||
|
||||
enum PortParameterValueType { Int, Float };
|
||||
|
||||
union PortParameterValue {
|
||||
long i;
|
||||
float f;
|
||||
};
|
||||
|
||||
protected:
|
||||
PortParameterValueType valueType;
|
||||
PortParameterValue value;
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
int age;
|
||||
|
||||
std::pair<PortParameterValue, PortParameterValueType> getValue();
|
||||
|
||||
virtual std::string getOutputValue();
|
||||
|
||||
void updateValue(modbus_t *modbus_context, uint16_t portStartAddress);
|
||||
};
|
||||
|
||||
class PortParameterFloat : virtual public PortParameter {
|
||||
protected:
|
||||
int decimalPlaces;
|
||||
|
||||
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
|
||||
|
||||
public:
|
||||
PortParameterFloat(std::string name, int decimalPlaces, uint16_t parameterAddressOffset, int registerSize);
|
||||
|
||||
std::string getOutputValue();
|
||||
};
|
||||
|
||||
class PortParameterInt : virtual public PortParameter {
|
||||
protected:
|
||||
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
|
||||
|
||||
public:
|
||||
PortParameterInt(std::string name, uint16_t parameterAddressOffset, int registerSize);
|
||||
|
||||
std::string getOutputValue();
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue