blob: 1f0e692bf6568f6a634f61471bc8eec37159699f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QMODBUSTCPSERVER_H
#define QMODBUSTCPSERVER_H
#include <QtSerialBus/qmodbuspdu.h>
#include <QtSerialBus/qmodbusserver.h>
QT_BEGIN_NAMESPACE
class QModbusTcpServerPrivate;
class QTcpSocket;
class Q_SERIALBUS_EXPORT QModbusTcpConnectionObserver
{
public:
virtual ~QModbusTcpConnectionObserver();
virtual bool acceptNewConnection(QTcpSocket *newClient) = 0;
};
class Q_SERIALBUS_EXPORT QModbusTcpServer : public QModbusServer
{
Q_OBJECT
Q_DECLARE_PRIVATE(QModbusTcpServer)
public:
explicit QModbusTcpServer(QObject *parent = nullptr);
~QModbusTcpServer();
void installConnectionObserver(QModbusTcpConnectionObserver *observer);
Q_SIGNALS:
void modbusClientDisconnected(QTcpSocket *modbusClient);
protected:
QModbusTcpServer(QModbusTcpServerPrivate &dd, QObject *parent = nullptr);
bool open() override;
void close() override;
QModbusResponse processRequest(const QModbusPdu &request) override;
};
QT_END_NAMESPACE
#endif // QMODBUSTCPSERVER_H
|