60 lines
1.4 KiB
C++
Executable File
60 lines
1.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* One connection to a bsm
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2017-01-18
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QHostAddress>
|
|
#include <QTcpSocket>
|
|
#include <logger.h>
|
|
#include "bsm_types.h"
|
|
|
|
class QTimer;
|
|
namespace BuildingControlUnit
|
|
{
|
|
namespace BSM
|
|
{
|
|
class Socket : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit Socket(const BuildingControlUnit::Bsm &cfg, QObject *parent = nullptr);
|
|
|
|
bool isConnected() const;
|
|
bool sendData(const QByteArray &data);
|
|
const BuildingControlUnit::Bsm &bsmConfig() const { return m_config; }
|
|
|
|
QString versionInfo() const { return m_versionInfo; }
|
|
void setVersionInformation(int verMajor, int verMinor, int verRev, const QString &manufacturer);
|
|
void gotAlive();
|
|
QHostAddress peerAddress() const { return m_tcpSocket->peerAddress(); }
|
|
Q_SIGNALS:
|
|
void dataAvailable(int id, const QByteArray &data);
|
|
void connected(int id);
|
|
void disconnected(int id);
|
|
private Q_SLOTS:
|
|
void onConnected();
|
|
void onDisconnected();
|
|
void onError(QAbstractSocket::SocketError error);
|
|
void onConnect();
|
|
void onReadyRead();
|
|
void onAliveTimeout();
|
|
private:
|
|
void startReconnectTimer();
|
|
private:
|
|
BuildingControlUnit::Bsm m_config;
|
|
QTcpSocket *m_tcpSocket;
|
|
QTimer *m_reconnectTimer;
|
|
QTimer *m_aliveTimer;
|
|
QString m_versionInfo;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
} // namespace BSM
|
|
} // namespace BuildingControlUnit
|