Protocol.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Protocol.h: interface for the CProtocol class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PROTOCOL_H__B54C8930_9411_4B11_B750_261140346F76__INCLUDED_)
  5. #define AFX_PROTOCOL_H__B54C8930_9411_4B11_B750_261140346F76__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. class CCommAsyn;
  10. class CProtocol
  11. {
  12. public:
  13. virtual BOOL InitParam(PPORTPARAM pPortParam,CCommAsyn*pComm);
  14. virtual int WorkMain(
  15. int nAddr, //设备地址
  16. BYTE Start, //起始位
  17. BYTE StartAddr[2], //起始地址
  18. int nRegNum, //读取的寄存器个数
  19. BYTE FuncCode[2],
  20. int nDataLen,
  21. BYTE byWithAddrFlag,
  22. char chMsg[80]) =0;
  23. virtual int WriteCommand(char DataBuffer[80], int nDataLen) = 0;
  24. CProtocol();
  25. virtual ~CProtocol();
  26. protected:
  27. CCommAsyn* m_pComm;
  28. int WriteMessage(BYTE* pBuf, int len);
  29. int ReadMessage(BYTE *pBuf, int len);
  30. public:
  31. RESPONSE_STRUCT m_structResponse;
  32. };
  33. #endif // !defined(AFX_PROTOCOL_H__B54C8930_9411_4B11_B750_261140346F76__INCLUDED_)