12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- // CommAsyn.cpp: implementation of the CCommAsyn class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "CommAsyn.h"
- #include <atlconv.h>
- #include "ProtocolModbus.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CCommAsyn::CCommAsyn()
- {
- m_pProtocol=NULL;
- }
- CCommAsyn::~CCommAsyn()
- {
- if(m_pProtocol)
- {
- delete m_pProtocol;
- m_pProtocol=NULL;
- }
- }
- BOOL CCommAsyn::CloseComm()
- {
- return this->CloseComm();
- }
- BOOL CCommAsyn::InitParam(PPORTPARAM pPortParam)
- {
- if(m_pProtocol)
- {
- delete m_pProtocol;
- m_pProtocol=NULL;
- }
- m_pProtocol=new CProtocolModbus();
- return m_pProtocol->InitParam(pPortParam,this);
- }
- int CCommAsyn::WorkMain(int nCommPort,
- int nAddr,
- char szCmd[32],
- char chSendMsg[32],
- int nDataLen,
- char chMsg[UPS_KE_HUA_MAX_MSG])
- {
- return m_pProtocol->WorkMain(nCommPort,
- nAddr,
- szCmd,
- chSendMsg,
- nDataLen,
- chMsg);
- }
- int CCommAsyn:: WriteCommand(char DataBuffer[80], int nDataLen)
- {
- return m_pProtocol->WriteCommand( DataBuffer, nDataLen);
- }
|