2024-03-16 22:51:32 +01:00
|
|
|
#ifndef PORTPARAMETERSGENERIC_H
|
|
|
|
|
#define PORTPARAMETERSGENERIC_H
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string>
|
2024-03-17 21:33:21 +01:00
|
|
|
#include <memory>
|
|
|
|
|
#include <mutex>
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
struct _modbus;
|
|
|
|
|
typedef _modbus modbus_t;
|
|
|
|
|
|
|
|
|
|
class PortParameter {
|
|
|
|
|
protected:
|
|
|
|
|
uint16_t parameterAddressOffset;
|
|
|
|
|
int registerSize;
|
|
|
|
|
|
2024-03-18 00:54:10 +01:00
|
|
|
virtual void setValueFromRegisters(uint16_t *readArray, int readArraySize);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
2024-03-18 00:54:10 +01:00
|
|
|
void updateValue(uint16_t *readArray, int readArraySize, int registerCount);
|
2024-03-16 22:51:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PortParameterFloat : virtual public PortParameter {
|
|
|
|
|
protected:
|
|
|
|
|
int decimalPlaces;
|
|
|
|
|
|
2024-03-18 00:54:10 +01:00
|
|
|
virtual void setValueFromRegisters(uint16_t *readArray, int readArraySize);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
PortParameterFloat(std::string name, int decimalPlaces, uint16_t parameterAddressOffset, int registerSize);
|
|
|
|
|
|
|
|
|
|
std::string getOutputValue();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PortParameterInt : virtual public PortParameter {
|
|
|
|
|
protected:
|
2024-03-18 00:54:10 +01:00
|
|
|
virtual void setValueFromRegisters(uint16_t *readArray, int readArraySize);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
PortParameterInt(std::string name, uint16_t parameterAddressOffset, int registerSize);
|
|
|
|
|
|
|
|
|
|
std::string getOutputValue();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|