2024-03-16 22:51:32 +01:00
|
|
|
#ifndef PORTPARAMETERSGENERIC_H
|
|
|
|
|
#define PORTPARAMETERSGENERIC_H
|
|
|
|
|
|
2024-03-20 19:55:36 +01:00
|
|
|
#include <memory>
|
2024-03-16 22:51:32 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
struct _modbus;
|
|
|
|
|
typedef _modbus modbus_t;
|
|
|
|
|
|
|
|
|
|
class PortParameter {
|
|
|
|
|
protected:
|
|
|
|
|
uint16_t parameterAddressOffset;
|
|
|
|
|
int registerSize;
|
|
|
|
|
|
2024-03-18 13:44:25 +01:00
|
|
|
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
public:
|
2024-03-20 20:17:15 +01:00
|
|
|
PortParameter(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
virtual ~PortParameter();
|
|
|
|
|
|
|
|
|
|
enum PortParameterValueType { Int, Float };
|
|
|
|
|
|
|
|
|
|
union PortParameterValue {
|
2024-03-20 16:39:25 +01:00
|
|
|
long long i;
|
2024-03-16 22:51:32 +01:00
|
|
|
float f;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected:
|
2024-03-20 19:55:36 +01:00
|
|
|
PortParameterValueType valueType;
|
2024-03-16 22:51:32 +01:00
|
|
|
PortParameterValue value;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
std::string name;
|
2024-03-20 20:17:15 +01:00
|
|
|
std::string shortName;
|
|
|
|
|
|
2024-03-16 22:51:32 +01:00
|
|
|
int age;
|
|
|
|
|
|
|
|
|
|
std::pair<PortParameterValue, PortParameterValueType> getValue();
|
|
|
|
|
|
|
|
|
|
virtual std::string getOutputValue();
|
|
|
|
|
|
2024-03-20 11:28:43 +01:00
|
|
|
void updateValue(std::shared_ptr<class modbus> modubs, uint16_t portStartAddress);
|
2024-03-16 22:51:32 +01:00
|
|
|
};
|
|
|
|
|
|
2024-03-20 20:17:15 +01:00
|
|
|
class PortParameterFloat : public PortParameter {
|
2024-03-16 22:51:32 +01:00
|
|
|
protected:
|
2024-03-20 19:55:36 +01:00
|
|
|
int decimalPlaces;
|
2024-03-16 22:51:32 +01:00
|
|
|
|
2024-03-20 19:55:36 +01:00
|
|
|
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
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);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
std::string getOutputValue();
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-20 20:17:15 +01:00
|
|
|
class PortParameterInt : public PortParameter {
|
2024-03-20 19:55:36 +01:00
|
|
|
protected:
|
2024-03-18 13:44:25 +01:00
|
|
|
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
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);
|
2024-03-16 22:51:32 +01:00
|
|
|
|
|
|
|
|
std::string getOutputValue();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|