canatal_13.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. #include "StdAfx.h"
  2. #include ".\canatal.h"
  3. canatal::canatal(char *szPath,char *szIniName,int nCommPort, int nAddr,int nRate, int nDataBit,int nStopBit, int nParity,int nInterval)
  4. {
  5. #if IS_USE_READMSG_CS
  6. InitializeCriticalSection(&m_csReadMsg);
  7. #endif
  8. MTVERIFY(m_hSemComm = CreateEvent(NULL, TRUE, TRUE, 0));
  9. for (int i = 0; i < MAX_ADDR ; i++)
  10. {
  11. memset(m_sz00Msg[i], 0, sizeof(m_sz00Msg[i]));
  12. // memset(m_sz03Msg[i], 0, sizeof(m_sz03Msg[i]));
  13. m_dwOnlineTick[i] = 0;
  14. m_devOnline[i] = TRUE;
  15. }
  16. }
  17. canatal::~canatal(void)
  18. {
  19. #if IS_USE_READMSG_CS
  20. DeleteCriticalSection(& m_csReadMsg);
  21. #endif
  22. MTVERIFY(CloseHandle(m_hSemComm));
  23. CloseComm();
  24. }
  25. BOOL canatal::OpenCRACComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval)
  26. {
  27. BOOL bResult = FALSE;
  28. //LOG4C((LOG_NOTICE,"->OpenUPSComm"));
  29. bResult = OpenComm( nCommPort, nAddr, nRate, nDataBit, nStopBit, nParity, nInterval );
  30. return bResult;
  31. }
  32. int canatal::GetIniInfo(char *szPath,char *szIniName,char *szCmd,char *IniSendCMD, int &IniSendlen, char *nType,int &nIndex,int &nLen, int &nBit)
  33. {
  34. CHAR szFile[MAX_PATH + 1] = "";
  35. wsprintf(szFile, "%s\\config\\%s", szPath, szIniName);
  36. TRACE("szFile =%s\n",szFile);
  37. IniSendlen = GetPrivateProfileString(szCmd, "SendCmd", "", IniSendCMD, 10, szFile); // 返回的字符串是以\0结束的;
  38. GetPrivateProfileString(szCmd, "type", "", nType, 10, szFile);
  39. nType[strlen(nType)] = '\0';
  40. nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile);
  41. nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile);
  42. nBit = GetPrivateProfileInt(szCmd,"Bit",-1,szFile);
  43. return 0;
  44. }
  45. int canatal::SendReadRequest(
  46. char *szPath,
  47. char *szIniName,
  48. int nCommPort,
  49. int nAddr,
  50. char *szCmd,
  51. char *szMsg,
  52. int nReversed1,
  53. int nReversed2,
  54. int nReversed3,
  55. int nReversed4,
  56. int nReversed5,
  57. float fReversed1,
  58. float fReversed2,
  59. float fReversed3,
  60. char *szReversed1,
  61. char *szReversed2,
  62. char *szReversed3,
  63. char *szReversed4,
  64. char *szReversed5 )
  65. {
  66. //LOG4C((LOG_NOTICE,"->SendReadRequest"));
  67. CCommProcess *pComm = FindComm(nCommPort);
  68. if( pComm == NULL ) return -1;
  69. int nRet(-1);
  70. int nIndex(0), nLen(0), IniSendlen(0),nBit(-1);
  71. char IniSendCMD[MAX_CMD] = {0}, szDataType[CMD_TYPE] = {0};
  72. GetIniInfo(szPath,szIniName,szCmd,IniSendCMD,IniSendlen,szDataType,nIndex,nLen,nBit);
  73. if (
  74. (strlen(m_sz00Msg[nAddr -1]) == 0 &&
  75. (
  76. strcmp(szCmd, "cmd-1") ==0 || strcmp(szCmd, "cmd-2") ==0 || strcmp(szCmd, "cmd-3") ==0 ||
  77. strcmp(szCmd, "cmd-4") ==0 || strcmp(szCmd, "cmd-5") ==0 || strcmp(szCmd, "cmd-6") ==0 ||
  78. strcmp(szCmd, "cmd-7") ==0 || strcmp(szCmd, "cmd-8") ==0 || strcmp(szCmd, "cmd-9") ==0 ||
  79. strcmp(szCmd, "cmd-10") ==0 || strcmp(szCmd, "cmd-11") ==0 || strcmp(szCmd, "cmd-12") ==0 ||
  80. strcmp(szCmd, "cmd-13") ==0 || strcmp(szCmd, "cmd-14") ==0 || strcmp(szCmd, "cmd-15") ==0 ||
  81. strcmp(szCmd, "cmd-16") ==0 || strcmp(szCmd, "cmd-17") ==0 || strcmp(szCmd, "cmd-18") ==0 ||
  82. strcmp(szCmd, "cmd-19") ==0 || strcmp(szCmd, "cmd-20") ==0 || strcmp(szCmd, "cmd-21") ==0 ||
  83. strcmp(szCmd, "cmd-22") ==0 || strcmp(szCmd, "cmd-23") ==0 || strcmp(szCmd, "cmd-24") ==0 ||
  84. strcmp(szCmd, "cmd-25") ==0 || strcmp(szCmd, "cmd-26") ==0
  85. ) )|| strcmp(szCmd, "cmd-1") == 0
  86. )
  87. {
  88. nRet = GetDeviceParam(nAddr ,pComm, IniSendCMD,IniSendlen, szCmd );
  89. if( nRet != 0 )
  90. return nRet;
  91. }
  92. if( GetTickCount() - m_dwOnlineTick[nAddr -1] > 60 * 1000 && m_dwOnlineTick[nAddr -1] > 0 ) {
  93. m_devOnline[nAddr -1] = FALSE;
  94. }
  95. else if( GetTickCount() - m_dwOnlineTick[nAddr -1] < 60 * 1000 && m_dwOnlineTick[nAddr -1] > 0 ) {
  96. m_devOnline[nAddr -1] = TRUE;
  97. }
  98. if( m_devOnline[nAddr -1] == FALSE ) {
  99. return -1;
  100. }
  101. nRet = Get_00Msg(nAddr, szCmd, szMsg, nIndex, nLen, nBit,szDataType);
  102. //nRet = Get_03Msg(nAddr, szCmd, szMsg, nIndex, nLen, szDataType);
  103. LOG4C((LOG_NOTICE,"nRet = %d,cmd = %s,值 = %s",nRet,szCmd,szMsg));
  104. return nRet;
  105. }
  106. // 发送写设置;
  107. int canatal::SendSetReuest(
  108. char *szPath,
  109. char *szIniName,
  110. int nCommPort,
  111. int nAddr,
  112. char *szCmd,
  113. char *szMsg,
  114. int nReversed1,
  115. int nReversed2,
  116. int nReversed3,
  117. int nReversed4,
  118. int nReversed5,
  119. float fReversed1,
  120. float fReversed2,
  121. float fReversed3,
  122. char *szReversed1,
  123. char *szReversed2,
  124. char *szReversed3,
  125. char *szReversed4,
  126. char *szReversed5
  127. )
  128. {
  129. CCommProcess *pComm = FindComm(nCommPort);
  130. if( pComm == NULL ) return -1;
  131. int nRet(-1);
  132. int nIndex(0), nLen(0), IniSendlen(0),nBit(-1);
  133. char IniSendCMD[MAX_CMD] = {0}, szDataType[CMD_TYPE] = {0};
  134. GetIniInfo(szPath,szIniName,szCmd,IniSendCMD,IniSendlen,szDataType,nIndex,nLen,nBit);
  135. if ( strcmp(szCmd, "cmd-27") ==0 )
  136. {
  137. BYTE szSendMSG[32] = {0};
  138. // 对数组进行赋值;
  139. szSendMSG[0] = 0x55;
  140. szSendMSG[1] = 0x67;
  141. szSendMSG[2] = 0x89;
  142. szSendMSG[3] = 0xAB;
  143. szSendMSG[4] = 0xCD;
  144. szSendMSG[5] = 0xEF;
  145. szSendMSG[6] = 0x12;
  146. szSendMSG[7] = 0x34;
  147. szSendMSG[8] = nAddr;
  148. //szSendMSG[9] = atoi(IniSendCMD);
  149. szSendMSG[9] = 0x03;
  150. int iCrc = RtnCheck( szSendMSG, 10 );
  151. szSendMSG[10] = iCrc>>8&0xff; // 高字节;
  152. szSendMSG[11] = iCrc&0xff; // 低字节;
  153. int iLen = 12;
  154. if (WaitForSingleObject(m_hSemComm,0) == WAIT_OBJECT_0 )
  155. {
  156. ResetEvent(m_hSemComm);
  157. int nResult = pComm->Write(szSendMSG, iLen);
  158. if (nResult != iLen)
  159. {
  160. SetEvent(m_hSemComm);
  161. return EER_CODE_COM_REGNUM;
  162. }
  163. }
  164. else
  165. {
  166. return ERR_CODE_COM_BUSY;
  167. }
  168. int nProcessLen(0),nReadLen(0);
  169. char *pBuff = new char[MAX_RECE_MSG];
  170. memset(pBuff, 0 , MAX_RECE_MSG);
  171. nReadLen = pComm->Read((BYTE *)pBuff,MAX_RECE_MSG);
  172. SetEvent(m_hSemComm);
  173. if( pBuff != NULL)
  174. {
  175. delete[] pBuff;
  176. pBuff = NULL;
  177. }
  178. }
  179. return nRet;
  180. }
  181. int canatal::GetDeviceParam(int naddr, CCommProcess *pComm,char *IniSendCMD,const int &IniSendlen ,char *szCmd)
  182. {
  183. int nRet(-1);
  184. nRet = Send_ReadDeviceData(naddr, pComm, IniSendCMD, IniSendlen);
  185. if( nRet != 0 ) {
  186. return nRet;
  187. }
  188. nRet = Recv_ReadDeviceData(naddr, pComm, szCmd);
  189. return nRet;
  190. }
  191. int canatal::Send_ReadDeviceData(int nAddr,CCommProcess *pComm,const char *IniSendCMD,const int &IniSendlen)
  192. {
  193. #if DEBUG_CANATAL13
  194. BYTE szSendMSG[32] = {0};
  195. // 对数组进行赋值;
  196. szSendMSG[0] = 0x55;
  197. szSendMSG[1] = 0x67;
  198. szSendMSG[2] = 0x89;
  199. szSendMSG[3] = 0xAB;
  200. szSendMSG[4] = 0xCD;
  201. szSendMSG[5] = 0xEF;
  202. szSendMSG[6] = 0x12;
  203. szSendMSG[7] = 0x34;
  204. szSendMSG[8] = nAddr;
  205. szSendMSG[9] = atoi(IniSendCMD);
  206. int iCrc = RtnCheck( szSendMSG, 10 );
  207. szSendMSG[10] = iCrc>>8&0xff; // 高字节;
  208. szSendMSG[11] = iCrc&0xff; // 低字节;
  209. int iLen = 12;
  210. if (WaitForSingleObject(m_hSemComm,0) == WAIT_OBJECT_0 ) {
  211. ResetEvent(m_hSemComm);
  212. int nResult = pComm->Write(szSendMSG, iLen);
  213. if (nResult != iLen){
  214. SetEvent(m_hSemComm);
  215. return EER_CODE_COM_REGNUM;
  216. }
  217. }
  218. else{
  219. return ERR_CODE_COM_BUSY;
  220. }
  221. #endif
  222. return 0;
  223. }
  224. int canatal::Recv_ReadDeviceData(int nAddr,CCommProcess *pComm,char *szCmd)
  225. {
  226. #if DEBUG_CANATAL13
  227. int nProcessLen(0),nReadLen(0);
  228. char *pBuff = new char[MAX_RECE_MSG];
  229. memset(pBuff, 0 , MAX_RECE_MSG);
  230. nReadLen = pComm->Read((BYTE *)pBuff,MAX_RECE_MSG);
  231. // 对返回的数据进行CRC校验;(不作校验)
  232. //int iCrc = RtnCheck((BYTE *)pBuff, nReadLen-2);
  233. //BYTE Hby = iCrc>>8&0xff; // 高字节;
  234. //BYTE Lby = iCrc&0xff; // 低字节;
  235. //if (iCrc != 0)
  236. //{
  237. // SetEvent( m_hSemComm );
  238. // if( pBuff != NULL)
  239. // {
  240. // delete[] pBuff;
  241. // pBuff = NULL;
  242. // }
  243. // LOG4C((LOG_NOTICE,"->RTN校验出错:%d",nRet));
  244. // return -1; //RTN校验出错
  245. //}
  246. //if (nReadLen != 23){
  247. if (nReadLen < 0){
  248. SetEvent(m_hSemComm);
  249. if (pBuff != NULL) {
  250. delete [] pBuff;
  251. pBuff = NULL;
  252. }
  253. LOG4C((LOG_NOTICE,"->串口没有读到数据"));
  254. return ERR_CODE_COM_READ_NO_DATA;
  255. } //长度校验出错 ;
  256. Copy_00_Msg(nAddr, szCmd, pBuff);
  257. m_dwOnlineTick[nAddr -1] = GetTickCount();
  258. SetEvent( m_hSemComm );
  259. if( pBuff != NULL) {
  260. delete[] pBuff;
  261. pBuff = NULL;
  262. }
  263. #else
  264. SimulationCommData(nAddr);
  265. #endif
  266. return 0;
  267. }
  268. void canatal::Copy_00_Msg( int nAddr, char *szCmd, char *pBuffer)
  269. {
  270. if (
  271. strcmp(szCmd, "cmd-1") ==0 || strcmp(szCmd, "cmd-2") ==0 || strcmp(szCmd, "cmd-3") ==0 ||
  272. strcmp(szCmd, "cmd-4") ==0 || strcmp(szCmd, "cmd-5") ==0 || strcmp(szCmd, "cmd-6") ==0 ||
  273. strcmp(szCmd, "cmd-7") ==0 || strcmp(szCmd, "cmd-8") ==0 || strcmp(szCmd, "cmd-9") ==0 ||
  274. strcmp(szCmd, "cmd-10") ==0 || strcmp(szCmd, "cmd-11") ==0 || strcmp(szCmd, "cmd-12") ==0 ||
  275. strcmp(szCmd, "cmd-13") ==0 || strcmp(szCmd, "cmd-14") ==0 || strcmp(szCmd, "cmd-15") ==0 ||
  276. strcmp(szCmd, "cmd-16") ==0 || strcmp(szCmd, "cmd-17") ==0 || strcmp(szCmd, "cmd-18") ==0 ||
  277. strcmp(szCmd, "cmd-19") ==0 || strcmp(szCmd, "cmd-20") ==0 || strcmp(szCmd, "cmd-21") ==0 ||
  278. strcmp(szCmd, "cmd-22") ==0 || strcmp(szCmd, "cmd-23") ==0 || strcmp(szCmd, "cmd-24") ==0 ||
  279. strcmp(szCmd, "cmd-25") ==0 || strcmp(szCmd, "cmd-26") ==0
  280. )
  281. {
  282. #if IS_USE_READMSG_CS
  283. EnterCriticalSection(&m_csReadMsg);
  284. #endif
  285. memcpy(m_sz00Msg[nAddr -1], pBuffer, sizeof(m_sz00Msg[nAddr -1]));
  286. #if IS_USE_READMSG_CS
  287. LeaveCriticalSection(&m_csReadMsg);
  288. #endif
  289. }
  290. }
  291. //void canatal::Copy_03_Msg( int nAddr, char *szCmd, char *pBuffer)
  292. //{
  293. // if (
  294. // strcmp(szCmd, "cmd-16") ==0 || strcmp(szCmd, "cmd-17") ==0 || strcmp(szCmd, "cmd-18") ==0 ||
  295. // strcmp(szCmd, "cmd-19") ==0 || strcmp(szCmd, "cmd-20") ==0 || strcmp(szCmd, "cmd-21") ==0 ||
  296. // strcmp(szCmd, "cmd-22") ==0 || strcmp(szCmd, "cmd-23") ==0 || strcmp(szCmd, "cmd-24") ==0 ||
  297. // strcmp(szCmd, "cmd-25") ==0 || strcmp(szCmd, "cmd-26") ==0 || strcmp(szCmd, "cmd-27") ==0 ||
  298. // strcmp(szCmd, "cmd-28") ==0 || strcmp(szCmd, "cmd-29") ==0 || strcmp(szCmd, "cmd-30") ==0 ||
  299. // strcmp(szCmd, "cmd-31") ==0
  300. // )
  301. // {
  302. //#if IS_USE_READMSG_CS
  303. // EnterCriticalSection(&m_csReadMsg);
  304. //#endif
  305. // memcpy(m_sz03Msg[nAddr -1], pBuffer, sizeof(m_sz03Msg[nAddr -1]));
  306. //#if IS_USE_READMSG_CS
  307. // LeaveCriticalSection(&m_csReadMsg);
  308. //#endif
  309. // }
  310. //}
  311. int canatal::Get_00Msg(int nAddr, char *szCmd, char *szMsg, int &nIndex, int &nLen, int &nBit,char *szType )
  312. {
  313. int nRet(0);
  314. if (strcmp(szCmd, "cmd-1") ==0 || strcmp(szCmd, "cmd-2") ==0 || strcmp(szCmd, "cmd-3") ==0 ||
  315. strcmp(szCmd, "cmd-4") ==0 || strcmp(szCmd, "cmd-5") ==0 || strcmp(szCmd, "cmd-6") ==0 ||
  316. strcmp(szCmd, "cmd-7") ==0 || strcmp(szCmd, "cmd-8") ==0 || strcmp(szCmd, "cmd-9") ==0 ||
  317. strcmp(szCmd, "cmd-10") ==0 || strcmp(szCmd, "cmd-11") ==0 || strcmp(szCmd, "cmd-12") ==0 ||
  318. strcmp(szCmd, "cmd-13") ==0 || strcmp(szCmd, "cmd-14") ==0 || strcmp(szCmd, "cmd-15") ==0 ||
  319. strcmp(szCmd, "cmd-16") ==0 || strcmp(szCmd, "cmd-17") ==0 || strcmp(szCmd, "cmd-18") ==0 ||
  320. strcmp(szCmd, "cmd-19") ==0 || strcmp(szCmd, "cmd-20") ==0 || strcmp(szCmd, "cmd-21") ==0 ||
  321. strcmp(szCmd, "cmd-22") ==0 || strcmp(szCmd, "cmd-23") ==0 || strcmp(szCmd, "cmd-24") ==0 ||
  322. strcmp(szCmd, "cmd-25") ==0 || strcmp(szCmd, "cmd-26") ==0
  323. )
  324. {
  325. #if IS_USE_READMSG_CS
  326. EnterCriticalSection(&m_csReadMsg);
  327. #endif
  328. if ( nBit == -1)
  329. DataConversion(szType, m_sz00Msg[nAddr -1] + nIndex, szMsg, nLen);
  330. else
  331. BitDataProcess(m_sz00Msg[nAddr -1] + nIndex, szMsg, nLen, nBit);
  332. #if IS_USE_READMSG_CS
  333. LeaveCriticalSection(&m_csReadMsg);
  334. #endif
  335. nRet = 0;
  336. }
  337. return nRet;
  338. }
  339. //int canatal::Get_03Msg(int nAddr, char *szCmd, char *szMsg, int &nIndex, int &nLen, int &nBit,char *szType )
  340. //{
  341. // int nRet(0);
  342. // if (strcmp(szCmd, "cmd-16") ==0 || strcmp(szCmd, "cmd-17") ==0 || strcmp(szCmd, "cmd-18") ==0 ||
  343. // strcmp(szCmd, "cmd-19") ==0 || strcmp(szCmd, "cmd-20") ==0 || strcmp(szCmd, "cmd-21") ==0 ||
  344. // strcmp(szCmd, "cmd-22") ==0 || strcmp(szCmd, "cmd-23") ==0 || strcmp(szCmd, "cmd-24") ==0 ||
  345. // strcmp(szCmd, "cmd-25") ==0 || strcmp(szCmd, "cmd-26") ==0 || strcmp(szCmd, "cmd-27") ==0 ||
  346. // strcmp(szCmd, "cmd-28") ==0 || strcmp(szCmd, "cmd-29") ==0 || strcmp(szCmd, "cmd-30") ==0 ||
  347. // strcmp(szCmd, "cmd-31") ==0 )
  348. // {
  349. //#if IS_USE_READMSG_CS
  350. // EnterCriticalSection(&m_csReadMsg);
  351. //#endif
  352. // DataConversion(szType, m_sz03Msg[nAddr -1] + nIndex, szMsg, nLen);
  353. //#if IS_USE_READMSG_CS
  354. // LeaveCriticalSection(&m_csReadMsg);
  355. //#endif
  356. // nRet = 0;
  357. // }
  358. // return nRet;
  359. //}
  360. UINT canatal::RtnCheck(BYTE *pBuf,int len)
  361. {
  362. unsigned int Genpoly=0xA001;
  363. unsigned int CRC=0xFFFF;
  364. unsigned int index;
  365. while(len--)
  366. {
  367. CRC=CRC^(unsigned int)*pBuf++;
  368. for(index=0;index<8;index++)
  369. {
  370. if((CRC & 0x0001)==1) CRC=(CRC>>1)^Genpoly;
  371. else (CRC=CRC>>1);
  372. }
  373. }
  374. return(CRC);
  375. }
  376. void canatal::BitDataProcess(const char *szSour, char *szRecv, int &iSourLen,int &StaBit)
  377. {
  378. CString strBit = ""; // 存放位串字符;
  379. int ByteBit = 0;
  380. char *tmp_Sour = new char[iSourLen+1];
  381. memcpy(tmp_Sour,szSour,iSourLen);
  382. if ( iSourLen == 1)
  383. {
  384. int sum = tmp_Sour[0];
  385. switch(StaBit) // switch(7 - StaBit);
  386. {
  387. case 7:
  388. ByteBit = sum & 0x01;
  389. break;
  390. case 6:
  391. ByteBit = (sum & 0x02) / 0x02 ;
  392. break;
  393. case 5:
  394. ByteBit = (sum & 0x04) / 0x04 ;
  395. break;
  396. case 4:
  397. ByteBit = (sum & 0x08) / 0x08 ;
  398. break;
  399. case 3:
  400. ByteBit = (sum & 0x10) / 0x10 ;
  401. break;
  402. case 2:
  403. ByteBit = (sum & 0x20) / 0x20 ;
  404. break;
  405. case 1:
  406. ByteBit = (sum & 0x40) / 0x40 ;
  407. break;
  408. case 0:
  409. ByteBit = (sum & 0x80) / 0x80;
  410. break;
  411. }
  412. itoa(ByteBit,szRecv,10);
  413. }
  414. else
  415. {
  416. for (int i = 0; i < iSourLen; i+=2)
  417. {
  418. char szDest[9] = {0}; // 目标数据;
  419. int sum = (AsciiToBYTE(tmp_Sour[i]))*16 + AsciiToBYTE(tmp_Sour[i+1]);
  420. for(int j = 0; j < 8; j ++)
  421. {
  422. switch(j)
  423. {
  424. case 7:
  425. ByteBit = sum & 0x01;
  426. break;
  427. case 6:
  428. ByteBit = (sum & 0x02) / 0x02 ;
  429. break;
  430. case 5:
  431. ByteBit = (sum & 0x04) / 0x04 ;
  432. break;
  433. case 4:
  434. ByteBit = (sum & 0x08) / 0x08 ;
  435. break;
  436. case 3:
  437. ByteBit = (sum & 0x10) / 0x10 ;
  438. break;
  439. case 2:
  440. ByteBit = (sum & 0x20) / 0x20 ;
  441. break;
  442. case 1:
  443. ByteBit = (sum & 0x40) / 0x40 ;
  444. break;
  445. case 0:
  446. ByteBit = (sum & 0x80) / 0x80;
  447. break;
  448. }
  449. szDest[j] = ByteBit + 48;
  450. }
  451. strBit += szDest;
  452. }
  453. strBit = strBit.MakeReverse();
  454. szRecv[0] = strBit.GetAt(StaBit);
  455. }
  456. if (tmp_Sour != NULL)
  457. {
  458. delete[] tmp_Sour;
  459. tmp_Sour = NULL;
  460. }
  461. }
  462. void canatal::SimulationCommData(int nAddr)
  463. {
  464. //~10012A0020680033335F439A1963439A99644366665C4333335A4333335D433333B33F0000C03FCDCC8C3F33B3DA43CDCC474200000033B3DA43E71D.
  465. memcpy(m_sz00Msg[nAddr -1], "~10012A0020680033335F439A1963439A99644366665C4333335A4333335D433333B33F0000C03FCDCC8C3F33B3DA43CDCC474200000033B3DA43E71D.", sizeof("~10012A0020680033335F439A1963439A99644366665C4333335A4333335D433333B33F0000C03FCDCC8C3F33B3DA43CDCC474200000033B3DA43E71D."));
  466. //~10012A00307600000E66A6C2439A19C5439A59C3436666663FCDCC4C3F0000803FC3F547423333333FA4703D3F1F852B3F9A995F43CD4C614333B35E4348E14742E3B1.
  467. // memcpy(m_sz03Msg[nAddr -1], "~10012A00307600000E66A6C2439A19C5439A59C3436666663FCDCC4C3F0000803FC3F547423333333FA4703D3F1F852B3F9A995F43CD4C614333B35E4348E14742E3B1.", sizeof("~10012A00307600000E66A6C2439A19C5439A59C3436666663FCDCC4C3F0000803FC3F547423333333FA4703D3F1F852B3F9A995F43CD4C614333B35E4348E14742E3B1."));
  468. }
  469. /////////