#if  !defined(_TOUCHKIT_20120103_H_)
#define _TOUCHKIT_20120103_H_

#include <DownComm.h>

void AfxGetTouchkitRowXY(int* pnTouchX, int*pnTouchY);
void AfxGetTouchkitIndexXY(int* pnIndexX, int*pnIndexY);

typedef struct tagTOUCHPANEHEAD
{
        WORD wFlags;
        WORD wStyle;
	WORD m_wScreenW;
	WORD m_wScreenH;
	WORD m_wPaneCols;
	WORD m_wPaneRows;

        BYTE  bysReserved[256 - 6 * sizeof(WORD)];
}TOUCHPANEHEAD, *LPTOUCHPANEHEAD;

class CTouchKit:public CMotorNet
{
private:
	BOOL m_bExist;
	BOOL m_bOpen;
	int  m_nWire;
	int  m_nScreenW;
	int  m_nScreenH;
	DWORD m_dwCounter;

	BYTE m_buffer[32];
public:
       TOUCHPANEHEAD m_TouchPaneHead;
public:
	void ClearBuffer();
	int ReceivePacket(BYTE* pBuffer, int nMaxCount);
public:
	BOOL  IsExist();
	DWORD GetVersion();
	BOOL  GetType();
	BOOL  GetAttrib(int* pnRowX, int* pnRowY, int* nState);
public:
	void SetCounter(DWORD dwCounter){m_dwCounter = dwCounter;}
	void AddCounter(){m_dwCounter++;}
	DWORD GetCounter(){m_dwCounter = 0lu;}
	void  SetScreenWH(int nW, int nH) {m_nScreenW = nW; m_nScreenH = nH;}
public:
	BOOL Init(int nBase);
	BOOL FindXY(int nRowX, int nRowY, int *pnSx, int *pnSy);
public:
	CTouchKit();
	~CTouchKit();
};



#endif