Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

//---------------------------------------------------------------------------

#ifndef UdTransferThreadH
#define UdTransferThreadH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <vector>
#include "UdTransferManager.h"

class DeviceSimulatorThread;
class IDeviceFactory;

//---------------------------------------------------------------------------
class UdTransferThread : public TThread
{
    typedef struct tagTHREADNAME_INFO
    {
        DWORD dwType;     // must be 0x1000
        LPCSTR szName;    // pointer to name (in user addr space)
        DWORD dwThreadID; // thread ID (-1=caller thread)
        DWORD dwFlags;    // reserved for future use, must be zero
    } THREADNAME_INFO;

public:
    __fastcall UdTransferThread( const UdTransferTask & task,
                                 UdTransferManager * manager,
                                 IDeviceFactory * deviceFactory );

    bool __fastcall IsRunning() { return m_running; }                                 
    void __fastcall StopTransfer() { m_running = false; }
    void __fastcall GetTransferStatistics( UdTransferStatistics & stats );

protected:
    void __fastcall Execute();

private:
    void SetName();
    bool InitialiseTask();
    bool ConnectDeviceSimulators();
    void RampTransferBatch();
    bool TransferNextBatch();
    void CheckDeviceSimulatorThreads();
    bool TransferUdFile( const AnsiString & filename );
    int  GetBatchSize();

private:
    bool    m_running;
    bool    m_error;
    bool    m_renameSent;
    bool    m_ignoreSent;
    bool    m_simulators;
    int     m_lastDevice;
    int     m_maxDevices;
    int     m_deviceId;
    int     m_connectTimeout;

    AnsiString m_deviceType;

    struct Ramp
    {
        bool        running;
        int         batchSize;
        int         count;

    } m_ramp;

    UdTransferManager *     m_manager;
    UdTransferTask          m_task;
    UdTransferStatistics    m_stats;

    IDeviceFactory *        m_deviceFactory;
    std::vector<DeviceSimulatorThread *> m_devices;  
};
//---------------------------------------------------------------------------
#endif