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. UINT GetCRC(BYTE *pBuf, int len);
  15. virtual BOOL InitParam(PPORTPARAM pPortParam, CCommAsyn *pComm);
  16. virtual int WorkMain(SETBASEPARAM SetBasePara, int nDataLen, char chMsg[80]);
  17. virtual int WriteCommand(SETBASEPARAM SetBasePara, double dbData, int nDataLen);
  18. CProtocolModbus();
  19. virtual ~CProtocolModbus();
  20. protected:
  21. HANDLE m_hSemComm;
  22. CRITICAL_SECTION m_csReadFinished;
  23. CRITICAL_SECTION m_csWrFinished;
  24. protected:
  25. virtual int RequestStatus( SETBASEPARAM SetBasePara);
  26. virtual int ResponseStatus( int nAddr, int nRegNum, int nDataLen, char chMsg[80]);
  27. virtual int RequestWrStatus( SETBASEPARAM SetBasePara, double dbData, int nDataLen);
  28. virtual int ResponseWrStatus(int nAddr, int nRegNum, int nDataLen);
  29. };
  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_)