Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2263 kivins 1
//---------------------------------------------------------------------------
2
 
3
#ifndef UdTransferThreadH
4
#define UdTransferThreadH
5
//---------------------------------------------------------------------------
6
#include <Classes.hpp>
7
#include <vector>
8
#include "UdTransferManager.h"
9
 
10
class DeviceSimulatorThread;
11
class IDeviceFactory;
12
 
13
//---------------------------------------------------------------------------
14
class UdTransferThread : public TThread
15
{
16
    typedef struct tagTHREADNAME_INFO
17
    {
18
        DWORD dwType;     // must be 0x1000
19
        LPCSTR szName;    // pointer to name (in user addr space)
20
        DWORD dwThreadID; // thread ID (-1=caller thread)
21
        DWORD dwFlags;    // reserved for future use, must be zero
22
    } THREADNAME_INFO;
23
 
24
public:
25
    __fastcall UdTransferThread( const UdTransferTask & task,
26
                                 UdTransferManager * manager,
27
                                 IDeviceFactory * deviceFactory );
28
 
29
    bool __fastcall IsRunning() { return m_running; }                                 
30
    void __fastcall StopTransfer() { m_running = false; }
31
    void __fastcall GetTransferStatistics( UdTransferStatistics & stats );
32
 
33
protected:
34
    void __fastcall Execute();
35
 
36
private:
37
    void SetName();
38
    bool InitialiseTask();
39
    bool ConnectDeviceSimulators();
40
    void RampTransferBatch();
41
    bool TransferNextBatch();
42
    void CheckDeviceSimulatorThreads();
43
    bool TransferUdFile( const AnsiString & filename );
44
    int  GetBatchSize();
45
 
46
private:
47
    bool    m_running;
48
    bool    m_error;
49
    bool    m_renameSent;
50
    bool    m_ignoreSent;
51
    bool    m_simulators;
52
    int     m_lastDevice;
53
    int     m_maxDevices;
54
    int     m_deviceId;
55
    int     m_connectTimeout;
56
 
57
    AnsiString m_deviceType;
58
 
59
    struct Ramp
60
    {
61
        bool        running;
62
        int         batchSize;
63
        int         count;
64
 
65
    } m_ramp;
66
 
67
    UdTransferManager *     m_manager;
68
    UdTransferTask          m_task;
69
    UdTransferStatistics    m_stats;
70
 
71
    IDeviceFactory *        m_deviceFactory;
72
    std::vector<DeviceSimulatorThread *> m_devices;  
73
};
74
//---------------------------------------------------------------------------
75
#endif