CuteHMI - Modbus (CuteHMI.Modbus.4)
DummyClientBackend.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DUMMYCLIENTBACKEND_HPP
2#define H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DUMMYCLIENTBACKEND_HPP
3
4#include "common.hpp"
5#include "AbstractClientBackend.hpp"
6#include "DummyClientConfig.hpp"
7
8namespace cutehmi {
9namespace modbus {
10namespace internal {
11
12class 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
74};
75
76}
77}
78}
79
80#endif
81
82//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
83//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
84//(c)C: This file is a part of CuteHMI.
85//(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.
86//(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.
87//(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/>.
88//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
89//(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
90//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
91//(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
State
Definition: AbstractDevice.hpp:48
Abstract client backend.
Definition: AbstractClientBackend.hpp:25
Definition: DummyClientBackend.hpp:14
Definition: DummyClientConfig.hpp:15
T internal(T... args)
Definition: RegisterTraits.hpp:16