CommAsyn.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // CommAsyn.cpp: implementation of the CCommAsyn class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "CommAsyn.h"
  6. #include <atlconv.h>
  7. #include "ProtocolModbus.h"
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[]=__FILE__;
  11. #define new DEBUG_NEW
  12. #endif
  13. //////////////////////////////////////////////////////////////////////
  14. // Construction/Destruction
  15. //////////////////////////////////////////////////////////////////////
  16. CCommAsyn::CCommAsyn()
  17. {
  18. m_pProtocol=NULL;
  19. }
  20. CCommAsyn::~CCommAsyn()
  21. {
  22. if(m_pProtocol)
  23. {
  24. delete m_pProtocol;
  25. m_pProtocol=NULL;
  26. }
  27. }
  28. BOOL CCommAsyn::CloseComm()
  29. {
  30. return this->CloseComm();
  31. }
  32. BOOL CCommAsyn::InitParam(PPORTPARAM pPortParam)
  33. {
  34. if(m_pProtocol)
  35. {
  36. delete m_pProtocol;
  37. m_pProtocol=NULL;
  38. }
  39. m_pProtocol=new CProtocolModbus();
  40. return m_pProtocol->InitParam(pPortParam,this);
  41. }
  42. int CCommAsyn::WorkMain(int nAddr, int nDataLen, int nReadPos, char chMsg[80])
  43. {
  44. return m_pProtocol->WorkMain( nAddr, nDataLen, nReadPos, chMsg);
  45. }
  46. int CCommAsyn:: WriteCommand(
  47. int nAddr,
  48. int nWorkStatus, int nWorkMode, int nFanSpeed,
  49. int nPutWind, int nAirTrade, int nSleep, int nLight,
  50. int nTempSetPoint )
  51. {
  52. return m_pProtocol->WriteCommand( nAddr,
  53. nWorkStatus,
  54. nWorkMode,
  55. nFanSpeed,
  56. nPutWind,
  57. nAirTrade,
  58. nSleep,
  59. nLight,
  60. nTempSetPoint );
  61. }