Files
qt5-legatus-legacy/Lts/Proxies/TrainingAreaBaseOC/connection_handler_tcp.h
T
2026-08-13 18:33:10 +02:00

54 lines
929 B
C++
Executable File

/**
* Connection Handler for the serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#pragma once
#include <QObject>
#include <QTcpSocket>
#include <LtsUtilsCore/sfm_bytemessage_converter.h>
#include "logger.h"
class QTimer;
namespace TrainingAreaBaseOC
{
class ConnectionHandlerTcp : public QObject
{
Q_OBJECT
public:
explicit ConnectionHandlerTcp();
~ConnectionHandlerTcp();
bool init();
bool send(const LtsUtils::SfmMessage &message);
bool open();
void close();
bool isOpen() const;
signals:
void received(const LtsUtils::SfmMessage &message);
void disconnectedFromEq();
private slots:
void read();
void handleError(QAbstractSocket::SocketError error);
private:
QTcpSocket *m_socket = nullptr;
QTimer *m_timer = nullptr;
QByteArray m_currentDataRead;
LOGGER_T m_logger;
};
} // namespace TrainingAreaBaseOC