Barst  2.0
A server that controls lab hardware.
serial device.h
1 
4 #ifndef CPL_SERIAL_DEVICE_H
5 #define CPL_SERIAL_DEVICE_H
6 
7 #include "base classses.h"
8 #include "cpl queue.h"
9 #include "misc tools.h"
10 
11 
12 class CChannelSerial;
13 
15 #define SERIAL_MAN_STR _T("SerMan")
16 class CManagerSerial : public CManager
17 {
18 public:
19  CManagerSerial(CComm* pcComm, const TCHAR szPipe[], int nChan, int &nError);
20  virtual ~CManagerSerial();
21  void ProcessData(const void *pHead, DWORD dwSize, __int64 llId);
22  void Result(void *pHead, bool bPass) {if (m_pcMemPool) m_pcMemPool->PoolRelease(pHead);}
23  virtual DWORD GetInfo(void* pHead, DWORD dwSize);
24 
25 private:
26  std::vector<CChannelSerial*> m_acSerialDevices; // list of all the RTV channels acive, could be NULL
27  HMODULE m_hLib;
28 };
29 
30 
31 typedef struct SSerialPacket
32 {
33  __int64 llId;
34  SBase* psSerialData;
36 
38 #define SERIAL_CHAN_STR _T("SerChan")
39 class CChannelSerial : public CDevice
40 {
41 public:
50  CChannelSerial(const TCHAR szPipe[], int nChan, SChanInitSerial &sChanInit, int &nError,
51  LARGE_INTEGER &llStart);
52  virtual ~CChannelSerial();
53  void ProcessData(const void *pHead, DWORD dwSize, __int64 llId);
54  void Result(void *pHead, bool bPass) {if (m_pcMemPool) m_pcMemPool->PoolRelease(pHead);}
55  DWORD GetInfo(void* pHead, DWORD dwSize);
56 
57  DWORD ThreadProc(); // thread that reads/writes to physical device
58 
59  const SChanInitSerial m_sChanInit; // channel initialization info
60  const std::tstring m_csPipeName; // channels pipe name
61  const unsigned short m_usChan; // channel/RTV channel for this instance
62 private:
63  CTimer m_cTimer; // timer of this channel
64  HANDLE m_hPort; //
65  HANDLE m_hStopEvent;
66  HANDLE m_hWriteEvent;
67  HANDLE m_hReadEvent;
68  OVERLAPPED m_sWOverlapped;
69  OVERLAPPED m_sROverlapped;
70  char* m_acReadBuffer;
71  COMMTIMEOUTS m_sTimeouts;
72  COMSTAT m_sComStat;
73  CQueue<SSerialPacket*> m_asWPackets;
74  CQueue<SSerialPacket*> m_asRPackets;
75 
76  HANDLE m_hThread;
77 };
78 #endif
virtual DWORD GetInfo(void *pHead, DWORD dwSize)
void Result(void *pHead, bool bPass)
Definition: serial device.h:54
void Result(void *pHead, bool bPass)
Definition: serial device.h:22
void ProcessData(const void *pHead, DWORD dwSize, __int64 llId)