QModbusTcpServer Class
QModbusTcpServer 클래스는 모드버스 클라이언트와의 통신에 TCP 서버를 사용하는 모드버스 서버를 나타냅니다. 더 보기...
헤더: | #include <QModbusTcpServer> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS SerialBus) target_link_libraries(mytarget PRIVATE Qt6::SerialBus) |
qmake: | QT += serialbus |
상속합니다: | QModbusServer |
공용 함수
QModbusTcpServer(QObject *parent = nullptr) | |
virtual | ~QModbusTcpServer() |
void | installConnectionObserver(QModbusTcpConnectionObserver *observer) |
시그널
void | modbusClientDisconnected(QTcpSocket *modbusClient) |
재구현된 보호 함수
virtual void | close() override |
virtual bool | open() override |
virtual QModbusResponse | processRequest(const QModbusPdu &request) override |
상세 설명
모드버스를 통한 통신은 단일 모드버스 클라이언트 인스턴스와 단일 모드버스 서버 간의 상호 작용이 필요합니다. 이 클래스는 TCP 서버를 통한 모드버스 서버 구현을 제공합니다.
모드버스 TCP 네트워크에는 여러 서버가 있을 수 있습니다. 서버는 QModbusTcpClient 로 표현되는 클라이언트 장치에 의해 읽기/쓰기됩니다.
멤버 함수 문서
[explicit]
QModbusTcpServer::QModbusTcpServer(QObject *parent = nullptr)
지정된 parent 로 QModbusTcpServer를 구축합니다. serverAddress 프리셋은 255
입니다.
[virtual noexcept]
QModbusTcpServer::~QModbusTcpServer()
QModbusTcpServer 인스턴스를 삭제합니다.
[override virtual protected]
void QModbusTcpServer::close()
다시 구현합니다: QModbusDevice::close().
void QModbusTcpServer::installConnectionObserver(QModbusTcpConnectionObserver *observer)
새 TCP 클라이언트가 이 서버 인스턴스에 연결할 때 알림을 받는 데 사용할 수 있는 observer 을 설치합니다. 또한 observer 는 들어오는 TCP 연결을 거부하는 데 사용할 수 있습니다.
QModbusTcpServer 는 주어진 observer 의 소유권을 가져옵니다. 이전에 설정된 옵저버는 모두 삭제됩니다. nullptr
를 매개변수로 사용하여 이 함수를 호출하면 옵저버를 제거할 수 있습니다.
QModbusTcpConnectionObserver도 참조하세요 .
[signal]
void QModbusTcpServer::modbusClientDisconnected(QTcpSocket *modbusClient)
이 신호는 현재 TCP 기반 modbusClient 이 모드버스 TCP 서버에서 연결이 끊어질 때 발생합니다. 동시에 여러 개의 TCP 클라이언트가 연결되어 있을 수 있습니다.
들어오는 새 연결에 대한 알림은 installConnectionObserver()을 통해 QModbusTcpConnectionObserver 을 설치하여 수신할 수 있습니다.
installConnectionObserver 를참조하세요 .
[override virtual protected]
bool QModbusTcpServer::open()
다시 구현합니다: QModbusDevice::open().
[override virtual protected]
QModbusResponse QModbusTcpServer::processRequest(const QModbusPdu &request)
재구현합니다: QModbusServer::processRequest(const QModbusPdu &request).
request 에 지정된 모드버스 클라이언트 요청을 처리하고 모드버스 응답을 반환합니다.
다음 모드버스 기능 코드는 모드버스 응용 프로토콜 사양 1.1b에 따라 직렬 라인 전용이므로 필터링됩니다:
- QModbusRequest::ReadExceptionStatus
- QModbusRequest::Diagnostics
- QModbusRequest::GetCommEventCounter
- QModbusRequest::GetCommEventLog
- QModbusRequest::ReportServerId
TCP 서버에 대한 요청은 예외 코드 QModbusExceptionResponse::IllegalFunction이 포함된 모드버스 예외 응답으로 응답됩니다.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.