Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2263 kivins 1
//---------------------------------------------------------------------------
2
 
3
#ifndef DeviceSimulatorThreadH
4
#define DeviceSimulatorThreadH
5
//---------------------------------------------------------------------------
6
#include <Classes.hpp>
7
 
8
#define DEVSIM_OBSERVER 1 
9
#include "IDevice.h"
10
 
11
#include <vector>
12
 
13
class IDeviceFactory;
14
 
15
//---------------------------------------------------------------------------
16
class DeviceSimulatorThread : public TThread, public IDeviceListener
17
{
18
  typedef struct tagTHREADNAME_INFO
19
  {
20
    DWORD dwType;     // must be 0x1000
21
    LPCSTR szName;    // pointer to name (in user addr space)
22
    DWORD dwThreadID; // thread ID (-1=caller thread)
23
    DWORD dwFlags;    // reserved for future use, must be zero
24
  } THREADNAME_INFO;
25
private:
26
    void SetName();
27
    void Reconnect();
28
    bool TransferUdFiles();
29
 
30
protected:
31
    void __fastcall Execute();
32
public:
33
    __fastcall DeviceSimulatorThread( IDevice * device,
34
                                      IDeviceFactory * factory,
35
                                      const AnsiString & hostname );
36
 
37
    void __fastcall UploadUDFile( const AnsiString & filename );
38
 
39
    const bool __fastcall IsRunning() { return m_running; }
40
 
41
    const bool __fastcall IsConnected() { return (IsRunning() && m_device->isConnected()); }
42
 
43
    void __fastcall Stop();
44
 
45
    const AnsiString __fastcall GetErrorMessage() { return m_error; }
46
 
47
    // IDeviceListener interface
48
 
49
    virtual void DS_STDCALL onEvent( const unsigned short type,
50
                                     const char * msg,
51
                                     const unsigned char status );
52
 
53
    virtual void DS_STDCALL detach();
54
 
55
private:
56
    IDevice *           m_device;
57
    IDeviceFactory *    m_factory;
58
    AnsiString          m_address;
59
 
60
    bool                m_running;
61
    AnsiString          m_error;
62
 
63
    HANDLE              m_semaphore;
64
    std::vector< AnsiString > m_udFiles;
65
 
66
};
67
//---------------------------------------------------------------------------
68
#endif