#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H

#include <GlobalDefine.h>
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <TCPProtocol.h>
#include <QFileInfoList>

class CZoneTest;

class CNetworkManager : public QObject, public CTCPProtocol
{
    Q_OBJECT
public:
    static CNetworkManager* instance(){return &mSingleton;}
    static  CNetworkManager mSingleton;

    explicit CNetworkManager(QObject *parent = 0);
    ~CNetworkManager();

    void BindPointers(CZoneTest *ProgramHandle);
    unsigned int StartServer();

    virtual void TCPTxRequest(QByteArray request);
    virtual void TCPHeartbeatRequest();
    virtual void TCPStationNameRequest();
    virtual void TCPStatusRequest();
    virtual void TCPZTLogDownloadRequest();
    virtual void TCPTrainLogsDownloadRequest();
    virtual void TCPTrainLogFileDataAck(eTCPProtocolAcknowledge Acknowledge);
    virtual void TCPDeleteZTLogRequest();
    virtual void TCPSetZTFunctionsConfigRequest(QByteArray &Data);

private:
    QTcpServer mTCPServer;
    QTcpSocket *mTCPSocket;
    CZoneTest *mProgramHandle;

    QFileInfoList mTrainLogsFileInfoList;
    int mCurTrainLogsListIndex;

signals:


public slots:

    void NewTCPConnection();
    void TCPDataReady();
    void TCPSockedDisconnected();
};

#endif // NETWORKMANAGER_H
