1#ifndef H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_ABSTRACTREGISTERCONTROLLER_HPP
2#define H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_ABSTRACTREGISTERCONTROLLER_HPP
4#include "internal/common.hpp"
5#include "AbstractDevice.hpp"
8#include <QQmlParserStatus>
24 QML_UNCREATABLE(
"AbstractRegisterController is an abstract class")
45 Q_ENUM(ValueSettingPolicy)
47 static constexpr
unsigned int INITIAL_ADDRESS = 0;
48 static constexpr
WriteMode INITIAL_WRITE_MODE = WRITE_DELAYED;
50 static constexpr
int INITIAL_WRITE_DELAY = 500;
51 static constexpr
bool INITIAL_BUSY = true;
52 static constexpr
bool INITIAL_READ_ON_WRITE = true;
53 static constexpr
bool INITIAL_ENABLED = true;
65 Q_PROPERTY(
unsigned int address READ address WRITE setAddress NOTIFY addressChanged)
70 Q_PROPERTY(
bool busy READ busy NOTIFY busyChanged)
75 Q_PROPERTY(
bool initialized READ initialized NOTIFY initializedChanged)
80 Q_PROPERTY(
bool readOnWrite READ readOnWrite WRITE setReadOnWrite NOTIFY readOnWriteChanged)
85 Q_PROPERTY(
WriteMode writeMode READ writeMode WRITE setWriteMode NOTIFY writeModeChanged)
90 Q_PROPERTY(
ValueSettingPolicy valueSettingPolicy READ valueSettingPolicy WRITE setValueSettingPolicy NOTIFY valueSettingPolicyChanged)
95 Q_PROPERTY(
int writeDelay READ writeDelay WRITE setWriteDelay NOTIFY writeDelayChanged)
100 Q_PROPERTY(
bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
108 unsigned int address() const;
110 void setAddress(
unsigned int address);
114 bool initialized() const;
116 bool readOnWrite() const;
118 void setReadOnWrite(
bool readOnWrite);
128 int writeDelay() const;
130 void setWriteDelay(
int writeDelay);
132 bool enabled() const;
134 void setEnabled(
bool enabled);
137 void deviceChanged();
139 void addressChanged();
143 void initializedChanged();
145 void readOnWriteChanged();
147 void writeModeChanged();
149 void valueSettingPolicyChanged();
151 void writeDelayChanged();
153 void enabledChanged();
156 virtual
void requestReadRegisters(quint16 address, quint16 amount,
QUuid * requestId) const = 0;
158 virtual quint16 bytes() const = 0;
160 virtual
void onDeviceDestroyed() = 0;
162 void classBegin() override;
164 void componentComplete() override;
166 void setBusy(
bool busy);
168 void setInitialized(
bool initialized);
174 bool deviceReady() const;
179 unsigned int address;
187 bool deferRequestRead;
191 address(INITIAL_ADDRESS),
194 readOnWrite(INITIAL_READ_ON_WRITE),
195 writeMode(INITIAL_WRITE_MODE),
196 valueSettingPolicy(INITIAL_VALUE_SETTING_POLICY),
197 writeDelay(INITIAL_WRITE_DELAY),
198 enabled(INITIAL_ENABLED),
199 deferRequestRead(
false)
Abstract Modbus device.
Definition: AbstractDevice.hpp:38
Abstract register controller.
Definition: AbstractRegisterController.hpp:20
WriteMode
Write mode enum.
Definition: AbstractRegisterController.hpp:30
@ WRITE_DELAYED
Writes are delayed. Write will be requested after amount of time specified by writeDelay property has...
Definition: AbstractRegisterController.hpp:31
@ WRITE_POSTPONED
Writes are postponed, which means that write will not be requested until previous write has finished.
Definition: AbstractRegisterController.hpp:32
@ WRITE_IMMEDIATE
Writes are requested immediately, which may creates a queue of pending writes if they are not proceed...
Definition: AbstractRegisterController.hpp:33
@ WRITE_EXPLICIT
Writes are explicit, i.e. write requires an explicit call to write value function.
Definition: AbstractRegisterController.hpp:34
ValueSettingPolicy
Value setting policy enum.
Definition: AbstractRegisterController.hpp:41
@ VALUE_SETTING_ALWAYS
Always handle setting a value and create write requests according to selected writeMode.
Definition: AbstractRegisterController.hpp:42
@ VALUE_SETTING_INITIALIZED
Handle set value and create write requests only when controller value has been initialized with value...
Definition: AbstractRegisterController.hpp:43