#ifndef USERVERTHREAD_H
#define USERVERTHREAD_H

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

class UServerThread : public QThread
{
    Q_OBJECT
public:
    explicit UServerThread(QObject *parent = 0, QString ip="", quint16 port=0);
    void mkCommCmd(unsigned char *cmd, unsigned char *data, unsigned char cmdCode, int dataLen);
    int mkHeartBeatCmd(unsigned char *cmd);
    int mkDeviceRegistCmd(unsigned char *cmd);
    int chk_protocol(QByteArray rtn, unsigned char *outData);
    bool chk_frame(QByteArray rtn);
    int mkTimeSetRtn(QByteArray rtn, unsigned char *cmd);
    bool set_systime(int year, int mon, int day, int hour, int min, int sec);
    void appendAllRealdata();
    void run();
    
signals:
    
public slots:

private:
    uint CommTime;
    QTcpSocket *so;
    QString ServerIP;
    quint16 ServerPort;
    QList<QByteArray> CmdList;
};

#endif // USERVERTHREAD_H
