Bagkee.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. /*************************************************
  2. /* Copyright (C), 2010-2011,StoneU. Co., Ltd.
  3. /* File name: Bagkee.cpp
  4. /* Author: Zero.t
  5. /* Version: Ver1.0.0.1
  6. /* Date: 2011-8-18
  7. /* Description: 柏克B系列UPS,具体型号未知;本类首次使用在项目广东 顺德锦丽;
  8. /* Others: UPS协议类,不做控制设备操作;
  9. /* Function List: ###
  10. /* History:
  11. 1.Date: ###
  12. Author: ###
  13. Modification: ###
  14. *************************************************/
  15. #include "StdAfx.h"
  16. #include "CommProcess.h"
  17. #include ".\bagkee.h"
  18. CBagkee::CBagkee(
  19. char szPath[MAX_PATH],
  20. char szIniName[MAX_PATH],
  21. int nCommPort, int nAddr,
  22. int nRate, int nDataBit,
  23. int nStopBit, int nParity,
  24. int nInterval
  25. )
  26. {
  27. #if IS_USE_READMSG_CS
  28. InitializeCriticalSection(&m_csReadMsg);
  29. #endif
  30. MTVERIFY(m_hSemComm = CreateEvent(NULL, TRUE, TRUE, 0));
  31. memset(m_szG1Msg, 0, sizeof(m_szG1Msg));
  32. memset(m_szG2Msg, 0, sizeof(m_szG2Msg));
  33. memset(m_szG3Msg, 0, sizeof(m_szG3Msg));
  34. memset(m_szQ1Msg, 0, sizeof(m_szQ1Msg));
  35. m_dwOnlineTick = 0;
  36. m_devOnline = TRUE;
  37. }
  38. CBagkee::~CBagkee()
  39. {
  40. #if IS_USE_READMSG_CS
  41. DeleteCriticalSection(& m_csReadMsg);
  42. #endif
  43. MTVERIFY(CloseHandle(m_hSemComm));
  44. CloseComm();
  45. }
  46. BOOL CBagkee::BagkeeOpenComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval)
  47. {
  48. //LOG4C((LOG_NOTICE,"打开串口"));
  49. BOOL bResult = FALSE;
  50. bResult = OpenComm( nCommPort, nAddr, nRate, nDataBit, nStopBit, nParity, nInterval );
  51. return bResult;
  52. }
  53. int CBagkee::SendReadRequest(
  54. char szPath[MAX_PATH],
  55. char szIniName[MAX_PATH],
  56. int nCommPort,
  57. int nAddr,
  58. char szCmd[MAX_CMD],
  59. char szMsg[VAR_MSG],
  60. int nReversed1,
  61. int nReversed2,
  62. int nReversed3,
  63. int nReversed4,
  64. int nReversed5,
  65. float fReversed1,
  66. float fReversed2,
  67. float fReversed3,
  68. char szReversed1[MAX_RESERVED1],
  69. char szReversed2[MAX_RESERVED2],
  70. char szReversed3[MAX_RESERVED3],
  71. char szReversed4[MAX_RESERVED4],
  72. char szReversed5[MAX_RESERVED5]
  73. )
  74. {
  75. //LOG4C((LOG_NOTICE,"读到设备数据"));
  76. int nIndex = 0, nLen = 0;
  77. char szSendMsg[UPS_SANTAK_SEND_MSG] = {0};
  78. char szType[CMD_TYPE] = {0};
  79. m_address = nAddr;
  80. GetParFromIni(szPath, szIniName, szCmd, szSendMsg, szType, nIndex, nLen);
  81. CCommProcess *pComm = FindComm(nCommPort);
  82. if( pComm == NULL ) return -1;
  83. int nRet = -1;
  84. if(
  85. ( strlen(m_szG1Msg) == 0 && (
  86. strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-2") == 0 || strcmp(szCmd,"cmd-3") == 0 ||
  87. strcmp(szCmd,"cmd-4") == 0 || strcmp(szCmd,"cmd-6") == 0 || strcmp(szCmd,"cmd-5") == 0 ||
  88. strcmp(szCmd,"cmd-7") == 0 || strcmp(szCmd,"cmd-8") == 0
  89. ))||
  90. (strlen(m_szG2Msg) == 0 &&(
  91. strcmp(szCmd,"cmd-9") == 0 || strcmp(szCmd,"cmd-10") == 0 || strcmp(szCmd,"cmd-11") == 0 ||
  92. strcmp(szCmd,"cmd-12") == 0 || strcmp(szCmd,"cmd-13") == 0 || strcmp(szCmd,"cmd-14") == 0 ||
  93. strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-16") == 0 || strcmp(szCmd,"cmd-17") == 0 ||
  94. strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 ||
  95. strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 ||
  96. strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0
  97. ))||
  98. (strlen(m_szG3Msg) == 0 &&(
  99. strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 ||
  100. strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 ||
  101. strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 ||
  102. strcmp(szCmd,"cmd-36") == 0 || strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0
  103. ))||
  104. (strlen(m_szQ1Msg) == 0 && (
  105. strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 ||
  106. strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 ||
  107. strcmp(szCmd,"cmd-45") == 0 || strcmp(szCmd,"cmd-46") == 0 || strcmp(szCmd,"cmd-47") == 0 ||
  108. strcmp(szCmd,"cmd-48") == 0 || strcmp(szCmd,"cmd-49") == 0 || strcmp(szCmd,"cmd-50") == 0 ||
  109. strcmp(szCmd,"cmd-51") == 0
  110. ))||
  111. strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd, "cmd-9") == 0 || strcmp(szCmd,"cmd-27") == 0 ||
  112. strcmp(szCmd,"cmd-39") == 0
  113. )
  114. {
  115. nRet = GetDeviceParam(nAddr, pComm, szSendMsg, szCmd, szMsg, nIndex, nLen, szType );
  116. if( nRet != 0 )
  117. return nRet;
  118. }
  119. if( GetTickCount() - m_dwOnlineTick > 60 * 1000 && m_dwOnlineTick > 0 )
  120. {
  121. m_devOnline = FALSE;
  122. }
  123. else if( GetTickCount() - m_dwOnlineTick < 60 * 1000 && m_dwOnlineTick > 0 )
  124. {
  125. m_devOnline = TRUE;
  126. }
  127. if( m_devOnline == FALSE )
  128. {
  129. return -1;
  130. }
  131. nRet = GetBagkeeG1Msg(szCmd, szMsg, nIndex, nLen, szType);
  132. nRet = GetBagkeeG2Msg(szCmd, szMsg, nIndex, nLen, szType);
  133. nRet = GetBagkeeG3Msg(szCmd, szMsg, nIndex, nLen, szType);
  134. nRet = GetBagkeeQ1Msg(szCmd, szMsg, nIndex, nLen, szType);
  135. //LOG4C_HEX_DUMP((LOG_NOTICE, szMsg, sizeof(szMsg)));
  136. //LOG4C((LOG_NOTICE, "%s=%d, sizeof = %d, return %d", szCmd, atoi(szMsg), sizeof(buf), nRet));
  137. return nRet;
  138. }
  139. int CBagkee::GetDeviceParam(
  140. int nAddr,
  141. CCommProcess *pComm, // 串口对象指针
  142. char szSendMsg[UPS_SANTAK_SEND_MSG], // 发送Buffer
  143. char szCmd[MAX_CMD], // 命令
  144. char szMsg[VAR_MSG], // 接收Buffer
  145. int &nIndex, // 变量索引,针对接收Buffer而言
  146. int &nLen, // 变量长度
  147. char szType[CMD_TYPE] // 变量数据类型
  148. )
  149. {
  150. //LOG4C((LOG_NOTICE,"GetDeviceParam"));
  151. int nRet = -1;
  152. nRet = RequestStatus(nAddr, pComm, szSendMsg);
  153. if( nRet != 0 )
  154. {
  155. return nRet; // 串口忙
  156. }
  157. nRet = ResponseStatus(nAddr, pComm, szCmd, szMsg, nIndex, nLen, szType);
  158. return nRet;
  159. }
  160. int CBagkee::GetParFromIni(
  161. char szPath[MAX_PATH], //服务器程序所在目录
  162. char szIniName[MAX_PATH], //配置文件名
  163. char szCmd[MAX_CMD], //命令
  164. char szSendCmd[MAX_CMD], //发送Buffer
  165. char nType[MAX_CMD],
  166. int &nIndex,
  167. int &nLen
  168. )
  169. {
  170. CHAR szFile[MAX_PATH + 1] = "";
  171. wsprintf(szFile, "%s\\config\\%s", szPath, szIniName);
  172. TRACE("szFile =%s\n",szFile);
  173. GetPrivateProfileString(szCmd, "SendCmd", "", szSendCmd, 10, szFile);
  174. szSendCmd[strlen(szSendCmd)] = 0x0D;
  175. GetPrivateProfileString(szCmd, "type", "", nType, 10, szFile);
  176. nType[strlen(nType)] = '\0';
  177. nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile);
  178. nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile);
  179. //LOG4C((LOG_NOTICE,"SendCmd = %s",szSendCmd));
  180. return 0;
  181. }
  182. int CBagkee::RequestStatus(int nAddr, CCommProcess *pComm,const char chSendMsg[UPS_SANTAK_SEND_MSG] )
  183. {
  184. #if UPS_DEBUG //开关量,用于测试模拟数据
  185. REQUEST_STRUCT structResuest;
  186. int nLen = sizeof(REQUEST_STRUCT);
  187. memset(&structResuest,0,nLen);
  188. memcpy(structResuest.chkSum, chSendMsg, 2);
  189. structResuest.End = 0x0D;
  190. //LOG4C_HEX_DUMP((LOG_NOTICE, chSendMsg, 2));
  191. if (WaitForSingleObject(m_hSemComm,0) == WAIT_OBJECT_0 )
  192. {
  193. int nDatalen = (int)sizeof(structResuest);
  194. ResetEvent(m_hSemComm);
  195. int nResult = pComm->Write((BYTE *)&structResuest, nDatalen);
  196. //LOG4C_HEX_DUMP((LOG_NOTICE, chSendMsg, 3));
  197. //LOG4C((LOG_NOTICE, "CSanTak::RequestStatus chSendMsg = %s, nResult = %d, nDatalen = %d", chSendMsg,nResult, nDatalen));
  198. if (nResult == nDatalen)
  199. {
  200. }
  201. else
  202. {
  203. SetEvent(m_hSemComm);
  204. return EER_CODE_BAGKEE_COM_REGNUM;
  205. }
  206. }
  207. else
  208. {
  209. return ERR_CODE_BAGKEE_COM_BUSY; //串口忙
  210. }
  211. #endif
  212. return 0;
  213. }
  214. int CBagkee::ResponseStatus(
  215. int nAddr,
  216. CCommProcess *pComm,
  217. char szCmd[MAX_CMD],
  218. char szMsg[VAR_MSG],
  219. int &nIndex,
  220. int &nLen,
  221. char szType[CMD_TYPE]
  222. )
  223. {
  224. #if UPS_DEBUG
  225. int nReceiveLen = 0;
  226. int nProcessLen = 0;
  227. int nReadLen = 0;
  228. RESPONSE_STRUCT strcutResponse;
  229. memset(&strcutResponse, 0, sizeof(RESPONSE_STRUCT));
  230. nReceiveLen = sizeof(RESPONSE_STRUCT);
  231. char *pBuff = new char[nReceiveLen];
  232. memset(pBuff, 0 , nReceiveLen);
  233. nReadLen = pComm->Read((BYTE *)pBuff,nReceiveLen);
  234. //LOG4C((LOG_NOTICE, "CSanTak::ResponseStatus pBuff = %s, nReadLen = %d, nReceiveLen = %d", pBuff, nReadLen, nReceiveLen));
  235. if (nReadLen <= 0)
  236. {
  237. SetEvent(m_hSemComm);
  238. if (pBuff != NULL)
  239. {
  240. delete [] pBuff;
  241. pBuff = NULL;
  242. }
  243. return ERR_CODE_BAGKEE_COM_READ_NO_DATA;
  244. }
  245. //长度校验出错
  246. SetBagkeeG1Msg(szCmd, pBuff);
  247. SetBagkeeG2Msg(szCmd, pBuff);
  248. SetBagkeeG3Msg(szCmd, pBuff);
  249. SetBagkeeQ1Msg(szCmd, pBuff);
  250. m_dwOnlineTick = GetTickCount();
  251. // 设置串口等待事件为有信号
  252. SetEvent( m_hSemComm );
  253. if( pBuff != NULL)
  254. {
  255. delete[] pBuff;
  256. pBuff = NULL;
  257. }
  258. #else
  259. SimulationCommData();
  260. #endif
  261. return 0;
  262. }
  263. int CBagkee::GetBagkeeG1Msg(char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[CMD_TYPE] )
  264. {
  265. int nRet = 0;
  266. if (
  267. strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-2") == 0 || strcmp(szCmd,"cmd-3") == 0 ||
  268. strcmp(szCmd,"cmd-4") == 0 || strcmp(szCmd,"cmd-6") == 0 || strcmp(szCmd,"cmd-5") == 0 ||
  269. strcmp(szCmd,"cmd-7") == 0 || strcmp(szCmd,"cmd-8") == 0
  270. )
  271. {
  272. #if IS_USE_READMSG_CS
  273. EnterCriticalSection(&m_csReadMsg);
  274. #endif
  275. DataConversion(szType, m_szG1Msg + nIndex, szMsg, nLen);
  276. #if IS_USE_READMSG_CS
  277. LeaveCriticalSection(&m_csReadMsg);
  278. #endif
  279. nRet = 0;
  280. }
  281. return nRet;
  282. }
  283. int CBagkee::GetBagkeeG2Msg(char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[CMD_TYPE] )
  284. {
  285. int nRet = 0;
  286. if (
  287. strcmp(szCmd,"cmd-9") == 0 || strcmp(szCmd,"cmd-10") == 0 || strcmp(szCmd,"cmd-11") == 0 ||
  288. strcmp(szCmd,"cmd-12") == 0 || strcmp(szCmd,"cmd-13") == 0 || strcmp(szCmd,"cmd-14") == 0 ||
  289. strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-16") == 0 || strcmp(szCmd,"cmd-17") == 0 ||
  290. strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 ||
  291. strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 ||
  292. strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0
  293. )
  294. {
  295. #if IS_USE_READMSG_CS
  296. EnterCriticalSection(&m_csReadMsg);
  297. #endif
  298. DataConversion(szType, m_szG2Msg + nIndex, szMsg, nLen);
  299. #if IS_USE_READMSG_CS
  300. LeaveCriticalSection(&m_csReadMsg);
  301. #endif
  302. nRet = 0;
  303. }
  304. return nRet;
  305. }
  306. int CBagkee::GetBagkeeG3Msg(char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[CMD_TYPE] )
  307. {
  308. int nRet = 0;
  309. if (
  310. strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 ||
  311. strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 ||
  312. strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 ||
  313. strcmp(szCmd,"cmd-36") == 0 || strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0
  314. )
  315. {
  316. #if IS_USE_READMSG_CS
  317. EnterCriticalSection(&m_csReadMsg);
  318. #endif
  319. DataConversion(szType, m_szG3Msg + nIndex, szMsg, nLen);
  320. #if IS_USE_READMSG_CS
  321. LeaveCriticalSection(&m_csReadMsg);
  322. #endif
  323. nRet = 0;
  324. }
  325. return nRet;
  326. }
  327. int CBagkee::GetBagkeeQ1Msg(char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[CMD_TYPE] )
  328. {
  329. int nRet = 0;
  330. if (
  331. strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 ||
  332. strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 ||
  333. strcmp(szCmd,"cmd-45") == 0 || strcmp(szCmd,"cmd-46") == 0 || strcmp(szCmd,"cmd-47") == 0 ||
  334. strcmp(szCmd,"cmd-48") == 0 || strcmp(szCmd,"cmd-49") == 0 || strcmp(szCmd,"cmd-50") == 0 ||
  335. strcmp(szCmd,"cmd-51") == 0
  336. )
  337. {
  338. #if IS_USE_READMSG_CS
  339. EnterCriticalSection(&m_csReadMsg);
  340. #endif
  341. DataConversion(szType, m_szQ1Msg + nIndex, szMsg, nLen);
  342. #if IS_USE_READMSG_CS
  343. LeaveCriticalSection(&m_csReadMsg);
  344. #endif
  345. nRet = 0;
  346. }
  347. return nRet;
  348. }
  349. void CBagkee::SetBagkeeG1Msg(char szCmd[MAX_CMD], char *pBuff)
  350. {
  351. if (
  352. strcmp(szCmd,"cmd-1") == 0 || strcmp(szCmd,"cmd-2") == 0 || strcmp(szCmd,"cmd-3") == 0 ||
  353. strcmp(szCmd,"cmd-4") == 0 || strcmp(szCmd,"cmd-6") == 0 || strcmp(szCmd,"cmd-5") == 0 ||
  354. strcmp(szCmd,"cmd-7") == 0 || strcmp(szCmd,"cmd-8") == 0
  355. )
  356. {
  357. #if IS_USE_READMSG_CS
  358. EnterCriticalSection(&m_csReadMsg);
  359. #endif
  360. memcpy(m_szG1Msg, pBuff, sizeof(m_szG1Msg));
  361. #if IS_USE_READMSG_CS
  362. LeaveCriticalSection(&m_csReadMsg);
  363. #endif
  364. }
  365. }
  366. void CBagkee::SetBagkeeG2Msg(char szCmd[MAX_CMD], char *pBuff)
  367. {
  368. if (
  369. strcmp(szCmd,"cmd-9") == 0 || strcmp(szCmd,"cmd-10") == 0 || strcmp(szCmd,"cmd-11") == 0 ||
  370. strcmp(szCmd,"cmd-12") == 0 || strcmp(szCmd,"cmd-13") == 0 || strcmp(szCmd,"cmd-14") == 0 ||
  371. strcmp(szCmd,"cmd-15") == 0 || strcmp(szCmd,"cmd-16") == 0 || strcmp(szCmd,"cmd-17") == 0 ||
  372. strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 ||
  373. strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 ||
  374. strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0
  375. )
  376. {
  377. #if IS_USE_READMSG_CS
  378. EnterCriticalSection(&m_csReadMsg);
  379. #endif
  380. memcpy(m_szG2Msg, pBuff, sizeof(m_szG2Msg));
  381. #if IS_USE_READMSG_CS
  382. LeaveCriticalSection(&m_csReadMsg);
  383. #endif
  384. }
  385. }
  386. void CBagkee::SetBagkeeG3Msg(char szCmd[MAX_CMD], char *pBuff)
  387. {
  388. if (
  389. strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 ||
  390. strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 ||
  391. strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 ||
  392. strcmp(szCmd,"cmd-36") == 0 || strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0
  393. )
  394. {
  395. #if IS_USE_READMSG_CS
  396. EnterCriticalSection(&m_csReadMsg);
  397. #endif
  398. memcpy(m_szG3Msg, pBuff, sizeof(m_szG3Msg));
  399. #if IS_USE_READMSG_CS
  400. LeaveCriticalSection(&m_csReadMsg);
  401. #endif
  402. }
  403. }
  404. void CBagkee::SetBagkeeQ1Msg(char szCmd[MAX_CMD], char *pBuff)
  405. {
  406. if (
  407. strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 ||
  408. strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 ||
  409. strcmp(szCmd,"cmd-45") == 0 || strcmp(szCmd,"cmd-46") == 0 || strcmp(szCmd,"cmd-47") == 0 ||
  410. strcmp(szCmd,"cmd-48") == 0 || strcmp(szCmd,"cmd-49") == 0 || strcmp(szCmd,"cmd-50") == 0 ||
  411. strcmp(szCmd,"cmd-51") == 0
  412. )
  413. {
  414. #if IS_USE_READMSG_CS
  415. EnterCriticalSection(&m_csReadMsg);
  416. #endif
  417. memcpy(m_szQ1Msg, pBuff, sizeof(m_szQ1Msg));
  418. #if IS_USE_READMSG_CS
  419. LeaveCriticalSection(&m_csReadMsg);
  420. #endif
  421. }
  422. }
  423. void CBagkee::SimulationCommData(void)
  424. {
  425. memcpy(m_szG1Msg, "!407 100 0000 000.0 +34.0 51.1 51.1 50.8", sizeof("!407 100 0000 000.0 +34.0 51.1 51.1 50.8"));
  426. memcpy(m_szG2Msg, "!00000001 00000111 00000000", sizeof("!00000001 00000111 00000000"));
  427. memcpy(m_szG3Msg, "!221.0/225.1/219.3 221.0/225.1/219.3 219.4/218.7/218.7 001.0/001.0/006.0", sizeof("!221.0/225.1/219.3 221.0/225.1/219.3 219.4/218.7/218.7 001.0/001.0/006.0"));
  428. memcpy(m_szQ1Msg, "(224.4 000.0 219.2 001 51.2 2.28 33.0 00000000", sizeof("(224.4 000.0 219.2 001 51.2 2.28 33.0 00000000"));
  429. }