CuteHMI - Modbus (CuteHMI.Modbus.2)
AbstractClient.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_ABSTRACTCLIENT_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_ABSTRACTCLIENT_HPP
3 
4 #include "AbstractDevice.hpp"
5 
6 #include "internal/PollingIterator.hpp"
7 
8 #include <cutehmi/services/PollingTimer.hpp>
9 
10 namespace cutehmi {
11 namespace modbus {
12 
18 class CUTEHMI_MODBUS_API AbstractClient:
19  public AbstractDevice
20 {
21  Q_OBJECT
22 
23  public:
24  Q_PROPERTY(cutehmi::services::PollingTimer * pollingTimer READ pollingTimer CONSTANT)
25 
26  const services::PollingTimer * pollingTimer() const;
27 
28  services::PollingTimer * pollingTimer();
29 
30  std::unique_ptr<ServiceStatuses> configureStarting(QState * starting) override;
31 
32  std::unique_ptr<ServiceStatuses> configureStarted(QState * active, const QState * idling, const QState * yielding) override;
33 
34  std::unique_ptr<ServiceStatuses> configureStopping(QState * stopping) override;
35 
36  std::unique_ptr<ServiceStatuses> configureBroken(QState * broken) override;
37 
38  std::unique_ptr<ServiceStatuses> configureRepairing(QState * repairing) override;
39 
40  std::unique_ptr<ServiceStatuses> configureEvacuating(QState * evacuating) override;
41 
42  std::unique_ptr<QAbstractTransition> transitionToStarted() const override;
43 
44  std::unique_ptr<QAbstractTransition> transitionToStopped() const override;
45 
46  std::unique_ptr<QAbstractTransition> transitionToBroken() const override;
47 
48  std::unique_ptr<QAbstractTransition> transitionToYielding() const override;
49 
50  std::unique_ptr<QAbstractTransition> transitionToIdling() const override;
51 
52  protected:
53  AbstractClient(QObject * parent = nullptr);
54 
55  void handleRequest(const QJsonObject & request) override;
56 
57  void handleReply(QUuid requestId, QJsonObject reply) override;
58 
59  protected slots:
60  virtual void onStateChanged();
61 
62  void poll();
63 
64  void pollingTask();
65 
66  CUTEHMI_PROTECTED_SIGNALS:
67  void requestReceived(QJsonObject request);
68 
69  void pollingFinished();
70 
71  void pollingTaskFinished();
72 
73  private:
74  struct Members {
75  internal::PollingIterator pollingIterator;
76  services::PollingTimer pollingTimer;
77 
78  Members(AbstractDevice * device):
79  pollingIterator(device)
80  {
81  }
82  };
83 
84  MPtr<Members> m;
85 };
86 
87 }
88 }
89 
90 #endif
91 
92 //(c)C: Copyright © 2019-2020, Michał Policht <michal@policht.pl>. All rights reserved.
93 //(c)C: This file is a part of CuteHMI.
94 //(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.
95 //(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.
96 //(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::PollingIterator
Definition: PollingIterator.hpp:16
QState
QUuid
cutehmi::modbus::AbstractDevice
Abstract Modbus device.
Definition: AbstractDevice.hpp:33
cutehmi::MPtr< Members >
QObject
cutehmi
cutehmi::modbus::AbstractClient
Abstract client.
Definition: AbstractClient.hpp:18
QJsonObject
cutehmi::services::PollingTimer
std::unique_ptr