CuteHMI - Modbus (CuteHMI.Modbus.2)
QtRTUServer.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_QTRTUSERVER_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_QTRTUSERVER_HPP
3 
4 #include "common.hpp"
5 #include "RegisterTraits.hpp"
6 #include "QtServerMixin.hpp"
7 
8 #include <QModbusRtuSerialSlave>
9 
10 namespace cutehmi {
11 namespace modbus {
12 namespace internal {
13 
17 class CUTEHMI_MODBUS_PRIVATE QtRTUServer:
18  public QModbusRtuSerialSlave,
19  protected QtServerMixin<QtRTUServer>
20 {
21  Q_OBJECT
22 
23  friend class QtServerMixin<QtRTUServer>;
25 
26  public:
31 
32  QtRTUServer(CoilDataContainer * coilData,
33  DiscreteInputDataContainer * discreteInputData,
34  HoldingRegisterDataContainer * holdingRegisterData,
35  InputRegisterDataContainer * inputRegisterData,
36  QObject * parent = nullptr);
37 
38  bool setMap(const QModbusDataUnitMap & map) override;
39 
40  protected:
41  bool readData(QModbusDataUnit * newData) const override;
42 
43  bool writeData(const QModbusDataUnit & newData) override;
44 
45  private:
46  struct Members {
47  CoilDataContainer * coilData;
48  DiscreteInputDataContainer * discreteInputData;
49  HoldingRegisterDataContainer * holdingRegisterData;
50  InputRegisterDataContainer * inputRegisterData;
51  };
52 
53  MPtr<Members> m;
54 };
55 
56 }
57 }
58 }
59 
60 #endif
61 
62 //(c)C: Copyright © 2019, Michał Policht <michal@policht.pl>. All rights reserved.
63 //(c)C: This file is a part of CuteHMI.
64 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
65 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
66 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
cutehmi::modbus::internal::QtRTUServer::DiscreteInputDataContainer
RegisterTraits< DiscreteInput >::Container DiscreteInputDataContainer
Definition: QtRTUServer.hpp:28
cutehmi::modbus::internal::QtRTUServer::CoilDataContainer
RegisterTraits< Coil >::Container CoilDataContainer
Definition: QtRTUServer.hpp:27
QModbusRtuSerialSlave
cutehmi::modbus::internal::RegisterTraits
Definition: RegisterTraits.hpp:15
cutehmi::modbus::internal::QtRTUServer
Qt SerialBus based TCP server.
Definition: QtRTUServer.hpp:17
cutehmi::modbus::internal::QtServerMixin
Definition: QtServerMixin.hpp:15
cutehmi::modbus::internal::QtRTUServer::HoldingRegisterDataContainer
RegisterTraits< HoldingRegister >::Container HoldingRegisterDataContainer
Definition: QtRTUServer.hpp:29
cutehmi::MPtr< Members >
QObject
cutehmi
QModbusDataUnit
std::internal
T internal(T... args)
cutehmi::modbus::internal::QtRTUServer::InputRegisterDataContainer
RegisterTraits< InputRegister >::Container InputRegisterDataContainer
Definition: QtRTUServer.hpp:30