CuteHMI - Modbus (CuteHMI.Modbus.2)
DummyClientBackend.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DUMMYCLIENTBACKEND_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DUMMYCLIENTBACKEND_HPP
3 
4 #include "common.hpp"
5 #include "AbstractClientBackend.hpp"
6 #include "DummyClientConfig.hpp"
7 
8 namespace cutehmi {
9 namespace modbus {
10 namespace internal {
11 
12 class CUTEHMI_MODBUS_PRIVATE DummyClientBackend:
14 {
15  Q_OBJECT
16 
17  public:
18  DummyClientBackend(DummyClientConfig * config, QObject * parent = nullptr);
19 
20  ~DummyClientBackend() override;
21 
22  public slots:
23  void ensureClosed();
24 
25  signals:
26  void opened();
27 
28  void closed();
29 
30  protected:
31  bool proceedRequest(QUuid requestId) override;
32 
33  void readCoils(QUuid requestId, quint16 startAddress, quint16 endAddress) override;
34 
35  void writeCoil(QUuid requestId, quint16 address, bool value) override;
36 
37  void writeMultipleCoils(QUuid requestId, quint16 startAddress, const QVector<quint16> & values) override;
38 
39  void readDiscreteInputs(QUuid requestId, quint16 startAddress, quint16 endAddress) override;
40 
41  void readHoldingRegisters(QUuid requestId, quint16 startAddress, quint16 endAddress) override;
42 
43  void writeHoldingRegister(QUuid requestId, quint16 address, quint16 value) override;
44 
45  void writeMultipleHoldingRegisters(QUuid requestId, quint16 startAddress, const QVector<quint16> & values) override;
46 
47  void readInputRegisters(QUuid requestId, quint16 startAddress, quint16 endAddress) override;
48 
49  protected slots:
50  void open() override;
51 
52  void close() override;
53 
54  private:
55  void setState(AbstractClient::State state);
56 
57  private:
58  typedef typename internal::RegisterTraits<InputRegister>::Container InputRegisterContainer;
59  typedef typename internal::RegisterTraits<HoldingRegister>::Container HolidingRegisterContainer;
60  typedef typename internal::RegisterTraits<DiscreteInput>::Container DiscreteInputContainer;
61  typedef typename internal::RegisterTraits<Coil>::Container CoilContainer;
62 
63  struct Members
64  {
65  DummyClientConfig * config;
67  InputRegisterContainer inputRegisters;
68  HolidingRegisterContainer holdingRegisters;
69  DiscreteInputContainer discreteInputs;
70  CoilContainer coils;
71  };
72 
73  MPtr<Members> m;
74 };
75 
76 }
77 }
78 }
79 
80 #endif
81 
82 //(c)C: Copyright © 2019, Michał Policht <michal@policht.pl>. All rights reserved.
83 //(c)C: This file is a part of CuteHMI.
84 //(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.
85 //(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.
86 //(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::AbstractClientBackend
Abstract client backend.
Definition: AbstractClientBackend.hpp:23
QUuid
cutehmi::modbus::internal::RegisterTraits
Definition: RegisterTraits.hpp:15
cutehmi::MPtr< Members >
QObject
cutehmi::modbus::internal::DummyClientBackend
Definition: DummyClientBackend.hpp:12
cutehmi
cutehmi::modbus::internal::DummyClientConfig
Definition: DummyClientConfig.hpp:13
cutehmi::modbus::AbstractDevice::State
State
Definition: AbstractDevice.hpp:44
std::internal
T internal(T... args)
QVector