/************************************************* /* Copyright (C), 2010-2011,StoneU. Co., Ltd. /* File name: ups_newave.cpp /* Author: Zero.t /* Version: Ver1.0.0.1 /* Date: 2011-8-30 /* Description: Conceptpower系列UPS,具体型号未知;本类首次使用在项目::K客户现场文件\b北京\M美思装饰\大众汽车金融; /* Others: UPS协议类,不做控制设备操作; /* Function List: ### /* History: 1.Date: ### Author: ### Modification: ### *************************************************/ #include "StdAfx.h" #include "CommProcess.h" #include ".\ups_newave.h" Cups_newave::Cups_newave( char szPath[MAX_PATH], char szIniName[MAX_PATH], int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval ) { #if IS_USE_READMSG_CS InitializeCriticalSection(&m_csReadMsg); #endif MTVERIFY(m_hSemComm = CreateEvent(NULL, TRUE, TRUE, 0)); memset(m_szAlarmMsg, 0, sizeof(m_szAlarmMsg)); memset(m_szStatuMsg, 0, sizeof(m_szStatuMsg)); memset(m_szValueMsg, 0, sizeof(m_szValueMsg)); m_dwOnlineTick = 0; m_devOnline = TRUE; } Cups_newave::~Cups_newave(void) { #if IS_USE_READMSG_CS DeleteCriticalSection(& m_csReadMsg); #endif MTVERIFY(CloseHandle(m_hSemComm)); CloseComm(); } BOOL Cups_newave::upsAveOpenComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval) { BOOL bResult = FALSE; bResult = OpenComm( nCommPort, nAddr, nRate, nDataBit, nStopBit, nParity, nInterval ); return bResult; } int Cups_newave::GetParamFromIni( char szPath[MAX_PATH], char szIniName[MAX_PATH],char szCmd[MAX_CMD],char szSanTakSendMsg[MAX_CMD], char nType[MAX_CMD], int &nIndex, int &nLen ,int &StaBit, int &EndBit) { CHAR szFile[MAX_PATH + 1] = ""; wsprintf(szFile, "%s\\config\\%s", szPath, szIniName); TRACE("szFile =%s\n",szFile); GetPrivateProfileString(szCmd, "SendCmd", "", szSanTakSendMsg, 10, szFile); szSanTakSendMsg[strlen(szSanTakSendMsg)] = 0x0D; GetPrivateProfileString(szCmd, "type", "", nType, 10, szFile); nType[strlen(nType)] = '\0'; nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile); nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile); StaBit = GetPrivateProfileInt(szCmd,"StaBit",0,szFile); EndBit = GetPrivateProfileInt(szCmd,"EndBit",0,szFile); return 0; } int Cups_newave::SendQueryMsg( CCommProcess *pComm,int nAddr) { #if NEWAVE_DEBUG //开关量,用于测试模拟数据 __QueryMsg str_Query; int nLen = sizeof(__QueryMsg); memset(&str_Query,0,nLen); str_Query.msg_head = 0x3E; str_Query.msg_addr[0] = ByteToAscii((nAddr >> 4) & 0x0f); str_Query.msg_addr[1] = ByteToAscii(nAddr & 0x0f); str_Query.msg_type = 0x51; str_Query.msg_length[0] = 0x30; str_Query.msg_length[1] = 0x30; str_Query.msg_length[3] = 0x34; memcpy(str_Query.msg_check,"0186",4); if (WaitForSingleObject(m_hSemComm,0) == WAIT_OBJECT_0 ) { int nDatalen = (int)sizeof(str_Query); ResetEvent(m_hSemComm); int nResult = pComm->Write((BYTE *)&str_Query, nDatalen); //LOG4C_HEX_DUMP((LOG_NOTICE, chSendMsg, 3)); //LOG4C((LOG_NOTICE, "CSanTak::RequestStatus chSendMsg = %s, nResult = %d, nDatalen = %d", chSendMsg,nResult, nDatalen)); if (nResult == nDatalen) { } else { SetEvent(m_hSemComm); return EER_CODE_NEWAVE_COM_REGNUM; } } else { return ERR_CODE_NEWAVE_COM_BUSY; //串口忙 } #endif return 0; } int Cups_newave::QueryResponeMsg(CCommProcess *pComm,int nAddr) { #if NEWAVE_DEBUG //开关量,用于测试模拟数据 int ireallen = 0; __ResponeQuery str_record; int ireadlen = sizeof(str_record); char *pBuffer = new char[ireadlen]; memset(pBuffer,0,ireadlen); ireallen = pComm->Read((BYTE *)pBuffer,ireadlen); if (ireallen <= 0) { SetEvent(m_hSemComm); if (pBuffer != NULL) { delete[] pBuffer; pBuffer = NULL; } return ERR_CODE_NEWAVE_COM_READ_NO_DATA; } char ch_record = 0; ch_record = pBuffer[4]; m_dwOnlineTick = GetTickCount(); // 设置串口等待事件为有信号 SetEvent( m_hSemComm ); if( pBuffer != NULL) { delete[] pBuffer; pBuffer = NULL; } #endif return 0; } int Cups_newave::SendReadRequest( char szPath[MAX_PATH], char szIniName[MAX_PATH], int nCommPort, int nAddr, char szCmd[MAX_CMD], char szRecMsg[VAR_MSG], int nReversed1, int nReversed2, int nReversed3, int nReversed4, int nReversed5, float fReversed1, float fReversed2, float fReversed3, char szReversed1[MAX_RESERVED1], char szReversed2[MAX_RESERVED2], char szReversed3[MAX_RESERVED3], char szReversed4[MAX_RESERVED4], char szReversed5[MAX_RESERVED5] ) { int nIndex = 0, nLen = 0; int StaBit = 0, EndBit = 0; char szSendCmd[MAX_SENDCMD] = {0}; char szType[CMD_TYPE] = {0}; m_address = nAddr; GetParamFromIni(szPath, szIniName, szCmd, szSendCmd, szType, nIndex, nLen ,StaBit, EndBit); CCommProcess *pComm = FindComm(nCommPort); if( pComm == NULL ) return -1; int nRet = -1; if( ( strlen(m_szValueMsg) == 0 && ( strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-2") == 0 || strcmp(szCmd,"cmd-3") == 0 || strcmp(szCmd,"cmd-4") == 0 || strcmp(szCmd,"cmd-6") == 0 || strcmp(szCmd,"cmd-5") == 0 || strcmp(szCmd,"cmd-7") == 0 || strcmp(szCmd,"cmd-8") == 0 || strcmp(szCmd,"cmd-9") == 0 || strcmp(szCmd,"cmd-10") == 0 || strcmp(szCmd,"cmd-11") == 0 || strcmp(szCmd,"cmd-12") == 0|| strcmp(szCmd,"cmd-13") == 0 || strcmp(szCmd,"cmd-14") == 0 ))|| (strlen(m_szStatuMsg) == 0 &&( strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-16") == 0 || strcmp(szCmd,"cmd-17") == 0 || strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 || strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 || strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0 || strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 || strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 || strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 || strcmp(szCmd,"cmd-36") == 0 ))|| (strlen(m_szAlarmMsg) == 0 && ( strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0 || strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 || strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 || strcmp(szCmd,"cmd-45") == 0 || strcmp(szCmd,"cmd-46") == 0 || strcmp(szCmd,"cmd-47") == 0 || strcmp(szCmd,"cmd-48") == 0 || strcmp(szCmd,"cmd-49") == 0 || strcmp(szCmd,"cmd-50") == 0 || strcmp(szCmd,"cmd-51") == 0 || strcmp(szCmd,"cmd-52") == 0 || strcmp(szCmd,"cmd-53") == 0 || strcmp(szCmd,"cmd-54") == 0 || strcmp(szCmd,"cmd-55") == 0 || strcmp(szCmd,"cmd-56") == 0 || strcmp(szCmd,"cmd-57") == 0 || strcmp(szCmd,"cmd-58") == 0 || strcmp(szCmd,"cmd-59") == 0 || strcmp(szCmd,"cmd-60") == 0 || strcmp(szCmd,"cmd-61") == 0 || strcmp(szCmd,"cmd-62") == 0 || strcmp(szCmd,"cmd-63") == 0 || strcmp(szCmd,"cmd-64") == 0 || strcmp(szCmd,"cmd-65") == 0 || strcmp(szCmd,"cmd-66") == 0 ))|| strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-39") == 0 ) { nRet = GetDeviceParam(nAddr, pComm, szSendCmd, szCmd, szRecMsg, nIndex, nLen,szType ); if( nRet != 0 ) return nRet; } if( GetTickCount() - m_dwOnlineTick > 60 * 1000 && m_dwOnlineTick > 0 ) { m_devOnline = FALSE; } else if( GetTickCount() - m_dwOnlineTick < 60 * 1000 && m_dwOnlineTick > 0 ) { m_devOnline = TRUE; } if( m_devOnline == FALSE ) { return -1; } nRet = GetValueMsg(szCmd, szRecMsg, nIndex, nLen, szType); nRet = GetStatuMsg(szCmd, szRecMsg, nIndex, nLen, StaBit, EndBit, szType); nRet = GetAlarmMsg(szCmd, szRecMsg, nIndex, nLen, StaBit, EndBit, szType); //LOG4C_HEX_DUMP((LOG_NOTICE, szMsg, sizeof(szMsg))); LOG4C((LOG_NOTICE, "%s=%d", szCmd, atoi(szRecMsg))); return nRet; } int Cups_newave::GetDeviceParam( int nAddr, CCommProcess *pComm, // 串口对象指针 char szSendCmd[MAX_SEND_MSG], // 发送Buffer char szCmd[MAX_CMD], // 命令 char szMsg[VAR_MSG], // 接收Buffer int &nIndex, // 变量索引,针对接收Buffer而言 int &nLen, // 变量长度 char szType[CMD_TYPE] // 变量数据类型 ) { int nRet = -1; nRet = RequestStatus(nAddr, pComm, szSendCmd); if( nRet != 0 ) { return nRet; } nRet = ResponseStatus(nAddr, pComm, szCmd, szMsg, nIndex, nLen, szType); return nRet; } int Cups_newave::RequestStatus(int nAddr, CCommProcess *pComm,const char szSendCmd[MAX_SEND_MSG] ) { #if NEWAVE_DEBUG //开关量,用于测试模拟数据 int sum = 0; __GetMsg str_GetMsg; int nLen = sizeof(str_GetMsg); memset(&str_GetMsg,0,nLen); str_GetMsg.msg_head = 0x3E; str_GetMsg.msg_addr[0] = ByteToAscii((nAddr >> 4) & 0x0f); str_GetMsg.msg_addr[1] = ByteToAscii(nAddr & 0x0f); str_GetMsg.msg_type = 0x47; str_GetMsg.msg_length[0] = 0x30; str_GetMsg.msg_length[1] = 0x30; str_GetMsg.msg_length[2] = 0x38; memcpy(str_GetMsg.msg_record,szSendCmd,4); { sum += str_GetMsg.msg_head; sum += str_GetMsg.msg_addr[0]; sum += str_GetMsg.msg_addr[1]; sum += str_GetMsg.msg_type; sum += str_GetMsg.msg_length[0]; sum += str_GetMsg.msg_length[1]; sum += str_GetMsg.msg_length[2]; sum += str_GetMsg.msg_record[0]; sum += str_GetMsg.msg_record[1]; sum += str_GetMsg.msg_record[2]; sum += str_GetMsg.msg_record[3]; } CString strSum; strSum.Format("%00004X",sum); int nstrlen = strSum.GetLength(); if (nstrlen > 4) { return -1; } for (int i = 0 ; i < nstrlen; i++) { str_GetMsg.msg_check[i] = strSum.GetAt(i); } if (WaitForSingleObject(m_hSemComm,0) == WAIT_OBJECT_0 ) { int nDatalen = (int)sizeof(str_GetMsg); ResetEvent(m_hSemComm); int nResult = pComm->Write((BYTE *)&str_GetMsg, nDatalen); //LOG4C_HEX_DUMP((LOG_NOTICE, chSendMsg, 3)); //LOG4C((LOG_NOTICE, "CSanTak::RequestStatus chSendMsg = %s, nResult = %d, nDatalen = %d", chSendMsg,nResult, nDatalen)); if (nResult == nDatalen) { } else { SetEvent(m_hSemComm); return EER_CODE_NEWAVE_COM_REGNUM; } } else { return ERR_CODE_NEWAVE_COM_BUSY; //串口忙 } #endif return 0; } int Cups_newave::ResponseStatus(int nAddr,CCommProcess *pComm, char szCmd[MAX_CMD], char szMsg[VAR_MSG],int &nIndex, int &nLen, char szType[CMD_TYPE]) { #if NEWAVE_DEBUG int nReceiveLen = 650; int nProcessLen = 0; int nReadLen = 0; char *pBuff = new char[nReceiveLen]; memset(pBuff, 0 , nReceiveLen); nReadLen = pComm->Read((BYTE *)pBuff,nReceiveLen); //LOG4C((LOG_NOTICE, "CSanTak::ResponseStatus pBuff = %s, nReadLen = %d, nReceiveLen = %d", pBuff, nReadLen, nReceiveLen)); if (nReadLen <= 0) { SetEvent(m_hSemComm); if (pBuff != NULL) { delete [] pBuff; pBuff = NULL; } return ERR_CODE_NEWAVE_COM_READ_NO_DATA; } //长度校验出错 SetValueMsg(szCmd, pBuff); SetStatuMsg(szCmd, pBuff); SetAlarmMsg(szCmd, pBuff); m_dwOnlineTick = GetTickCount(); // 设置串口等待事件为有信号 SetEvent( m_hSemComm ); if( pBuff != NULL) { delete[] pBuff; pBuff = NULL; } #else SimulationCommData(); #endif return 0; } // 长度为2; void Cups_newave::DataProcess(const char *szSour, char *szDest,int &StaBit, int &EndBit) { char tmp_Sour[3] = {0}; memcpy(tmp_Sour,szSour,2); int sum = (AsciiToBYTE(tmp_Sour[0]))*16 + AsciiToBYTE(tmp_Sour[1]); int ByteBit = 0; switch(StaBit) { #if 1 case 7: ByteBit = sum & 0x01; break; case 6: ByteBit = (sum & 0x02) / 0x02 ; break; case 5: ByteBit = (sum & 0x04) / 0x04 ; break; case 4: ByteBit = (sum & 0x08) / 0x08 ; break; case 3: ByteBit = (sum & 0x10) / 0x10 ; break; case 2: ByteBit = (sum & 0x20) / 0x20 ; break; case 1: ByteBit = (sum & 0x40) / 0x40 ; break; case 0: ByteBit = (sum & 0x80) / 0x80; break; #else case 0: ByteBit = sum & 0x01; break; case 1: ByteBit = (sum & 0x02) / 0x02 ; break; case 2: ByteBit = (sum & 0x04) / 0x04 ; break; case 3: ByteBit = (sum & 0x08) / 0x08 ; break; case 4: ByteBit = (sum & 0x10) / 0x10 ; break; case 5: ByteBit = (sum & 0x20) / 0x20 ; break; case 6: ByteBit = (sum & 0x40) / 0x40 ; break; case 7: ByteBit = (sum & 0x80) / 0x80; break; #endif } szDest[0] = ByteBit + 48; } void Cups_newave::BitDataProcess(const char *szSour, char *szRecv, int &iSourLen,int &StaBit) { CString strBit = ""; // 存放位串字符; int ByteBit = 0; char *tmp_Sour = new char[iSourLen+1]; memcpy(tmp_Sour,szSour,iSourLen); for (int i = 0; i < iSourLen; i+=2) { char szDest[9] = {0}; // 目标数据; int sum = (AsciiToBYTE(tmp_Sour[i]))*16 + AsciiToBYTE(tmp_Sour[i+1]); for(int j = 0; j < 8; j ++) { switch(j) { case 7: ByteBit = sum & 0x01; break; case 6: ByteBit = (sum & 0x02) / 0x02 ; break; case 5: ByteBit = (sum & 0x04) / 0x04 ; break; case 4: ByteBit = (sum & 0x08) / 0x08 ; break; case 3: ByteBit = (sum & 0x10) / 0x10 ; break; case 2: ByteBit = (sum & 0x20) / 0x20 ; break; case 1: ByteBit = (sum & 0x40) / 0x40 ; break; case 0: ByteBit = (sum & 0x80) / 0x80; break; } szDest[j] = ByteBit + 48; } strBit += szDest; } strBit = strBit.MakeReverse(); szRecv[0] = strBit.GetAt(StaBit); if (tmp_Sour != NULL) { delete[] tmp_Sour; tmp_Sour = NULL; } } int Cups_newave::GetValueMsg(char szCmd[MAX_CMD],char szRecMsg[VAR_MSG],int &nIndex, int &nLen, char szTp[CMD_TYPE]) { int nRet = 0; if ( strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-2") == 0 || strcmp(szCmd,"cmd-3") == 0 || strcmp(szCmd,"cmd-4") == 0 || strcmp(szCmd,"cmd-6") == 0 || strcmp(szCmd,"cmd-5") == 0 || strcmp(szCmd,"cmd-7") == 0 || strcmp(szCmd,"cmd-8") == 0 || strcmp(szCmd,"cmd-9") == 0 || strcmp(szCmd,"cmd-10") == 0 || strcmp(szCmd,"cmd-11") == 0 || strcmp(szCmd,"cmd-12") == 0|| strcmp(szCmd,"cmd-13") == 0 || strcmp(szCmd,"cmd-14") == 0 ) { #if IS_USE_READMSG_CS EnterCriticalSection(&m_csReadMsg); #endif DataConversion(szTp, m_szValueMsg + nIndex, szRecMsg, nLen); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif nRet = 0; } return nRet; } int Cups_newave::GetStatuMsg(char szCmd[MAX_CMD],char szRecMsg[VAR_MSG],int &nIndex, int &nLen, int &StaBit, int &EndBit, char szTp[CMD_TYPE]) { int nRet = 0; if ( strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-16") == 0 || strcmp(szCmd,"cmd-17") == 0 || strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 || strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 || strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0 || strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 || strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 || strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 || strcmp(szCmd,"cmd-36") == 0 ) { #if IS_USE_READMSG_CS EnterCriticalSection(&m_csReadMsg); #endif //DataProcess(m_szStatuMsg + nIndex, szRecMsg ,StaBit, EndBit); BitDataProcess(m_szStatuMsg + nIndex,szRecMsg,nLen,StaBit); LOG4C((LOG_NOTICE, "%s Bit[%d] = %s", szCmd,StaBit ,szRecMsg)); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif nRet = 0; } return nRet; } int Cups_newave::GetAlarmMsg(char szCmd[MAX_CMD],char szRecMsg[VAR_MSG],int &nIndex, int &nLen, int &StaBit, int &EndBit, char szTp[CMD_TYPE]) { int nRet = 0; if ( strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0 || strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 || strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 || strcmp(szCmd,"cmd-45") == 0 || strcmp(szCmd,"cmd-46") == 0 || strcmp(szCmd,"cmd-47") == 0 || strcmp(szCmd,"cmd-48") == 0 || strcmp(szCmd,"cmd-49") == 0 || strcmp(szCmd,"cmd-50") == 0 || strcmp(szCmd,"cmd-51") == 0 || strcmp(szCmd,"cmd-52") == 0 || strcmp(szCmd,"cmd-53") == 0 || strcmp(szCmd,"cmd-54") == 0 || strcmp(szCmd,"cmd-55") == 0 || strcmp(szCmd,"cmd-56") == 0 || strcmp(szCmd,"cmd-57") == 0 || strcmp(szCmd,"cmd-58") == 0 || strcmp(szCmd,"cmd-59") == 0 || strcmp(szCmd,"cmd-60") == 0 || strcmp(szCmd,"cmd-61") == 0 || strcmp(szCmd,"cmd-62") == 0 || strcmp(szCmd,"cmd-63") == 0 || strcmp(szCmd,"cmd-64") == 0 || strcmp(szCmd,"cmd-65") == 0 || strcmp(szCmd,"cmd-66") == 0 ) { #if IS_USE_READMSG_CS EnterCriticalSection(&m_csReadMsg); #endif //DataProcess(m_szAlarmMsg + nIndex, szRecMsg ,StaBit, EndBit); BitDataProcess(m_szAlarmMsg + nIndex,szRecMsg,nLen,StaBit); LOG4C((LOG_NOTICE, "%s Bit[%d] = %s", szCmd,StaBit ,szRecMsg)); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif nRet = 0; } return nRet; } void Cups_newave::SetValueMsg(char szCmd[MAX_CMD], char *pBuffer) { if ( strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-2") == 0 || strcmp(szCmd,"cmd-3") == 0 || strcmp(szCmd,"cmd-4") == 0 || strcmp(szCmd,"cmd-6") == 0 || strcmp(szCmd,"cmd-5") == 0 || strcmp(szCmd,"cmd-7") == 0 || strcmp(szCmd,"cmd-8") == 0 || strcmp(szCmd,"cmd-9") == 0 || strcmp(szCmd,"cmd-10") == 0 || strcmp(szCmd,"cmd-11") == 0 || strcmp(szCmd,"cmd-12") == 0|| strcmp(szCmd,"cmd-13") == 0 || strcmp(szCmd,"cmd-14") == 0 ) { #if IS_USE_READMSG_CS EnterCriticalSection(&m_csReadMsg); #endif memcpy(m_szValueMsg, pBuffer, sizeof(m_szValueMsg)); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif } } void Cups_newave::SetStatuMsg(char szCmd[MAX_CMD], char *pBuffer) { if ( strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-16") == 0 || strcmp(szCmd,"cmd-17") == 0 || strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 || strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 || strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0 || strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 || strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 || strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 || strcmp(szCmd,"cmd-36") == 0 ) { #if IS_USE_READMSG_CS EnterCriticalSection(&m_csReadMsg); #endif memcpy(m_szStatuMsg, pBuffer, sizeof(m_szStatuMsg)); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif } } void Cups_newave::SetAlarmMsg(char szCmd[MAX_CMD], char *pBuffer) { if ( strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0 || strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 || strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 || strcmp(szCmd,"cmd-45") == 0 || strcmp(szCmd,"cmd-46") == 0 || strcmp(szCmd,"cmd-47") == 0 || strcmp(szCmd,"cmd-48") == 0 || strcmp(szCmd,"cmd-49") == 0 || strcmp(szCmd,"cmd-50") == 0 || strcmp(szCmd,"cmd-51") == 0 || strcmp(szCmd,"cmd-52") == 0 || strcmp(szCmd,"cmd-53") == 0 || strcmp(szCmd,"cmd-54") == 0 || strcmp(szCmd,"cmd-55") == 0 || strcmp(szCmd,"cmd-56") == 0 || strcmp(szCmd,"cmd-57") == 0 || strcmp(szCmd,"cmd-58") == 0 || strcmp(szCmd,"cmd-59") == 0 || strcmp(szCmd,"cmd-60") == 0 || strcmp(szCmd,"cmd-61") == 0 || strcmp(szCmd,"cmd-62") == 0 || strcmp(szCmd,"cmd-63") == 0 || strcmp(szCmd,"cmd-64") == 0 || strcmp(szCmd,"cmd-65") == 0 || strcmp(szCmd,"cmd-66") == 0 ) { #if IS_USE_READMSG_CS EnterCriticalSection(&m_csReadMsg); #endif memcpy(m_szAlarmMsg, pBuffer, sizeof(m_szAlarmMsg)); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif } } void Cups_newave::SimulationCommData() { memcpy(m_szValueMsg, ">01A0575999,100,2277,2278,2289,2204,2197,2199,3,7,4,12,23,150BDF", sizeof(">01A0575999,100,2277,2278,2289,2204,2197,2199,3,7,4,12,23,150BDF")); memcpy(m_szStatuMsg, ">01A012C0C291B3033A", sizeof(">01A012C0C291B3033A")); memcpy(m_szAlarmMsg, ">01A018808080808080800451", sizeof(">01A018808080808080800451")); }