CuteHMI - Modbus (CuteHMI.Modbus.4)
|
Abstract Modbus device. More...
#include <cutehmi/modbus/AbstractDevice.hpp>
Public Slots | |
virtual void | open ()=0 |
virtual void | close ()=0 |
Signals | |
void | errored (cutehmi::InplaceError error) |
void | stateChanged () |
void | readyChanged () |
void | maxReadCoilsChanged () |
void | maxWriteCoilsChanged () |
void | maxReadDiscreteInputsChanged () |
void | maxWriteDiscreteInputsChanged () |
void | maxReadHoldingRegistersChanged () |
void | maxWriteHoldingRegistersChanged () |
void | maxReadInputRegistersChanged () |
void | maxWriteInputRegistersChanged () |
void | maxRequestsChanged () |
void | requestCompleted (QJsonObject request, QJsonObject reply) |
Public Member Functions | |
State | state () const |
bool | ready () const |
Get readiness status. More... | |
int | maxReadCoils () const |
void | setMaxReadCoils (int maxReadCoils) |
int | maxWriteCoils () const |
void | setMaxWriteCoils (int maxWriteCoils) |
int | maxReadDiscreteInputs () const |
void | setMaxReadDiscreteInputs (int maxReadDiscreteInputs) |
int | maxWriteDiscreteInputs () const |
void | setMaxWriteDiscreteInputs (int maxWriteDiscreteInputs) |
int | maxReadHoldingRegisters () const |
void | setMaxReadHoldingRegisters (int maxReadHoldingRegisters) |
int | maxWriteHoldingRegisters () const |
void | setMaxWriteHoldingRegisters (int maxWriteHoldingRegisters) |
int | maxReadInputRegisters () const |
void | setMaxReadInputRegisters (int maxReadInputRegisters) |
int | maxWriteInputRegisters () const |
void | setMaxWriteInputRegisters (int maxWriteInputRegisters) |
int | maxRequests () const |
void | setMaxRequests (int maxRequests) |
Coil * | coilAt (quint16 address) |
DiscreteInput * | discreteInputAt (quint16 address) |
HoldingRegister * | holdingRegisterAt (quint16 address) |
InputRegister * | inputRegisterAt (quint16 address) |
Q_INVOKABLE void | requestReadCoils (quint16 address, quint16 amount=1, QUuid *requestId=nullptr) |
Read coils request. More... | |
Q_INVOKABLE void | requestWriteCoil (quint16 address, bool value, QUuid *requestId=nullptr) |
Write coils request. More... | |
Q_INVOKABLE void | requestWriteMultipleCoils (quint16 address, QJsonArray values, QUuid *requestId=nullptr) |
Write multiple coils request. More... | |
Q_INVOKABLE void | requestReadDiscreteInputs (quint16 address, quint16 amount=1, QUuid *requestId=nullptr) |
Read discrete inputs request. More... | |
Q_INVOKABLE void | requestWriteDiscreteInput (quint16 address, bool value, QUuid *requestId=nullptr) |
Write discrete input request. More... | |
Q_INVOKABLE void | requestWriteMultipleDiscreteInputs (quint16 address, QJsonArray values, QUuid *requestId=nullptr) |
Write multiple discrete inputs request. More... | |
Q_INVOKABLE void | requestReadHoldingRegisters (quint16 address, quint16 amount=1, QUuid *requestId=nullptr) |
Read holding registers request. More... | |
Q_INVOKABLE void | requestWriteHoldingRegister (quint16 address, quint16 value, QUuid *requestId=nullptr) |
Write holding register request. More... | |
Q_INVOKABLE void | requestWriteMultipleHoldingRegisters (quint16 address, QJsonArray values, QUuid *requestId=nullptr) |
Write multiple holding registers request. More... | |
Q_INVOKABLE void | requestReadInputRegisters (quint16 address, quint16 amount=1, QUuid *requestId=nullptr) |
Read input registers request. More... | |
Q_INVOKABLE void | requestWriteInputRegister (quint16 address, quint16 value, QUuid *requestId=nullptr) |
Write input register request. More... | |
Q_INVOKABLE void | requestWriteMultipleInputRegisters (quint16 address, QJsonArray values, QUuid *requestId=nullptr) |
Write multiple input registers request. More... | |
Q_INVOKABLE void | requestDiagnostics (cutehmi::modbus::AbstractDevice::DiagnosticsSubfunction subfunction, quint16 data, QUuid *requestId=nullptr) |
Diagonistics request. More... | |
Q_INVOKABLE void | requestReadExceptionStatus (QUuid *requestId=nullptr) |
Report slave id request. More... | |
Q_INVOKABLE void | requestFetchCommEventCounter (QUuid *requestId=nullptr) |
Report slave id request. More... | |
Q_INVOKABLE void | requestFetchCommEventLog (QUuid *requestId=nullptr) |
Report slave id request. More... | |
Q_INVOKABLE void | requestReportSlaveId (QUuid *requestId=nullptr) |
Report slave id request. More... | |
Q_INVOKABLE void | requestMaskWriteHoldingRegister (quint16 address, quint16 andMask, quint16 orMask, QUuid *requestId=nullptr) |
Mask write holding register request. More... | |
Q_INVOKABLE void | requestReadWriteMultipleHoldingRegisters (quint16 readAddress, quint16 amount, quint16 writeAddress, QJsonArray values, QUuid *requestId=nullptr) |
Read/write multiple holding registers request. More... | |
Q_INVOKABLE void | requestReadFIFOQueue (quint16 address, QUuid *requestId=nullptr) |
Read FIFO queue request. More... | |
Q_INVOKABLE QJsonObject | readFileRecordSubrequest (quint16 file, quint16 address, quint16 amount) |
Generate read file record subrequest. More... | |
Q_INVOKABLE void | requestReadFileRecord (QJsonArray subrequests, QUuid *requestId=nullptr) |
Read file record request. More... | |
Q_INVOKABLE QJsonObject | writeFileRecordSubrequest (quint16 file, quint16 address, QJsonArray values) |
Generate write file record subrequest. More... | |
Q_INVOKABLE void | requestWriteFileRecord (QJsonArray subrequests, QUuid *requestId=nullptr) |
Write file record request. More... | |
Q_INVOKABLE void | request (cutehmi::modbus::AbstractDevice::Function function, QJsonObject payload, QUuid *requestId=nullptr) |
Modbus function request. More... | |
Public Member Functions inherited from QObject | |
virtual const QMetaObject * | metaObject () const const |
QObject (QObject *parent) | |
virtual | ~QObject () |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
Q_CLASSINFO (Name, Value) | |
Q_INTERFACES (...) | |
Q_PROPERTY (...) | |
Q_ENUMS (...) | |
Q_FLAGS (...) | |
Q_ENUM (...) | |
Q_FLAG (...) | |
Q_ENUM_NS (...) | |
Q_FLAG_NS (...) | |
Q_OBJECT Q_OBJECT | |
Q_GADGET Q_GADGET | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_SIGNALS Q_SIGNALS | |
Q_SIGNAL Q_SIGNAL | |
Q_SLOTS Q_SLOTS | |
Q_SLOT Q_SLOT | |
Q_EMIT Q_EMIT | |
Q_INVOKABLE Q_INVOKABLE | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Public Member Functions inherited from cutehmi::services::Serviceable | |
virtual void | configureStarting (QState *starting, AssignStatusFunction assignStatus)=0 |
virtual void | configureStarted (QState *active, const QState *idling, const QState *yielding, AssignStatusFunction assignStatus)=0 |
virtual void | configureStopping (QState *stopping, AssignStatusFunction assignStatus)=0 |
virtual void | configureBroken (QState *broken, AssignStatusFunction assignStatus)=0 |
virtual void | configureRepairing (QState *repairing, AssignStatusFunction assignStatus)=0 |
virtual void | configureEvacuating (QState *evacuating, AssignStatusFunction assignStatus)=0 |
virtual std::unique_ptr< QAbstractTransition > | transitionToStarted () const=0 |
virtual std::unique_ptr< QAbstractTransition > | transitionToStopped () const=0 |
virtual std::unique_ptr< QAbstractTransition > | transitionToBroken () const=0 |
virtual std::unique_ptr< QAbstractTransition > | transitionToYielding () const=0 |
virtual std::unique_ptr< QAbstractTransition > | transitionToIdling () const=0 |
Static Public Attributes | |
static constexpr quint16 | MIN_ADDRESS = 0 |
static constexpr quint16 | MAX_ADDRESS = 65535 |
static constexpr int | INITIAL_MAX_READ_COILS = 16 |
static constexpr int | INITIAL_MAX_WRITE_COILS = 16 |
static constexpr int | INITIAL_MAX_READ_DISCRETE_INPUTS = 16 |
static constexpr int | INITIAL_MAX_WRITE_DISCRETE_INPUTS = 16 |
static constexpr int | INITIAL_MAX_READ_HOLDING_REGISTERS = 16 |
static constexpr int | INITIAL_MAX_WRITE_HOLDING_REGISTERS = 16 |
static constexpr int | INITIAL_MAX_READ_INPUT_REGISTERS = 16 |
static constexpr int | INITIAL_MAX_WRITE_INPUT_REGISTERS = 16 |
static constexpr int | INITIAL_MAX_REQUESTS = 1000 |
static constexpr State | INITIAL_STATE = CLOSED |
static constexpr bool | INITIAL_READY = false |
Query limits. | |
Modbus protocol imposes following restriction on amount of data that can be read or write at once.
This means that Modbus message must not exceed 256 octets in size. In Modbus over TCP, device address and CRC (3 octets) are traded for 6 octet header and 1 octet unit identifier, which gives 4 octets less to store values. Theoretical maximal amounts of values for given Modbus register types, that can be queried within a single message, are defined by constants below, however particular PLCs may impose further restrictions. | |
static constexpr int | MAX_READ_TCP_COILS = 1976 |
Maximal amount of coils that can be read at once through TCP. More... | |
static constexpr int | MAX_READ_RTU_COILS = 2008 |
Maximal amount of coils that can be read at once through RTU. More... | |
static constexpr int | MAX_WRITE_TCP_COILS = 1944 |
Maximal amount of coils that can be written at once through TCP. More... | |
static constexpr int | MAX_WRITE_RTU_COILS = 1976 |
Maximal amount of coils that can be written at once through RTU. More... | |
static constexpr int | MAX_READ_TCP_DISCRETE_INPUTS = 1976 |
Maximal amount of discrete inputs that can be read at once through TCP. More... | |
static constexpr int | MAX_READ_RTU_DISCRETE_INPUTS = 2008 |
Maximal amount of discrete inputs that can be read at once through RTU. More... | |
static constexpr int | MAX_READ_TCP_HOLDING_REGISTERS = 123 |
Maximal amount of holding registers that can be read at once through TCP. More... | |
static constexpr int | MAX_READ_RTU_HOLDING_REGISTERS = 125 |
Maximal amount of holding registers that can be read at once through RTU. More... | |
static constexpr int | MAX_WRITE_TCP_HOLDING_REGISTERS = 123 |
Maximal amount of holding registers that can be written at once through TCP. More... | |
static constexpr int | MAX_WRITE_RTU_HOLDING_REGISTERS = 125 |
Maximal amount of holding registers that can be written at once through RTU. More... | |
static constexpr int | MAX_READ_TCP_INPUT_REGISTERS = 123 |
Maximal amount of input registers that can be read at once through TCP. More... | |
static constexpr int | MAX_READ_RTU_INPUT_REGISTERS = 125 |
Maximal amount of input registers that can be read at once through RTU. More... | |
Protected Types | |
typedef internal::RegisterTraits< internal::Coil >::Container | CoilDataContainer |
typedef internal::RegisterTraits< internal::DiscreteInput >::Container | DiscreteInputDataContainer |
typedef internal::RegisterTraits< internal::HoldingRegister >::Container | HoldingRegisterDataContainer |
typedef internal::RegisterTraits< internal::InputRegister >::Container | InputRegisterDataContainer |
Protected Slots | |
virtual void | handleReply (QUuid requestId, QJsonObject reply) |
Reply handler. More... | |
void | setState (cutehmi::modbus::AbstractDevice::State state) |
void | setReady (bool ready) |
void | handleError (cutehmi::InplaceError error) |
Properties | |
State | state |
bool | ready |
int | maxReadCoils |
int | maxWriteCoils |
int | maxReadDiscreteInputs |
int | maxWriteDiscreteInputs |
int | maxReadHoldingRegisters |
int | maxWriteHoldingRegisters |
int | maxReadInputRegisters |
int | maxWriteInputRegisters |
int | maxRequests |
Properties inherited from QObject | |
objectName | |
Friends | |
class | test_AbstractDevice |
class | test_AbstractServer |
class | internal::IterableTasks |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Public Attributes inherited from QObject | |
typedef | QObjectList |
Abstract Modbus device.
|
protected |
|
protected |
|
protected |
|
protected |
enum cutehmi::modbus::AbstractDevice::DiagnosticsSubfunction : quint16 |
|
protected |
|
overrideprotected |
Destructor.
|
protected |
|
pure virtualslot |
Coil * cutehmi::modbus::AbstractDevice::coilAt | ( | quint16 | address | ) |
|
protected |
|
protected |
DiscreteInput * cutehmi::modbus::AbstractDevice::discreteInputAt | ( | quint16 | address | ) |
|
protected |
|
protected |
|
signal |
|
protectedslot |
|
protectedvirtualslot |
Reply handler.
requestId | request id. |
reply | reply data. |
Reimplemented in cutehmi::modbus::AbstractClient.
|
protectedpure virtual |
Handle request.
This function acts as request handler, that derived class must implement. Internally request() function creates request object and passes it to request handler of derived class. Request object is added to pending requests queue. Derived class should start processing request. Once request completes derived class is expected to prepare reply and call handleReply() function. Otherwise it has to remove request from queue by calling takePendingRequest() function and emit requestCompleted() signal.
request | request object containing request header and payload. |
Implemented in cutehmi::modbus::AbstractClient, and cutehmi::modbus::AbstractServer.
HoldingRegister * cutehmi::modbus::AbstractDevice::holdingRegisterAt | ( | quint16 | address | ) |
|
protected |
|
protected |
InputRegister * cutehmi::modbus::AbstractDevice::inputRegisterAt | ( | quint16 | address | ) |
|
protected |
|
protected |
int cutehmi::modbus::AbstractDevice::maxReadCoils | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxReadDiscreteInputs | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxReadHoldingRegisters | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxReadInputRegisters | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxRequests | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxWriteCoils | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxWriteDiscreteInputs | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxWriteHoldingRegisters | ( | ) | const |
|
signal |
int cutehmi::modbus::AbstractDevice::maxWriteInputRegisters | ( | ) | const |
|
signal |
|
pure virtualslot |
|
protected |
QJsonObject cutehmi::modbus::AbstractDevice::readFileRecordSubrequest | ( | quint16 | file, |
quint16 | address, | ||
quint16 | amount | ||
) |
Generate read file record subrequest.
Helper function that creates JSON object for readFileRecord() function.
file | file number. |
address | starting address. |
amount | amount of registers to be read. |
bool cutehmi::modbus::AbstractDevice::ready | ( | ) | const |
Get readiness status.
Indicates whether device is ready for handling requests.
true
, otherwise it returns false
.
|
signal |
void cutehmi::modbus::AbstractDevice::request | ( | cutehmi::modbus::AbstractDevice::Function | function, |
QJsonObject | payload, | ||
QUuid * | requestId = nullptr |
||
) |
Modbus function request.
function | Modbus function code. |
payload | request payload. Payload is specific to each function code. Typically it is more convenient to use one of the helper slots (requestXYZ()) rather than prepare raw payload. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
|
signal |
void cutehmi::modbus::AbstractDevice::requestDiagnostics | ( | cutehmi::modbus::AbstractDevice::DiagnosticsSubfunction | subfunction, |
quint16 | data, | ||
QUuid * | requestId = nullptr |
||
) |
Diagonistics request.
Convenient function that prepares payload and calls request() with FUNCTION_DIAGNOSTICS function code.
subfunction | diagnostics function. |
data | data to be passed to diagnostics function. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestFetchCommEventCounter | ( | QUuid * | requestId = nullptr | ) |
Report slave id request.
Convenient function that calls request() with FUNCTION_FETCH_COMM_EVENT_COUNTER function code.
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestFetchCommEventLog | ( | QUuid * | requestId = nullptr | ) |
Report slave id request.
Convenient function that calls request() with FUNCTION_FETCH_COMM_EVENT_COUNTER function code.
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestMaskWriteHoldingRegister | ( | quint16 | address, |
quint16 | andMask, | ||
quint16 | orMask, | ||
QUuid * | requestId = nullptr |
||
) |
Mask write holding register request.
Convenient function that prepares payload and calls request() with FUNCTION_MASK_WRITE_HOLDING_REGISTER function code. As a result a holding register is modified according to the following formula: holdingRegister[address] = (holdingRegister[address] AND andMask) OR ( orMask AND ! andMask).
address | address of the holding register to mask. |
andMask | mask to be used as AND mask. |
orMask | mask to be used as OR mask. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadCoils | ( | quint16 | address, |
quint16 | amount = 1 , |
||
QUuid * | requestId = nullptr |
||
) |
Read coils request.
Convenient function that prepares request payload and calls request() with FUNCTION_READ_COILS function code.
address | starting address. |
amount | number of coils to query. Note that Modbus specification expects it to be 16 bit unsigned value, so 65535 is maximal number of coils that can be queried at once (Modbus address range 0-65535 contains 65536 addresses). Modbus message size imposes further restriction - see query limits. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadDiscreteInputs | ( | quint16 | address, |
quint16 | amount = 1 , |
||
QUuid * | requestId = nullptr |
||
) |
Read discrete inputs request.
Convenient function that prepares request payload and calls request() with FUNCTION_READ_DISCRETE_INPUTS function code.
address | starting address. |
amount | number of inputs to query. Note that Modbus specification expects it to be 16 bit unsigned value, so 65535 is maximal number of inputs that can be queried at once (Modbus address range 0-65535 contains 65536 addresses). Modbus message size imposes further restriction - see query limits. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadExceptionStatus | ( | QUuid * | requestId = nullptr | ) |
Report slave id request.
Convenient function that calls request() with FUNCTION_READ_EXCEPTION_STATUS function code.
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadFIFOQueue | ( | quint16 | address, |
QUuid * | requestId = nullptr |
||
) |
Read FIFO queue request.
Convenient function that prepares payload and calls request() with FUNCTION_READ_FIFO_QUEUE function code.
address | starting address to be read from FIFO queue. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadFileRecord | ( | QJsonArray | subrequests, |
QUuid * | requestId = nullptr |
||
) |
Read file record request.
Convenient function that prepares payload and calls request() with FUNCTION_READ_FILE_RECORD function code.
subrequests | array of subrequests. Each array element should be a JSON object, which can be created with readFileRecordSubrequest() function. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadHoldingRegisters | ( | quint16 | address, |
quint16 | amount = 1 , |
||
QUuid * | requestId = nullptr |
||
) |
Read holding registers request.
Convenient function that prepares request payload and calls request() with FUNCTION_READ_HOLDING_REGISTERS function code.
address | starting address. |
amount | number of registers to query. Note that Modbus specification expects it to be 16 bit unsigned value, so 65535 is maximal number of registers that can be queried at once (Modbus address range 0-65535 contains 65536 addresses). Modbus message size imposes further restriction - see query limits. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadInputRegisters | ( | quint16 | address, |
quint16 | amount = 1 , |
||
QUuid * | requestId = nullptr |
||
) |
Read input registers request.
Convenient function that prepares request payload and calls request() with FUNCTION_READ_INPUT_REGISTERS function code.
address | starting address. |
amount | number of registers to query. Note that Modbus specification expects it to be 16 bit unsigned value, so 65535 is maximal number of registers that can be queried at once (Modbus address range 0-65535 contains 65536 addresses). Modbus message size imposes further restriction - see query limits. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReadWriteMultipleHoldingRegisters | ( | quint16 | readAddress, |
quint16 | amount, | ||
quint16 | writeAddress, | ||
QJsonArray | values, | ||
QUuid * | requestId = nullptr |
||
) |
Read/write multiple holding registers request.
Convenient function that prepares payload and calls request() with FUNCTION_READ_WRITE_MULTIPLE_HOLDING_REGISTERS function code.
readAddress | starting address of registers to be read from. |
amount | amount of registers to be read. |
writeAddress | starting address of registers to be written to. |
values | values to be written. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestReportSlaveId | ( | QUuid * | requestId = nullptr | ) |
Report slave id request.
Convenient function that calls request() with FUNCTION_REPORT_SLAVE_ID function code.
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteCoil | ( | quint16 | address, |
bool | value, | ||
QUuid * | requestId = nullptr |
||
) |
Write coils request.
Convenient function that prepares request payload and calls request(FUNCTION_WRITE_COIL, payload).
address | address of the coil. |
value | value to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteDiscreteInput | ( | quint16 | address, |
bool | value, | ||
QUuid * | requestId = nullptr |
||
) |
Write discrete input request.
Convenient function that prepares request payload and calls request() with FUNCTION_WRITE_DISCRETE_INPUT function code.
address | address of the discrete input. |
value | value to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteFileRecord | ( | QJsonArray | subrequests, |
QUuid * | requestId = nullptr |
||
) |
Write file record request.
Convenient function that prepares payload and calls request() with FUNCTION_WRITE_FILE_RECORD function code.
subrequests | array of subrequests. Each array element should be a JSON object, which can be created with writeFileRecordSubrequest() function. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteHoldingRegister | ( | quint16 | address, |
quint16 | value, | ||
QUuid * | requestId = nullptr |
||
) |
Write holding register request.
Convenient function that prepares request payload and calls request() with FUNCTION_WRITE_HOLDING_REGISTER function code.
address | address of the coil. |
value | value to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteInputRegister | ( | quint16 | address, |
quint16 | value, | ||
QUuid * | requestId = nullptr |
||
) |
Write input register request.
Convenient function that prepares request payload and calls request(FUNCTION_WRITE_INPUT_REGISTER).
address | address of the input register. |
value | value to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteMultipleCoils | ( | quint16 | address, |
QJsonArray | values, | ||
QUuid * | requestId = nullptr |
||
) |
Write multiple coils request.
Convenient function that prepares request payload and calls request() with FUNCTION_WRITE_MULTIPLE_COILS function code.
address | address of the first coil. |
values | array containing values to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteMultipleDiscreteInputs | ( | quint16 | address, |
QJsonArray | values, | ||
QUuid * | requestId = nullptr |
||
) |
Write multiple discrete inputs request.
Convenient function that prepares request payload and calls request() with FUNCTION_WRITE_MULTIPLE_DISCRETE_INPUTS function code.
address | address of the first discrete input. |
values | array containing values to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteMultipleHoldingRegisters | ( | quint16 | address, |
QJsonArray | values, | ||
QUuid * | requestId = nullptr |
||
) |
Write multiple holding registers request.
Convenient function that prepares request payload and calls request() with FUNCTION_WRITE_MULTIPLE_HOLDING_REGISTERS function code.
address | address of the first holding register. |
values | array containing values to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::requestWriteMultipleInputRegisters | ( | quint16 | address, |
QJsonArray | values, | ||
QUuid * | requestId = nullptr |
||
) |
Write multiple input registers request.
Convenient function that prepares request payload and calls request() with FUNCTION_WRITE_MULTIPLE_INPUT_REGISTERS function code.
address | address of the first input register. |
values | array containing values to be set. |
requestId | request id. If not nullptr , function will set pointee to generated request id before handling the request. |
void cutehmi::modbus::AbstractDevice::setMaxReadCoils | ( | int | maxReadCoils | ) |
void cutehmi::modbus::AbstractDevice::setMaxReadDiscreteInputs | ( | int | maxReadDiscreteInputs | ) |
void cutehmi::modbus::AbstractDevice::setMaxReadHoldingRegisters | ( | int | maxReadHoldingRegisters | ) |
void cutehmi::modbus::AbstractDevice::setMaxReadInputRegisters | ( | int | maxReadInputRegisters | ) |
void cutehmi::modbus::AbstractDevice::setMaxRequests | ( | int | maxRequests | ) |
void cutehmi::modbus::AbstractDevice::setMaxWriteCoils | ( | int | maxWriteCoils | ) |
void cutehmi::modbus::AbstractDevice::setMaxWriteDiscreteInputs | ( | int | maxWriteDiscreteInputs | ) |
void cutehmi::modbus::AbstractDevice::setMaxWriteHoldingRegisters | ( | int | maxWriteHoldingRegisters | ) |
void cutehmi::modbus::AbstractDevice::setMaxWriteInputRegisters | ( | int | maxWriteInputRegisters | ) |
|
protectedslot |
|
protectedslot |
|
protected |
AbstractDevice::State cutehmi::modbus::AbstractDevice::state | ( | ) | const |
|
signal |
|
protected |
|
protected |
QJsonObject cutehmi::modbus::AbstractDevice::writeFileRecordSubrequest | ( | quint16 | file, |
quint16 | address, | ||
QJsonArray | values | ||
) |
Generate write file record subrequest.
Helper function that creates JSON object for writeFileRecord() function.
file | file number. |
address | starting address. |
values | values to be written. |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Maximal amount of coils that can be read at once through RTU.
|
staticconstexpr |
Maximal amount of discrete inputs that can be read at once through RTU.
|
staticconstexpr |
Maximal amount of holding registers that can be read at once through RTU.
|
staticconstexpr |
Maximal amount of input registers that can be read at once through RTU.
|
staticconstexpr |
Maximal amount of coils that can be read at once through TCP.
|
staticconstexpr |
Maximal amount of discrete inputs that can be read at once through TCP.
|
staticconstexpr |
Maximal amount of holding registers that can be read at once through TCP.
|
staticconstexpr |
Maximal amount of input registers that can be read at once through TCP.
|
staticconstexpr |
Maximal amount of coils that can be written at once through RTU.
|
staticconstexpr |
Maximal amount of holding registers that can be written at once through RTU.
|
staticconstexpr |
Maximal amount of coils that can be written at once through TCP.
|
staticconstexpr |
Maximal amount of holding registers that can be written at once through TCP.
|
staticconstexpr |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
read |
|
read |