1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_ABSTRACTREGISTERCONTROLLER_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_ABSTRACTREGISTERCONTROLLER_HPP
4 #include "internal/common.hpp"
5 #include "AbstractDevice.hpp"
8 #include <QQmlParserStatus>
35 static constexpr
unsigned int INITIAL_ADDRESS = 0;
36 static constexpr
WriteMode INITIAL_WRITE_MODE = WRITE_DELAYED;
37 static constexpr
int INITIAL_WRITE_DELAY = 500;
38 static constexpr
bool INITIAL_BUSY = true;
39 static constexpr
bool INITIAL_READ_ON_WRITE = true;
40 static constexpr
bool INITIAL_ENABLED = true;
45 Q_PROPERTY(
AbstractDevice * device READ device WRITE setDevice NOTIFY deviceChanged)
52 Q_PROPERTY(
unsigned int address READ address WRITE setAddress NOTIFY addressChanged)
57 Q_PROPERTY(
bool busy READ busy NOTIFY busyChanged)
62 Q_PROPERTY(
bool readOnWrite READ readOnWrite WRITE setReadOnWrite NOTIFY readOnWriteChanged)
67 Q_PROPERTY(
WriteMode writeMode READ writeMode WRITE setWriteMode NOTIFY writeModeChanged)
72 Q_PROPERTY(
int writeDelay READ writeDelay WRITE setWriteDelay NOTIFY writeDelayChanged)
77 Q_PROPERTY(
bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
85 unsigned int address() const;
87 void setAddress(
unsigned int address);
91 bool readOnWrite() const;
93 void setReadOnWrite(
bool readOnWrite);
99 int writeDelay() const;
101 void setWriteDelay(
int writeDelay);
103 bool enabled() const;
105 void setEnabled(
bool enabled);
108 void deviceChanged();
110 void addressChanged();
114 void readOnWriteChanged();
116 void writeModeChanged();
118 void writeDelayChanged();
120 void enabledChanged();
123 virtual
void requestReadRegisters(quint16 address, quint16 amount,
QUuid * requestId) const = 0;
125 virtual quint16 bytes() const = 0;
127 virtual
void onDeviceDestroyed() = 0;
129 void classBegin() override;
131 void componentComplete() override;
133 void setBusy(
bool busy);
139 bool deviceReady() const;
144 unsigned int address;
149 bool postponedWritePending;
151 bool deferRequestRead;
155 address(INITIAL_ADDRESS),
157 readOnWrite(INITIAL_READ_ON_WRITE),
158 writeMode(INITIAL_WRITE_MODE),
159 writeDelay(INITIAL_WRITE_DELAY),
160 enabled(INITIAL_ENABLED),
161 deferRequestRead(
false)