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")
38 static constexpr
unsigned int INITIAL_ADDRESS = 0;
39 static constexpr
WriteMode INITIAL_WRITE_MODE = WRITE_DELAYED;
40 static constexpr
int INITIAL_WRITE_DELAY = 500;
41 static constexpr
bool INITIAL_BUSY = true;
42 static constexpr
bool INITIAL_READ_ON_WRITE = true;
43 static constexpr
bool INITIAL_ENABLED = true;
55 Q_PROPERTY(
unsigned int address READ address WRITE setAddress NOTIFY addressChanged)
60 Q_PROPERTY(
bool busy READ busy NOTIFY busyChanged)
65 Q_PROPERTY(
bool readOnWrite READ readOnWrite WRITE setReadOnWrite NOTIFY readOnWriteChanged)
70 Q_PROPERTY(
WriteMode writeMode READ writeMode WRITE setWriteMode NOTIFY writeModeChanged)
75 Q_PROPERTY(
int writeDelay READ writeDelay WRITE setWriteDelay NOTIFY writeDelayChanged)
80 Q_PROPERTY(
bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
88 unsigned int address() const;
90 void setAddress(
unsigned int address);
94 bool readOnWrite() const;
96 void setReadOnWrite(
bool readOnWrite);
102 int writeDelay() const;
104 void setWriteDelay(
int writeDelay);
106 bool enabled() const;
108 void setEnabled(
bool enabled);
111 void deviceChanged();
113 void addressChanged();
117 void readOnWriteChanged();
119 void writeModeChanged();
121 void writeDelayChanged();
123 void enabledChanged();
126 virtual
void requestReadRegisters(quint16 address, quint16 amount,
QUuid * requestId) const = 0;
128 virtual quint16 bytes() const = 0;
130 virtual
void onDeviceDestroyed() = 0;
132 void classBegin() override;
134 void componentComplete() override;
136 void setBusy(
bool busy);
142 bool deviceReady() const;
147 unsigned int address;
153 bool deferRequestRead;
157 address(INITIAL_ADDRESS),
159 readOnWrite(INITIAL_READ_ON_WRITE),
160 writeMode(INITIAL_WRITE_MODE),
161 writeDelay(INITIAL_WRITE_DELAY),
162 enabled(INITIAL_ENABLED),
163 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