Barst  2.0
A server that controls lab hardware.
mcdaq_device.h
1 
4 #ifndef _CPL_MCDAQ_DEVICE_H_
5 #define _CPL_MCDAQ_DEVICE_H_
6 
7 #include "base classses.h"
8 #include "cpl queue.h"
9 #include "misc tools.h"
10 
11 
12 class CChannelMCDAQ;
13 
15 #define MCDAQ_MAN_STR _T("DAQMan")
16 class CManagerMCDAQ : public CManager
17 {
18 public:
19  CManagerMCDAQ(CComm* pcComm, const TCHAR szPipe[], int nChan, int &nError);
20  virtual ~CManagerMCDAQ();
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  const unsigned short m_usChans; // number of daq ports availible for use.
25 private:
26  std::vector<CChannelMCDAQ*> m_acDAQDevices; // list of all the daq channels acive, could be NULL
27 };
28 
29 
30 typedef struct SMCDAQPacket
31 {
32  __int64 llId; // the pipe that gets the response
33  SMCDAQWData* psData;
34 } SMCDAQPacket;
35 
36 
38 #define MCDAQ_CHAN_STR _T("DAQChan")
39 class CChannelMCDAQ : public CDevice
40 {
41 public:
50  CChannelMCDAQ(const TCHAR szPipe[], int nChan, SChanInitMCDAQ &sChanInit, int &nError,
51  LARGE_INTEGER &llStart);
52  virtual ~CChannelMCDAQ();
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 SChanInitMCDAQ m_sChanInit; // channel initialization info
60  const std::tstring m_csPipeName; // channels pipe name
61  const unsigned short m_usChan; // channel/MCDAQ channel for this instance
62 private:
63  CTimer m_cTimer; // timer of this channel
64  unsigned short m_usLastWrite; // the last word written
65 
66  HANDLE m_hStopEvent; // signals stop
67  HANDLE m_hWriteEvent; // signals a new write ready
68  HANDLE m_hReadEvent; // signals a read request
69  CQueue<SMCDAQPacket*> m_asWPackets; // holds the requested write packets
70  std::vector<long long> m_allReads; // holds the pipes that requested reads
71  CRITICAL_SECTION m_hReadSafe; // protects access to m_allReads
72 
73  HANDLE m_hThread; // handle to thread
74 };
75 #endif
void Result(void *pHead, bool bPass)
Definition: mcdaq_device.h:22
void Result(void *pHead, bool bPass)
Definition: mcdaq_device.h:54
virtual DWORD GetInfo(void *pHead, DWORD dwSize)
void ProcessData(const void *pHead, DWORD dwSize, __int64 llId)