ProtocolModbus.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // ProtocolPMC916.h: interface for the CProtocolModbus class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PROTOCOLPMC916_H_INCLUDED_)
  5. #define AFX_PROTOCOLPMC916_H_INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #define DEBUG_PROTOCOL 1
  10. #include "Protocol.h"
  11. class CProtocolModbus : public CProtocol
  12. {
  13. public:
  14. virtual BOOL InitParam(PPORTPARAM pPortParam, CCommAsyn *pComm);
  15. virtual int WorkMain(SETBASEPARAM SetBasePara, int nDataLen, char chMsg[80]);
  16. virtual int WriteCommand(SETBASEPARAM SetBasePara, double dbData, int nDataLen);
  17. CProtocolModbus();
  18. virtual ~CProtocolModbus();
  19. protected:
  20. HANDLE m_hSemComm;
  21. CRITICAL_SECTION m_csReadFinished;
  22. CRITICAL_SECTION m_csWrFinished;
  23. protected:
  24. virtual int RequestStatus( SETBASEPARAM SetBasePara);
  25. virtual int ResponseStatus( int nAddr, int nRegNum, int nDataLen, char chMsg[80]);
  26. virtual int RequestWrStatus( SETBASEPARAM SetBasePara, double dbData, int nDataLen);
  27. virtual int ResponseWrStatus(int nAddr, int nRegNum, int nDataLen);
  28. };
  29. BYTE GetCheckCode(const char * pSendBuf, int nEnd);//»ñµÃУÑéÂë
  30. char ByteToAscii(BYTE btSrc);
  31. WORD AsciiToBYTE(BYTE btSrc);
  32. static unsigned char LRC(unsigned char *auchMsg, unsigned short usDataLen);
  33. #endif // !defined(AFX_PROTOCOLPMC916_H_INCLUDED_)