CuteHMI - Modbus (CuteHMI.Modbus.4)
AbstractServer.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_ABSTRACTSERVER_HPP
2#define H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_ABSTRACTSERVER_HPP
3
4#include "AbstractDevice.hpp"
5
6#include <QQmlEngine>
7
8namespace cutehmi {
9namespace modbus {
10
17class CUTEHMI_MODBUS_API AbstractServer:
19{
20 Q_OBJECT
21 QML_NAMED_ELEMENT(AbstractServer)
22 QML_UNCREATABLE("AbstractServer is an abstract class")
23
24 public:
25 static constexpr bool INITIAL_BUSY = false;
26
27 Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
28
29 bool busy() const;
30
31 virtual void setBusy(bool busy) = 0;
32
33 void configureStarting(QState * starting, AssignStatusFunction assignStatus) override;
34
35 void configureStarted(QState * active, const QState * idling, const QState * yielding, AssignStatusFunction assignStatus) override;
36
37 void configureStopping(QState * stopping, AssignStatusFunction assignStatus) override;
38
39 void configureBroken(QState * broken, AssignStatusFunction assignStatus) override;
40
41 void configureRepairing(QState * repairing, AssignStatusFunction assignStatus) override;
42
43 void configureEvacuating(QState * evacuating, AssignStatusFunction assignStatus) override;
44
45 std::unique_ptr<QAbstractTransition> transitionToStarted() const override;
46
47 std::unique_ptr<QAbstractTransition> transitionToStopped() const override;
48
49 std::unique_ptr<QAbstractTransition> transitionToBroken() const override;
50
51 std::unique_ptr<QAbstractTransition> transitionToYielding() const override;
52
53 std::unique_ptr<QAbstractTransition> transitionToIdling() const override;
54
55 signals:
57
58 protected:
59 AbstractServer(QObject * parent = nullptr);
60
61 void handleRequest(const QJsonObject & request) override;
62
63 protected slots:
64 virtual void handleCoilsWritten(quint16 address, quint16 amount);
65
66 virtual void handleDiscreteInputsWritten(quint16 address, quint16 amount);
67
68 virtual void handleHoldingRegistersWritten(quint16 address, quint16 amount);
69
70 virtual void handleInputRegistersWritten(quint16 address, quint16 amount);
71
72 void updateBusy(bool busy);
73
74 protected:
75 Q_SIGNAL void requestAccepted(QJsonObject request);
76
77 private:
78 struct Members {
79 bool busy = INITIAL_BUSY;
80 };
81
83};
84
85}
86}
87
88#endif
89
90//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
91//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
92//(c)C: This file is a part of CuteHMI.
93//(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.
94//(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.
95//(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/>.
96//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
97//(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:
98//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
99//(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.
Abstract Modbus device.
Definition: AbstractDevice.hpp:38
Abstract server.
Definition: AbstractServer.hpp:19
virtual void setBusy(bool busy)=0
Q_SIGNAL void requestAccepted(QJsonObject request)