1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_REGISTER16CONTROLLER_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_REGISTER16CONTROLLER_HPP
4 #include "internal/common.hpp"
5 #include "internal/RegisterControllerMixin.hpp"
6 #include "Register16.hpp"
7 #include "AbstractRegisterController.hpp"
33 static constexpr qreal INITIAL_VALUE = 0.0;
34 static constexpr qreal INITIAL_VALUE_SCALE = 1.0;
35 static constexpr
Encoding INITIAL_ENCODING = UINT16;
37 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
38 Q_PROPERTY(qreal valueScale READ valueScale WRITE setValueScale NOTIFY valueScaleChanged)
39 Q_PROPERTY(
Encoding encoding READ encoding WRITE setEncoding NOTIFY encodingChanged)
47 void setValue(qreal value);
49 qreal valueScale() const;
51 void setValueScale(qreal valueScale);
65 void valueScaleChanged();
67 void encodingChanged();
76 virtual
AbstractDevice::Function readRegistersFunction() const = 0;
78 virtual
AbstractDevice::Function writeRegisterFunction() const = 0;
80 virtual
void requestWriteRegister(quint16 address, quint16 value,
QUuid * requestId) const = 0;
82 virtual
Register16 * registerAt(quint16 address) const = 0;
86 quint16 bytes() const override;
88 void onDeviceDestroyed() override;
98 void updateValue(quint16 value);
102 static qreal Decode(quint16 value,
Encoding encoding);
104 static quint16 Encode(qreal value,
Encoding encoding);
106 static
bool ValidateEncoding(qreal value,
Encoding encoding);
108 void requestWrite(qreal value);
110 bool verifyRegisterValue() const;
118 bool postponedWritePending;
120 qreal requestedValue;
126 value(INITIAL_VALUE),
127 valueScale(INITIAL_VALUE_SCALE),
128 encoding(INITIAL_ENCODING),
129 postponedWritePending(
false),
130 adjustingValue(
false),