diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-02-06 17:47:18 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-02-14 12:29:45 +0100 |
commit | e448b2b4d402c7ef4c8b06d16a8307e5219b115a (patch) | |
tree | b8a3ef412a0516c63b89b22add8e3c000ba4ee98 /examples/serialbus/modbus/server/doc | |
parent | 81c4145f51951dab3a1472a6209f626a8ca4aee2 (diff) |
Modbus Server: update example description
Extend the example description so that it actually highlights the main
features shown in the example.
Also update the example to match the guidelines:
* Do not use Example in the name
* Update screenshot
* add Connectivity category
Task-number: QTBUG-110890
Pick-to: 6.5
Change-Id: I4eb7603630a9b69fff4cf921b5adff6ea4c125cf
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'examples/serialbus/modbus/server/doc')
-rw-r--r-- | examples/serialbus/modbus/server/doc/images/modbusserver.png | bin | 19104 -> 44914 bytes | |||
-rw-r--r-- | examples/serialbus/modbus/server/doc/src/modbusserver.qdoc | 68 |
2 files changed, 62 insertions, 6 deletions
diff --git a/examples/serialbus/modbus/server/doc/images/modbusserver.png b/examples/serialbus/modbus/server/doc/images/modbusserver.png Binary files differindex 1506382..2bd8cea 100644 --- a/examples/serialbus/modbus/server/doc/images/modbusserver.png +++ b/examples/serialbus/modbus/server/doc/images/modbusserver.png diff --git a/examples/serialbus/modbus/server/doc/src/modbusserver.qdoc b/examples/serialbus/modbus/server/doc/src/modbusserver.qdoc index ec27852..102b565 100644 --- a/examples/serialbus/modbus/server/doc/src/modbusserver.qdoc +++ b/examples/serialbus/modbus/server/doc/src/modbusserver.qdoc @@ -1,8 +1,10 @@ -// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example modbus/server - \title Modbus Server example + \title Modbus Server + \ingroup qtserialbus-examples + \meta category Connectivity \brief The example implements a Modbus server application. @@ -10,13 +12,67 @@ adjusts its internal states based on the request and responds with the appropriate reply. - \image ../images/modbusserver.png - - \include examples-run.qdocinc - This example must be used in conjunction with the \l {modbus/client}{Modbus Client example}. This example should be started and put into the listen state before the Modbus client example is started. Subsequent interactions between the two examples use the Modbus protocol. + + Key classes used in this example: + + \list + \li \l QModbusServer + \li \l QModbusDataUnit + \endlist + + \image ../images/modbusserver.png + + \section1 Creating a QModbusServer + + An instance of \l QModbusServer is required to perform any communication. + Depending on the specified connection type, the example can instantiate a + \l QModbusRtuSerialServer (for serial communication) or a + \l QModbusTcpServer (for TCP-based communication). + + \snippet modbus/server/mainwindow.cpp create_server_0 + + Once the server is created, the register map is set using + \l QModbusServer::setMap() method. This register map is used by client + applications to read and write server data. + + \snippet modbus/server/mainwindow.cpp create_server_1 + + After that the communication parameters and the server address are + specified. The communication parameters depend on the communication type: + + \snippet modbus/server/mainwindow.cpp create_server_2 + + After the server is created and all the parameters are specified, use + \l QModbusServer::connectDevice() to connect to Modbus network. + + \section1 Changing Local Values + + The example allows to change values of all supported + \l {QModbusDataUnit::RegisterType}{register types} by using the provided + combo boxes or line edits. Once the value is updated in the UI, the + \l QModbusServer::setData() method is used to update the actual value on + the server: + + \snippet modbus/server/mainwindow.cpp update_data_locally + + \section1 Handling Remote Writes + + The Modbus clients are capable of updating \l {QModbusDataUnit::}{Coils} + and \l {QModbusDataUnit::}{HoldingRegisters} by sending write requests. + Once the value is updated on the server side using such request, a + \l QModbusServer::dataWritten() signal is emitted. + + \snippet modbus/server/mainwindow.cpp connect_data_written + + The Modbus server example connects to this signal, extracts the updated + values and updates the UI accordingly: + + \snippet modbus/server/mainwindow.cpp update_data_from_remote + + \include examples-run.qdocinc */ |