CommAsyn.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // CommAsyn.h: interface for the CCommAsyn class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_COMMASYN_H__8351010D_0DD3_4F8C_8F3B_959BA59019E7__INCLUDED_)
  5. #define AFX_COMMASYN_H__8351010D_0DD3_4F8C_8F3B_959BA59019E7__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #define STATUS_NORMAL 0
  10. #define STATUS_FAULT 1
  11. #define STATUS_NOUSE 2
  12. #define STATUS_TYPEERROR 3
  13. #define COMM_CORRECT 0
  14. #define COMM_ERROR 1
  15. #define MAX_DATA_NUM128 128
  16. #define MAX_YXNO 2048
  17. #define MAX_YCNO 2048
  18. class CProtocol;
  19. class CCommAsyn
  20. {
  21. public:
  22. CProtocol* m_pProtocol;
  23. virtual int Write(BYTE * pBuf, int len) =0;
  24. virtual int Read(BYTE * pBuf, int len) =0;
  25. virtual int WriteCommand(char DataBuffer[80], int nDataLen);
  26. virtual int WorkMain(
  27. int nAddr, //设备地址
  28. BYTE Start, //起始位
  29. BYTE StartAddr[2], //起始地址
  30. int nRegNum, //读取的寄存器个数
  31. BYTE FuncCode[2],
  32. int nDataLen,
  33. BYTE byWithAddrFlag,
  34. char chMsg[80]);
  35. virtual BOOL InitParam(PPORTPARAM pPortParam);
  36. virtual BOOL CloseComm();
  37. CCommAsyn();
  38. virtual ~CCommAsyn();
  39. };
  40. #endif // !defined(AFX_COMMASYN_H__8351010D_0DD3_4F8C_8F3B_959BA59019E7__INCLUDED_)