CuteHMI - Modbus (CuteHMI.Modbus.2)
DummyClient.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_DUMMYCLIENT_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_DUMMYCLIENT_HPP
3 
4 #include "internal/common.hpp"
5 #include "internal/DummyClientConfig.hpp"
6 #include "internal/DummyClientBackend.hpp"
7 #include "internal/PollingIterator.hpp"
8 #include "AbstractClient.hpp"
9 
10 #include <cutehmi/services/PollingTimer.hpp>
11 
12 #include <QThread>
13 
14 #include <vector>
15 
16 namespace cutehmi {
17 namespace modbus {
18 
25 class CUTEHMI_MODBUS_API DummyClient:
26  public AbstractClient
27 {
28  Q_OBJECT
29 
30  public:
31  static constexpr int INITIAL_OPEN_LATENCY = internal::DummyClientConfig::INITIAL_OPEN_LATENCY;
32  static constexpr int INITIAL_CLOSE_LATENCY = internal::DummyClientConfig::INITIAL_CLOSE_LATENCY;
33  static constexpr int INITIAL_LATENCY = internal::DummyClientConfig::INITIAL_LATENCY;
34 
35  Q_PROPERTY(int connectLatency READ connectLatency WRITE setConnectLatency NOTIFY connectLatencyChanged)
36  Q_PROPERTY(int disconnectLatency READ disconnectLatency WRITE setDisconnectLatency NOTIFY disconnectLatencyChanged)
37  Q_PROPERTY(int latency READ latency WRITE setLatency NOTIFY latencyChanged)
38 
39  DummyClient(QObject * parent = nullptr);
40 
41  ~DummyClient() override;
42 
43  int connectLatency() const;
44 
45  void setConnectLatency(int connectLatency);
46 
47  int disconnectLatency() const;
48 
49  void setDisconnectLatency(int disconnectLatency);
50 
51  int latency() const;
52 
53  void setLatency(int latency);
54 
55  public slots:
56  void open() override;
57 
58  void close() override;
59 
60  signals:
61  void connectLatencyChanged();
62 
63  void disconnectLatencyChanged();
64 
65  void latencyChanged();
66 
67  private:
68  struct Members {
71  QThread thread;
72 
73  Members():
74  backend(& config)
75  {
76  }
77  };
78 
79  MPtr<Members> m;
80 };
81 
82 }
83 }
84 
85 #endif
86 
87 //(c)C: Copyright © 2019-2020, Michał Policht <michal@policht.pl>. All rights reserved.
88 //(c)C: This file is a part of CuteHMI.
89 //(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.
90 //(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.
91 //(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::DummyClientConfig::INITIAL_LATENCY
static constexpr int INITIAL_LATENCY
Definition: DummyClientConfig.hpp:21
cutehmi::modbus::internal::DummyClientConfig::INITIAL_CLOSE_LATENCY
static constexpr int INITIAL_CLOSE_LATENCY
Definition: DummyClientConfig.hpp:20
QThread
cutehmi::modbus::internal::DummyClientConfig::INITIAL_OPEN_LATENCY
static constexpr int INITIAL_OPEN_LATENCY
Definition: DummyClientConfig.hpp:19
cutehmi::MPtr< Members >
QObject
cutehmi::modbus::internal::DummyClientBackend
Definition: DummyClientBackend.hpp:12
cutehmi
cutehmi::modbus::AbstractClient
Abstract client.
Definition: AbstractClient.hpp:18
cutehmi::modbus::internal::DummyClientConfig
Definition: DummyClientConfig.hpp:13
cutehmi::modbus::DummyClient
Dummy client.
Definition: DummyClient.hpp:25