| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590 |
- #include "stdafx.h"
- #include "hipulse_uv130.h "
- hipulse_uv130::hipulse_uv130(char *szPath,char *szIniName,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) ); //CreateEvent()创建或打开一个命名的或无名的事件对象
-
- for( int i = 0; i < MAX_ADDR; i++ )
- {
- memset(m_szHipulse_U_41Msg[i], 0, sizeof(m_szHipulse_U_41Msg[i]));
- memset(m_szHipulse_U_43Msg[i], 0, sizeof(m_szHipulse_U_43Msg[i]));
- memset(m_szHipulse_U_44Msg[i], 0, sizeof(m_szHipulse_U_44Msg[i]));
- memset(m_szHipulse_U_E1Msg[i], 0, sizeof(m_szHipulse_U_E1Msg[i]));
- memset(m_szHipulse_U_E2Msg[i], 0, sizeof(m_szHipulse_U_E2Msg[i]));
- memset(m_szHipulse_U_E3Msg[i], 0, sizeof(m_szHipulse_U_E3Msg[i]));
- m_devOnline[i] = TRUE;
- m_dwOnlineTick[i] = 0;
- }
- }
- hipulse_uv130::~hipulse_uv130()
- {
- #if IS_USE_READMSG_CS
- DeleteCriticalSection( &m_csReadMsg );
- #endif
- MTVERIFY( CloseHandle( m_hSemComm ) );
- CloseComm();
- }
- BOOL hipulse_uv130::UpsHipulseOpenComm(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 );
- //LOG4C((LOG_NOTICE,"->OpenUPSComm"));
- return bResult;
- }
- int hipulse_uv130::GetIniInfo(char *szPath,char *szIniName,char *szCmd,char *IniSendCMD,int &IniSendlen,char *szDataType,int &nIndex,int &nLen, int &iSBit, int &iEBit)
- {
- CHAR szFile[MAX_PATH + 1] = "";
- wsprintf(szFile, "%s\\config\\%s", szPath, szIniName);
- IniSendlen = GetPrivateProfileString(szCmd, "SendCmd", "", IniSendCMD, 10, szFile); // 返回的字符串是以\0结束的;
- GetPrivateProfileString(szCmd, "type", "", szDataType, 10, szFile);
- szDataType[strlen(szDataType)] = '\0';
- nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile);
- nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile);
- iSBit = GetPrivateProfileInt(szCmd, "StaBit", 0, szFile);//从配置文件中取值
- iEBit = GetPrivateProfileInt(szCmd, "EndBit", 0, szFile);
- return 0;
- }
- // 发送读取设备参数请求
- int hipulse_uv130::SendReadRequest(
- char szPath[MAX_PATH], // 程序所在路径
- char szIniName[MAX_PATH], // 配置文件名称
- int nCommPort, // 串行端口
- int nAddr, // 设备地址
- char szCmd[MAX_CMD], // 请求命令
- char szMsg[VAR_MSG], // 响应的值
- int nReversed1, // 预留整形参数1接口
- int nReversed2, // 预留整形参数2接口
- int nReversed3, // 预留整形参数3接口
- int nReversed4, // 预留整形参数4接口
- int nReversed5, // 预留整形参数5接口
- float fReversed1, // 预留float参数1接口
- float fReversed2, // 预留float参数2接口
- float fReversed3, // 预留float参数3接口
- char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
- char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
- char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
- char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
- char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
- )
- {
- //LOG4C((LOG_NOTICE,"->SendReadRequest"));
- CCommProcess *pComm = FindComm(nCommPort);
- if( pComm == NULL ) return -1;
- int nRet = -1;
- int nIndex(0), nLen(0), IniSendlen(0),iSBit(0), iEBit(0);
- char IniSendCMD[MAX_CMD] = {0}, szDataType[CMD_TYPE] = {0};
- GetIniInfo(szPath,szIniName,szCmd,IniSendCMD,IniSendlen,szDataType,nIndex,nLen,iSBit,iEBit);
- if( nAddr < 1 )
- return -1;
- int iCmd = atoi(szCmd + 4);
- if(
- (strlen(m_szHipulse_U_41Msg[nAddr -1]) == 0 && (iCmd >= 1 && iCmd <= 14)) || iCmd == 1 ||
- (strlen(m_szHipulse_U_E1Msg[nAddr -1]) == 0 && (iCmd >= 15 && iCmd <= 28)) || iCmd == 15 ||
- (strlen(m_szHipulse_U_E2Msg[nAddr -1]) == 0 && (iCmd >= 29 && iCmd <= 44)) || iCmd == 29 ||
- (strlen(m_szHipulse_U_E3Msg[nAddr -1]) == 0 && (iCmd >= 45 && iCmd <= 61)) || iCmd == 45 ||
- (strlen(m_szHipulse_U_43Msg[nAddr -1]) == 0 && (iCmd >= 62 && iCmd <= 74)) || iCmd == 62 ||
- (strlen(m_szHipulse_U_44Msg[nAddr -1]) == 0 && (iCmd >= 75 && iCmd <= 134)) || iCmd == 75
- )
- {
- nRet = GetDeviceParam( nAddr,pComm, szCmd, IniSendCMD, IniSendlen );
- if ( nRet != 0) return nRet;
- }
- if( GetTickCount() - m_dwOnlineTick[nAddr - 1] > 60 *1000 && m_dwOnlineTick[nAddr - 1] > 0 )
- m_devOnline[nAddr - 1] = FALSE;
- else if( GetTickCount() - m_dwOnlineTick[nAddr - 1] < 60 *1000 && m_dwOnlineTick[nAddr - 1] > 0 )
- m_devOnline[nAddr - 1] = TRUE;
- if( m_devOnline[nAddr - 1] == FALSE )
- return -1;
- nRet = GetHipulseQ41VarMsg( nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
- nRet = GetHipulseQ43VarMsg( nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
- nRet = GetHipulseQ44VarMsg( nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
- nRet = GetHipulseQE1VarMsg( nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
- nRet = GetHipulseQE2VarMsg( nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
- nRet = GetHipulseQE3VarMsg( nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
- //LOG4C((LOG_NOTICE,"nRet = %d,cmd = %s,值 = %s",nRet,szCmd,szMsg));
- return nRet;
- }
- int hipulse_uv130::GetDeviceParam(int nAddr,CCommProcess *pComm,char *szCmd,char *IniSendCMD,const int &IniSendlen)
- {
- int nRet = -1;
- nRet = Send_ReadDeviceData(nAddr, pComm, szCmd, IniSendCMD, IniSendlen);
- if( nRet != 0 )
- return nRet; // 串口忙
- nRet = Recv_ReadDeviceData( nAddr, pComm, szCmd);
- return nRet;
- }
- // 发送设置设备参数请求
- int hipulse_uv130::SendSetReuest(
- char szPath[MAX_PATH], // 程序所在路径
- char szIniName[MAX_PATH], // 配置文件名称
- int nCommPort, // 串行端口
- int nAddr, // 设备地址
- char szCmd[MAX_CMD], // 请求命令
- char szMsg[VAR_MSG], // 响应的值
- int nReversed1, // 预留整形参数1接口
- int nReversed2, // 预留整形参数2接口
- int nReversed3, // 预留整形参数3接口
- int nReversed4, // 预留整形参数4接口
- int nReversed5, // 预留整形参数5接口
- float fReversed1, // 预留float参数1接口
- float fReversed2, // 预留float参数2接口
- float fReversed3, // 预留float参数3接口
- char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
- char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
- char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
- char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
- char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
- )
- {
- return 0;
- }
- int hipulse_uv130::Send_ReadDeviceData(int nAddr,CCommProcess *pComm,char *szCmd, const char *IniSendCMD,const int &IniSendlen)
- {
- #if DEBUG_Hipulse_U
- char chLength[4] = {0};
- char chChkSum[5] = {0};
- REQUESTPARAM RequestPara;
- int iLen = sizeof(RequestPara);
- memset( &RequestPara, 0, iLen );
- RequestPara.RequestChild.bySoi = 0x7E;
- RequestPara.RequestChild.byVer[0] = 0x31;
- RequestPara.RequestChild.byVer[1] = 0x31;
- RequestPara.RequestChild.byAdr[0] = ByteToAscii((nAddr >> 4) & 0x0f);
- RequestPara.RequestChild.byAdr[1] = ByteToAscii(nAddr & 0x0f);
- RequestPara.RequestChild.byCid1[0] = 0x32;
- RequestPara.RequestChild.byCid1[1] = 0x41;
- memcpy(RequestPara.RequestChild.byCid2, IniSendCMD, IniSendlen);
- RequestPara.RequestChild.byLength[0] = 0x30;
- RequestPara.RequestChild.byLength[1] = 0x30;
- RequestPara.RequestChild.byLength[2] = 0x30;
- RequestPara.RequestChild.byLength[3] = 0x30;
- int nLen = sizeof(RequestPara.byCheckSum) -1;
- BYTE *pDataBuf = new BYTE[ iLen - nLen];
- memset(pDataBuf, 0, iLen -nLen );
- memcpy(pDataBuf, &RequestPara, iLen - nLen);
- GetCheckSum((char *)pDataBuf + 1, chChkSum, iLen - sizeof(RequestPara.byCheckSum) - 2 );
- delete []pDataBuf;
- pDataBuf = NULL;
- RequestPara.byCheckSum[0] = chChkSum[0];
- RequestPara.byCheckSum[1] = chChkSum[1];
- RequestPara.byCheckSum[2] = chChkSum[2];
- RequestPara.byCheckSum[3] = chChkSum[3];
- RequestPara.byEoi = 0x0D;
- if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) // 有信号才写串口
- {
- int nDataLen = (int)sizeof(RequestPara);
- ResetEvent( m_hSemComm );
- int nResult = pComm->Write((BYTE *)&RequestPara, nDataLen);
- if( nResult != nDataLen )
- {
- SetEvent( m_hSemComm );
- return ERR_CODE_HIPULSE_COM_REGNUM;
- }
- }
- else
- {
- return ERR_CODE_HIPULSE_COM_BUSY;
- }
- #endif
- return 0;
- }
- int hipulse_uv130::Recv_ReadDeviceData(int nAddr,CCommProcess *pComm,char *szCmd)
- {
- #if DEBUG_Hipulse_U
- BYTE *byAryRecv = new BYTE[250];
- ZeroMemory(byAryRecv, 250);
- int iRecvLen = pComm->Read((BYTE *)byAryRecv, 250);
- if( iRecvLen <= 0)
- {
- SetEvent( m_hSemComm );
- if( iRecvLen != NULL)
- {
- delete[] byAryRecv;
- byAryRecv = NULL;
- }
- return ERR_CODE_HIPULSE_COM_READ_NO_DATA;
- }
- if (!ChkSumCheck( (char*)byAryRecv,iRecvLen))
- {
- SetEvent( m_hSemComm );
- if( iRecvLen != NULL)
- {
- delete[] byAryRecv;
- byAryRecv = NULL;
- }
- return ERR_CODE_HIPULSE_COM_CHKSUM_LOST;
- }
- #if 1
- if (!CheckLength( (char*)byAryRecv))
- {
- // 数据长度校检错误
- //TRACE("数据长度校检错误!\r\n");
- SetEvent( m_hSemComm );
- if( iRecvLen != NULL)
- {
- delete[] byAryRecv;
- byAryRecv = NULL;
- }
- return ERR_CODE_HIPULSE_COM_VARLEN;
- }
- int nRet = RtnCheck( (char*)byAryRecv,iRecvLen);
- if (nRet !=0 )
- {
- SetEvent( m_hSemComm );
- if( iRecvLen != NULL)
- {
- delete[] byAryRecv;
- byAryRecv = NULL;
- }
- return nRet;
- }
- #endif
- SetHipulseQ41VarMsg( nAddr,szCmd, (char*)byAryRecv);
- SetHipulseQ43VarMsg( nAddr,szCmd, (char*)byAryRecv);
- SetHipulseQ44VarMsg( nAddr,szCmd, (char*)byAryRecv);
- SetHipulseQE1VarMsg( nAddr,szCmd, (char*)byAryRecv);
- SetHipulseQE2VarMsg( nAddr,szCmd, (char*)byAryRecv);
- SetHipulseQE3VarMsg( nAddr,szCmd, (char*)byAryRecv);
- m_dwOnlineTick[nAddr -1] = GetTickCount();
- // 设置串口等待事件为有信号
- SetEvent( m_hSemComm );
- if( byAryRecv != NULL)
- {
- delete[] byAryRecv;
- byAryRecv = NULL;
- }
- #else
- SimulationCommData();
- #endif
- return 0;
- }
- void hipulse_uv130::SetHipulseQ41VarMsg( int nAddr,char *szCmd, char *pBuffer)
- {
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 1 && iCmd <=14)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- memcpy(m_szHipulse_U_41Msg[nAddr-1], pBuffer, sizeof(m_szHipulse_U_41Msg[nAddr-1]));
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- }
- }
- void hipulse_uv130::SetHipulseQE1VarMsg( int nAddr,char *szCmd, char *pBuffer)
- {
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 15 && iCmd <=28)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- memcpy(m_szHipulse_U_E1Msg[nAddr-1], pBuffer, sizeof(m_szHipulse_U_E1Msg[nAddr-1]));
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif;
- }
- }
- void hipulse_uv130::SetHipulseQE2VarMsg( int nAddr,char *szCmd, char *pBuffer)
- {
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 29 && iCmd <=44)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- memcpy(m_szHipulse_U_E2Msg[nAddr-1], pBuffer, sizeof(m_szHipulse_U_E2Msg[nAddr-1]));
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif;
- }
- }
- void hipulse_uv130::SetHipulseQE3VarMsg( int nAddr,char *szCmd, char *pBuffer)
- {
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 45 && iCmd <=61)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- memcpy(m_szHipulse_U_E3Msg[nAddr-1], pBuffer, sizeof(m_szHipulse_U_E3Msg[nAddr-1]));
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- }
- }
- void hipulse_uv130::SetHipulseQ43VarMsg( int nAddr,char *szCmd, char *pBuffer)
- {
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 62 && iCmd <=74)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- memcpy(m_szHipulse_U_43Msg[nAddr-1], pBuffer, sizeof(m_szHipulse_U_43Msg[nAddr-1]));
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- }
- }
- void hipulse_uv130::SetHipulseQ44VarMsg( int nAddr,char *szCmd, char *pBuffer)
- {
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 75 && iCmd <=134)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- memcpy(m_szHipulse_U_44Msg[nAddr-1], pBuffer, sizeof(m_szHipulse_U_44Msg[nAddr-1]));
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif;
- }
- }
- int hipulse_uv130::GetHipulseQ41VarMsg(int nAddr,char *szCmd, char *szRecvMsg,int &nIndex,int &nLen,char *szDataType)
- {
- int nRet = 0;
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 1 && iCmd <=14)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- DataConversion(szDataType, m_szHipulse_U_41Msg[nAddr-1] + nIndex, szRecvMsg, nLen, 0, 0);
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- nRet = 0;
- #endif
- }
- return nRet;
- }
- int hipulse_uv130::GetHipulseQE1VarMsg(int nAddr,char *szCmd, char *szRecvMsg,int &nIndex,int &nLen,char *szDataType)
- {
- int nRet = 0;
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 15 && iCmd <=28)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- DataConversion(szDataType, m_szHipulse_U_E1Msg[nAddr-1] + nIndex, szRecvMsg, nLen, 0, 0);
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- nRet = 0;
- }
- return nRet;
- }
- int hipulse_uv130::GetHipulseQE2VarMsg(int nAddr,char *szCmd, char *szRecvMsg,int &nIndex,int &nLen,char *szDataType)
- {
- int nRet = 0;
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 29 && iCmd <=44)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- DataConversion(szDataType, m_szHipulse_U_E2Msg[nAddr-1] + nIndex, szRecvMsg, nLen, 0, 0);
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- nRet = 0;
- }
- return nRet;
- }
- int hipulse_uv130::GetHipulseQE3VarMsg(int nAddr,char *szCmd, char *szRecvMsg,int &nIndex,int &nLen,char *szDataType)
- {
- int nRet = 0;
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 45 && iCmd <=61)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- DataConversion(szDataType, m_szHipulse_U_E3Msg[nAddr-1] + nIndex, szRecvMsg, nLen, 0, 0);
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- nRet = 0;
- }
- return nRet;
- }
- int hipulse_uv130::GetHipulseQ43VarMsg(int nAddr,char *szCmd, char *szRecvMsg,int &nIndex,int &nLen,char *szDataType)
- {
- int nRet = 0;
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 62 && iCmd <=74)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- DataConversion(szDataType, m_szHipulse_U_43Msg[nAddr-1] + nIndex, szRecvMsg, nLen, 0, 0);
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- nRet = 0;
- }
- return nRet;
- }
- int hipulse_uv130::GetHipulseQ44VarMsg(int nAddr,char *szCmd, char *szRecvMsg,int &nIndex,int &nLen,char *szDataType)
- {
- int nRet = 0;
- int iCmd = atoi(szCmd + 4);
- if ( iCmd >= 75 && iCmd <=134)
- {
- #if IS_USE_READMSG_CS
- EnterCriticalSection( &m_csReadMsg );
- #endif
- DataConversion(szDataType, m_szHipulse_U_44Msg[nAddr-1] + nIndex, szRecvMsg, nLen, 0, 0);
- #if IS_USE_READMSG_CS
- LeaveCriticalSection(&m_csReadMsg);
- #endif
- nRet = 0;
- }
- return nRet;
- }
- void hipulse_uv130::SimulationCommData(void)
- {
- }
- UINT hipulse_uv130::GetCheckSum(char *pBuf, char chDest[5], int len)
- {
- WORD iSum = 0;;
- for(int i=0; i<len; i++)//求和
- {
- iSum += pBuf[i];
- }
- WORD iCompliment = iSum;
- iCompliment = ~iCompliment;//取反
- iCompliment++;
- itoa(iCompliment, chDest, 16);
- chDest[0] = lowercase2uppercase(chDest[0]);
- chDest[1] = lowercase2uppercase(chDest[1]);
- chDest[2] = lowercase2uppercase(chDest[2]);
- chDest[3] = lowercase2uppercase(chDest[3]);
- return atoi(chDest);
- }
- WORD hipulse_uv130::RtnCheck(char szRecvdMsg[VAR_MSG],int len)
- {
- char ch[2];
- ch[0] = szRecvdMsg[7];
- ch[1] = szRecvdMsg[8];
- if (atoi(ch) == 0)
- {
- return 0;
- }
- else if (atoi(ch)==ERR_CID_RTN_VAR)
- {
- return ERR_CID_RTN_VAR;
- }
- else if (atoi(ch)==ERR_CID_RTN_CHKSUM)
- {
- return ERR_CID_RTN_CHKSUM;
- }
- else if (atoi(ch)==ERR_CID_RTN_LCHKSUM)
- {
- return ERR_CID_RTN_LCHKSUM;
- }
- else if (atoi(ch)==ERR_CID_RTN_CID2)
- {
- return ERR_CID_RTN_CID2;
- }
- else if (atoi(ch)==ERR_CID_RTN_FORMAT)
- {
- return ERR_CID_RTN_FORMAT;
- }
- else if (atoi(ch)==ERR_CID_RTN_INVALI_DATA)
- {
- return ERR_CID_RTN_INVALI_DATA;
- }
- else if (atoi(ch)==ERR_CID_RTN_INVALI_RIGHT)
- {
- return ERR_CID_RTN_INVALI_RIGHT;
- }
- else if (atoi(ch)==ERR_CID_RTN_OPERATE_FALL)
- {
- return ERR_CID_RTN_OPERATE_FALL;
- }
- else if (atoi(ch)==ERR_CID_RTN_COM_ERR)
- {
- return ERR_CID_RTN_COM_ERR;
- }
- return -1;
- }
|