#ifndef DMPCOMMTHREAD_H
#define DMPCOMMTHREAD_H

#include <QThread>
#include <QTcpSocket>
#include <QString>
#include <QDateTime>
#include <QHostAddress>

class DMPCommThread : public QThread
{
    Q_OBJECT
public:
    explicit DMPCommThread(qintptr socketDescriptor,QObject *parent = nullptr);
    ~DMPCommThread() override;
    void run() override;
    void close_self(QTcpSocket *so);
    void stop();
    void readData(QTcpSocket *so);
    int getserviceidx(QString sn);
    quint16 chk_crcc(QByteArray buff, quint16 len);
    QByteArray mk_rtn(quint8 type, quint16 sn);
    QByteArray mk_rtn(quint8 type);
    QByteArray mk_heartbeat_rtn();
    QByteArray mk_login_rtn();
    QByteArray mk_settime();

signals:
    void CommData(QString data);
    void DatabaseData(QString sql);
    void getERealtimeValue(QString DeviceCode, QString bstr, QString pointstr, QDateTime t);

public slots:

private:
    qintptr SocketDescriptor;
    bool keepcomm;
    QString DeviceID;
    QString IEMI,IMSI;

};

#endif // DMPCOMMTHREAD_H
