M84c5z.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. // DataMate3000.cpp: implementation of the CDataMate3000 class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "M84c5z.h"
  6. #include "CommProcess.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. CM84c5z::CM84c5z( char szPath[MAX_PATH], // 程序所在路径
  16. char szIniName[MAX_PATH], // 配置文件名称
  17. int nCommPort, // 串行端口
  18. int nAddr, // 设备地址
  19. int nRate, // 波特率
  20. int nDataBit, // 数据位
  21. int nStopBit, // 停止位
  22. int nParity, // 校验位
  23. int nInterval // 时间间隔
  24. )
  25. {
  26. #if IS_USE_READMSG_CS
  27. InitializeCriticalSection( &m_csReadMsg ); //初始化一个临界资源对象
  28. #endif
  29. MTVERIFY( m_hSemComm = CreateEvent( NULL, TRUE, TRUE, 0 ) ); //创建或打开一个命名的或无名的事件对象
  30. for( int i = 0; i < MAX_ADDR; i++ )
  31. {
  32. memset(m_szMz_41Msg[i], 0, sizeof(m_szMz_41Msg[i]));
  33. memset(m_szMz_43Msg[i], 0, sizeof(m_szMz_43Msg[i]));
  34. memset(m_szMz_44Msg[i], 0, sizeof(m_szMz_44Msg[i]));
  35. m_devOnline[i] = TRUE;
  36. m_dwOnlineTick[i] = 0;
  37. }
  38. }
  39. CM84c5z::~CM84c5z()
  40. {
  41. #if IS_USE_READMSG_CS
  42. DeleteCriticalSection( &m_csReadMsg );
  43. #endif
  44. MTVERIFY( CloseHandle( m_hSemComm ) );
  45. CloseComm();
  46. }
  47. BOOL CM84c5z::MzOpenComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval)
  48. {
  49. BOOL bResult = FALSE;
  50. bResult = OpenComm( nCommPort, nAddr, nRate, nDataBit, nStopBit, nParity, nInterval );
  51. return bResult;
  52. }
  53. // 发送读取设备参数请求
  54. int CM84c5z::SendReadRequest(
  55. char szPath[MAX_PATH], // 程序所在路径
  56. char szIniName[MAX_PATH], // 配置文件名称
  57. int nCommPort, // 串行端口
  58. int nAddr, // 设备地址
  59. char szCmd[MAX_CMD], // 请求命令
  60. char szMsg[VAR_MSG], // 响应的值
  61. int nReversed1, // 预留整形参数1接口
  62. int nReversed2, // 预留整形参数2接口
  63. int nReversed3, // 预留整形参数3接口
  64. int nReversed4, // 预留整形参数4接口
  65. int nReversed5, // 预留整形参数5接口
  66. float fReversed1, // 预留float参数1接口
  67. float fReversed2, // 预留float参数2接口
  68. float fReversed3, // 预留float参数3接口
  69. char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
  70. char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
  71. char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
  72. char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
  73. char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
  74. )
  75. {
  76. //LOG4C((LOG_NOTICE," CM84c5z::SendReadRequest"));
  77. int nIndex = 0, nLen = 0;
  78. char szSendMsg[MZ_SEND_MSG] = {0};
  79. char szType[DK_TYPE_LENGTH] = {0};
  80. char szScreen[MAX_CMD] = {0};
  81. int startBit = 0;
  82. int endBit = 0;
  83. GetMzFromIni(szPath, szIniName, szCmd, szSendMsg, szType, szScreen, nIndex, nLen, startBit, endBit);
  84. CCommProcess *pComm = FindComm(nCommPort);
  85. if( pComm == NULL ) return -1;
  86. int nRet = -1;
  87. if( (strlen(m_szMz_41Msg[nAddr - 1]) == 0 &&
  88. (strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 ||
  89. strcmp(szCmd, "cmd-3") == 0 || strcmp(szCmd, "cmd-4") == 0 ||
  90. strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 ||
  91. strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-7") == 0 ||
  92. strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 ||
  93. strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 ||
  94. strcmp(szCmd, "cmd-12") == 0 || strcmp(szCmd, "cmd-13") == 0 ) )|| //获取系统模拟量量化数据(浮点数)
  95. ( strlen(m_szMz_43Msg[nAddr - 1]) == 0 &&
  96. (strcmp(szCmd, "cmd-14") == 0 || strcmp(szCmd, "cmd-15") == 0 ||
  97. strcmp(szCmd, "cmd-16") == 0 ) )|| //获取开关输入状态
  98. ( strlen(m_szMz_44Msg[nAddr - 1]) == 0 &&
  99. (strcmp(szCmd, "cmd-17") == 0 || strcmp(szCmd, "cmd-18") == 0 ||
  100. strcmp(szCmd, "cmd-19") == 0 || strcmp(szCmd, "cmd-20") == 0 ||
  101. strcmp(szCmd, "cmd-21") == 0 || strcmp(szCmd, "cmd-22") == 0 ||
  102. strcmp(szCmd, "cmd-23") == 0 || strcmp(szCmd, "cmd-24") == 0 ||
  103. strcmp(szCmd, "cmd-25") == 0 || strcmp(szCmd, "cmd-26") == 0 ||
  104. strcmp(szCmd, "cmd-27") == 0 || strcmp(szCmd, "cmd-28") == 0) ) ||
  105. strcmp(szCmd, "cmd-1") == 0 ||
  106. strcmp(szCmd, "cmd-3") == 0 ||
  107. strcmp(szCmd, "cmd-14") == 0 ||
  108. strcmp(szCmd, "cmd-15") == 0 ||
  109. strcmp(szCmd, "cmd-17") == 0 ) //获取系统参数(定点数)
  110. {
  111. nRet = GetDeviceParam(nAddr, pComm, szSendMsg, szCmd, szMsg, nIndex, nLen, szType, szScreen );
  112. if( nRet != 0 ) return nRet;
  113. }
  114. if( GetTickCount() - m_dwOnlineTick[nAddr - 1] > 60 *1000 && m_dwOnlineTick[nAddr - 1] > 0 )
  115. {
  116. m_devOnline[nAddr - 1] = FALSE;
  117. }
  118. else if( GetTickCount() - m_dwOnlineTick[nAddr - 1] < 60 *1000 && m_dwOnlineTick[nAddr - 1] > 0 )
  119. {
  120. m_devOnline[nAddr - 1] = TRUE;
  121. }
  122. if( m_devOnline[nAddr - 1] == FALSE )
  123. {
  124. return -1;
  125. }
  126. nRet = GetMz_41VarMsg(nAddr, szCmd, szMsg, nIndex, nLen, szType, startBit, endBit);
  127. nRet = GetMz_43VarMsg(nAddr, szCmd, szMsg, nIndex, nLen, szType, startBit, endBit);
  128. nRet = GetMz_44VarMsg(nAddr, szCmd, szMsg, nIndex, nLen, szType, startBit, endBit);
  129. //LOG4C((LOG_NOTICE, "%s = %s, return %d", szCmd, szMsg, nRet));
  130. return nRet;
  131. }
  132. int CM84c5z::GetMz_41VarMsg( int nAddr, //设备地址
  133. char szCmd[MAX_CMD], // 命令
  134. char szMsg[VAR_MSG], // 接收Buffer
  135. int &nIndex, // 变量索引,针对接收Buffer而言
  136. int &nLen, // 变量长度
  137. char szType[TYPE_LENGTH], // 变量数据类型
  138. int startBit,
  139. int endBit )
  140. {
  141. int nRet = 0;
  142. if( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 ||
  143. strcmp(szCmd, "cmd-3") == 0 || strcmp(szCmd, "cmd-4") == 0 ||
  144. strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 ||
  145. strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-7") == 0 ||
  146. strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 ||
  147. strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 ||
  148. strcmp(szCmd, "cmd-12") == 0 || strcmp(szCmd, "cmd-13") == 0)
  149. {
  150. #if IS_USE_READMSG_CS
  151. EnterCriticalSection( &m_csReadMsg );
  152. #endif
  153. DataConversion(szType, m_szMz_41Msg[nAddr - 1] + nIndex, szMsg, nLen, startBit, endBit);
  154. //LOG4C((LOG_NOTICE, "GetMz_41VarMsg m_szMz_41Msg = %s,szMsg=%s, cmd = %s, type =%s",m_szMz_41Msg, szMsg, szCmd, szType));
  155. #if IS_USE_READMSG_CS
  156. LeaveCriticalSection(&m_csReadMsg);
  157. #endif
  158. nRet = 0;
  159. }
  160. return nRet;
  161. }
  162. int CM84c5z::GetMz_43VarMsg( int nAddr, //设备地址
  163. char szCmd[MAX_CMD], // 命令
  164. char szMsg[VAR_MSG], // 接收Buffer
  165. int &nIndex, // 变量索引,针对接收Buffer而言
  166. int &nLen, // 变量长度
  167. char szType[TYPE_LENGTH],// 变量数据类型
  168. int startBit,
  169. int endBit )
  170. {
  171. int nRet = 0;
  172. if( strcmp(szCmd, "cmd-14") == 0 ||
  173. strcmp(szCmd, "cmd-15") == 0 ||
  174. strcmp(szCmd, "cmd-16") == 0 )
  175. {
  176. #if IS_USE_READMSG_CS
  177. EnterCriticalSection( &m_csReadMsg );
  178. #endif
  179. DataConversion(szType, m_szMz_43Msg[nAddr - 1] + nIndex, szMsg, nLen, 0, 0);
  180. #if IS_USE_READMSG_CS
  181. LeaveCriticalSection(&m_csReadMsg);
  182. #endif
  183. nRet = 0;
  184. }
  185. return nRet;
  186. }
  187. int CM84c5z::GetMz_44VarMsg(int nAddr, //设备地址
  188. char szCmd[MAX_CMD], // 命令
  189. char szMsg[VAR_MSG], // 接收Buffer
  190. int &nIndex, // 变量索引,针对接收Buffer而言
  191. int &nLen, // 变量长度
  192. char szType[TYPE_LENGTH],// 变量数据类型
  193. int startBit,
  194. int endBit )
  195. {
  196. int nRet = 0;
  197. if( strcmp(szCmd, "cmd-17") == 0 || strcmp(szCmd, "cmd-18") == 0 ||
  198. strcmp(szCmd, "cmd-19") == 0 || strcmp(szCmd, "cmd-20") == 0 ||
  199. strcmp(szCmd, "cmd-21") == 0 || strcmp(szCmd, "cmd-22") == 0 ||
  200. strcmp(szCmd, "cmd-23") == 0 || strcmp(szCmd, "cmd-24") == 0 ||
  201. strcmp(szCmd, "cmd-25") == 0 || strcmp(szCmd, "cmd-26") == 0 ||
  202. strcmp(szCmd, "cmd-27") == 0 || strcmp(szCmd, "cmd-28") == 0)
  203. {
  204. #if IS_USE_READMSG_CS
  205. EnterCriticalSection( &m_csReadMsg );
  206. #endif
  207. DataConversion(szType, m_szMz_44Msg[nAddr - 1] + nIndex, szMsg, nLen, 0, 0);
  208. #if IS_USE_READMSG_CS
  209. LeaveCriticalSection(&m_csReadMsg);
  210. #endif
  211. nRet = 0;
  212. }
  213. return nRet;
  214. }
  215. int CM84c5z::GetDeviceParam(int nAddr,
  216. CCommProcess *pComm, //串口对象指针
  217. char szSendMsg[MZ_SEND_MSG], //发送Buffer
  218. char szCmd[MAX_CMD], // 命令
  219. char szMsg[VAR_MSG], // 接收Buffer
  220. int &nIndex, // 变量索引,针对接收Buffer而言
  221. int &nLen, // 变量长度
  222. char szType[TYPE_LENGTH],
  223. char szScreen[CID2_LENGTH]) // 变量数据类型
  224. {
  225. int nRet = -1;
  226. nRet = RequestStatus(nAddr, szCmd, pComm, szSendMsg, szScreen);
  227. if( nRet != 0 )
  228. {
  229. return nRet; // 串口忙
  230. }
  231. nRet = ResponseStatus(nAddr, pComm, szCmd, szMsg, nIndex, nLen, szType);
  232. return nRet;
  233. }
  234. int CM84c5z::SetDeviceParam(int nAddr,
  235. CCommProcess *pComm, //串口对象指针
  236. char szSendMsg[MZ_SEND_MSG], //发送Buffer
  237. char szCmd[MAX_CMD], // 命令
  238. char szMsg[VAR_MSG], // 接收Buffer
  239. int &nIndex, // 变量索引,针对接收Buffer而言
  240. int &nLen, // 变量长度
  241. char szType[TYPE_LENGTH]) // 变量数据类型
  242. {
  243. int nRet = -1;
  244. nRet = WriteRequestStatus(nAddr, szCmd, pComm, szSendMsg);
  245. if( nRet != 0 )
  246. {
  247. return nRet; // 串口忙
  248. }
  249. nRet = WriteResponseStatus(nAddr, pComm, szCmd, szMsg, nIndex, nLen, szType);
  250. return nRet;
  251. }
  252. void CM84c5z::SetMz_41VarMsg( int nAddr, char szCmd[MAX_CMD], char *pBuffer)
  253. {
  254. if( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 ||
  255. strcmp(szCmd, "cmd-3") == 0 || strcmp(szCmd, "cmd-4") == 0 ||
  256. strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 ||
  257. strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-7") == 0 ||
  258. strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 ||
  259. strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 ||
  260. strcmp(szCmd, "cmd-12") == 0 || strcmp(szCmd, "cmd-13") == 0 )
  261. {
  262. #if IS_USE_READMSG_CS
  263. EnterCriticalSection( &m_csReadMsg );
  264. #endif
  265. memcpy(m_szMz_41Msg[nAddr - 1], pBuffer, sizeof(m_szMz_41Msg[nAddr - 1]));
  266. #if IS_USE_READMSG_CS
  267. LeaveCriticalSection(&m_csReadMsg);
  268. #endif
  269. }
  270. }
  271. void CM84c5z::SetMz_43VarMsg( int nAddr, char szCmd[MAX_CMD], char *pBuffer)
  272. {
  273. if( strcmp(szCmd, "cmd-14") == 0 ||
  274. strcmp(szCmd, "cmd-15") == 0 ||
  275. strcmp(szCmd, "cmd-16") == 0 )
  276. {
  277. #if IS_USE_READMSG_CS
  278. EnterCriticalSection( &m_csReadMsg );
  279. #endif
  280. memcpy(m_szMz_43Msg[nAddr - 1], pBuffer, sizeof(m_szMz_43Msg[nAddr - 1]));
  281. #if IS_USE_READMSG_CS
  282. LeaveCriticalSection(&m_csReadMsg);
  283. #endif
  284. }
  285. }
  286. void CM84c5z::SetMz_44VarMsg( int nAddr, char szCmd[MAX_CMD], char *pBuffer)
  287. {
  288. if( strcmp(szCmd, "cmd-17") == 0 || strcmp(szCmd, "cmd-18") == 0 ||
  289. strcmp(szCmd, "cmd-19") == 0 || strcmp(szCmd, "cmd-20") == 0 ||
  290. strcmp(szCmd, "cmd-21") == 0 || strcmp(szCmd, "cmd-22") == 0 ||
  291. strcmp(szCmd, "cmd-23") == 0 || strcmp(szCmd, "cmd-24") == 0 ||
  292. strcmp(szCmd, "cmd-25") == 0 || strcmp(szCmd, "cmd-26") == 0 ||
  293. strcmp(szCmd, "cmd-27") == 0 || strcmp(szCmd, "cmd-28") == 0)
  294. {
  295. #if IS_USE_READMSG_CS
  296. EnterCriticalSection( &m_csReadMsg );
  297. #endif
  298. memcpy(m_szMz_44Msg[nAddr - 1], pBuffer, sizeof(m_szMz_44Msg[nAddr - 1]));
  299. #if IS_USE_READMSG_CS
  300. LeaveCriticalSection(&m_csReadMsg);
  301. #endif
  302. }
  303. }
  304. // 发送设置设备参数请求
  305. int CM84c5z::SendSetReuest(
  306. char szPath[MAX_PATH], // 程序所在路径
  307. char szIniName[MAX_PATH], // 配置文件名称
  308. int nCommPort, // 串行端口
  309. int nAddr, // 设备地址
  310. char szCmd[MAX_CMD], // 请求命令
  311. char szMsg[VAR_MSG], // 响应的值
  312. int nReversed1, // 预留整形参数1接口
  313. int nReversed2, // 预留整形参数2接口
  314. int nReversed3, // 预留整形参数3接口
  315. int nReversed4, // 预留整形参数4接口
  316. int nReversed5, // 预留整形参数5接口
  317. float fReversed1, // 预留float参数1接口
  318. float fReversed2, // 预留float参数2接口
  319. float fReversed3, // 预留float参数3接口
  320. char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
  321. char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
  322. char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
  323. char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
  324. char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
  325. )
  326. {
  327. return 0;
  328. }
  329. //读取配置文件
  330. int CM84c5z::GetMzFromIni(
  331. char szPath[MAX_PATH], //服务器程序所在目录
  332. char szIniName[MAX_PATH], //配置文件名
  333. char szCmd[MAX_CMD], //命令
  334. char szCid2[CID2_LENGTH], //发送Buffer
  335. char szType[TYPE_LENGTH],
  336. char szScreen[CID2_LENGTH],
  337. int &nIndex,
  338. int &nLen,
  339. int &nStaBit,
  340. int &nEndBit
  341. )
  342. {
  343. char szFile[MAX_PATH + 1] = "";
  344. memset(szType, 0, TYPE_LENGTH);
  345. wsprintf(szFile, "%s\\config\\%s", szPath, szIniName);//只读config下面的ini
  346. GetPrivateProfileString(szCmd, "SendCmd", "", szCid2, CID2_LENGTH, szFile);//读取配置文件中的一段字符串
  347. GetPrivateProfileString(szCmd, "Type", "", szType, TYPE_LENGTH, szFile);
  348. GetPrivateProfileString("CMD", "Screen-count", "", szScreen, CID2_LENGTH, szFile);//读取配置文件中的一段字符串
  349. nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile);//从配置文件中取值
  350. nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile);
  351. nStaBit = GetPrivateProfileInt(szCmd, "StaBit", 0, szFile);//从配置文件中取值
  352. nEndBit = GetPrivateProfileInt(szCmd, "EndBit", 0, szFile);
  353. return 0;
  354. }
  355. int CM84c5z::RequestStatus( int nAddr,
  356. char szCmd[MAX_CMD], // 命令
  357. CCommProcess *pComm, //串口对象指针
  358. char chSendMsg[MZ_SEND_MSG], //发送Buffer
  359. char szScreen[CID2_LENGTH] //交流屏个数
  360. )
  361. {
  362. int nRet = -1;
  363. #if DEBUG_MZ
  364. int iLen = sizeof(REQUEST_STRUCT);
  365. char chLength[4] = {0};
  366. char chChkSum[5] = {0};
  367. REQUEST_STRUCT RequestPara;
  368. memset( &RequestPara, 0, iLen );
  369. //起始位
  370. RequestPara.headMes.Start = 0x7E;
  371. //通讯协议版本
  372. RequestPara.headMes.Version[0] = 0x32;
  373. RequestPara.headMes.Version[1] = 0x30;
  374. //设备地址描述
  375. RequestPara.headMes.Address[0] = ByteToAscii((nAddr>>4) & 0x0f);
  376. RequestPara.headMes.Address[1] = ByteToAscii(nAddr & 0x0f);
  377. //Cid1
  378. RequestPara.headMes.Cid1[0] = 0x34;
  379. RequestPara.headMes.Cid1[1] = 0x30;
  380. //Cid2
  381. RequestPara.headMes.Cid2[0] = ByteToAscii(chSendMsg[0] & 0x0f);
  382. RequestPara.headMes.Cid2[1] = ByteToAscii(chSendMsg[1] & 0x0f);
  383. RequestPara.headMes.Lenth[1] = 0x30;
  384. RequestPara.headMes.Lenth[2] = 0x30;
  385. RequestPara.headMes.Lenth[3] = 0x32;
  386. RequestPara.headMes.Lenth[0] = ByteToAscii(GetLengthSum(RequestPara.headMes.Lenth));
  387. RequestPara.headMes.GroupInfo[0] = 0x46;
  388. RequestPara.headMes.GroupInfo[1] = 0x46;
  389. //校验码
  390. BYTE *pDataBuf = new BYTE[ iLen - sizeof(RequestPara.chkSum) - 1 ];
  391. memset(pDataBuf, 0, iLen - sizeof(RequestPara.chkSum) - 1 );
  392. memcpy(pDataBuf, &RequestPara, iLen - sizeof(RequestPara.chkSum) - 1 );
  393. GetCheckSum((char *)pDataBuf + 1, chChkSum, iLen - sizeof(RequestPara.chkSum) - 2 );
  394. RequestPara.chkSum[0] = chChkSum[0];
  395. RequestPara.chkSum[1] = chChkSum[1];
  396. RequestPara.chkSum[2] = chChkSum[2];
  397. RequestPara.chkSum[3] = chChkSum[3];
  398. //结束符
  399. RequestPara.End = 0x0D;
  400. //LOG4C_HEX_DUMP((LOG_NOTICE, (char *)&RequestPara, sizeof(RequestPara)));
  401. if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) // 有信号才写串口
  402. {
  403. int nDataLen = (int)sizeof(RequestPara);
  404. ResetEvent( m_hSemComm );
  405. int nResult = pComm->Write((BYTE *)&RequestPara, nDataLen);
  406. if( nResult == iLen )
  407. {
  408. }
  409. else
  410. {
  411. delete []pDataBuf;
  412. SetEvent( m_hSemComm );
  413. return EER_CODE_MZ_COM_WRITE_DATA;
  414. }
  415. }
  416. else
  417. {
  418. LOG4C((LOG_NOTICE, "m_hSemComm no single"));
  419. delete []pDataBuf;
  420. return ERR_CODE_MZ_COM_BUSY;
  421. }
  422. delete[]pDataBuf;
  423. #endif
  424. return 0;
  425. }
  426. int CM84c5z::ResponseStatus(
  427. int nAddr, // 设备地址
  428. CCommProcess *pComm, //串口对象指针
  429. char szCmd[MAX_CMD], // 命令
  430. char szMsg[VAR_MSG], // 接收Buffer
  431. int &nIndex, // 变量索引,针对接收Buffer而言
  432. int &nLen, // 变量长度
  433. char szType[TYPE_LENGTH] // 变量数据类型
  434. )
  435. {
  436. #if DEBUG_MZ
  437. int nReceiveLen = 0;
  438. int nProcessLen = 0;
  439. int nReadLen = 0;
  440. RESPONSE_STRUCT structResponse;
  441. memset( &structResponse, 0, sizeof(RESPONSE_STRUCT) );
  442. nReceiveLen = sizeof(RESPONSE_STRUCT);
  443. char *pBuffer = new char[ nReceiveLen ];
  444. memset(pBuffer, 0, nReceiveLen);
  445. nReadLen = pComm->Read((BYTE *)pBuffer,nReceiveLen);
  446. //LOG4C((LOG_NOTICE," nReadLen = %d ,pBuffer = %s",nReadLen,pBuffer));
  447. if( nReadLen <= 0)
  448. {
  449. // 串口没有读到数据
  450. //TRACE("串口没有读到数据!\r\n");
  451. SetEvent( m_hSemComm );
  452. if( pBuffer != NULL)
  453. {
  454. delete[] pBuffer;
  455. pBuffer = NULL;
  456. }
  457. return ERR_CODE_MZ_COM_READ_NO_DATA;
  458. }
  459. //else if( nReadLen < nReceiveLen )
  460. //{
  461. // SetEvent( m_hSemComm );
  462. // if( pBuffer )
  463. // {
  464. // delete[] pBuffer;
  465. // pBuffer = NULL;
  466. // }
  467. // return ERR_CODE_MZ_COM_FAULT;
  468. //}
  469. //else if( nReadLen > nLen )
  470. //{
  471. // // 完全代码,不一定能执行到
  472. // SetEvent( m_hSemComm );
  473. // if( pBuffer != NULL)
  474. // {
  475. // delete[] pBuffer;
  476. // pBuffer = NULL;
  477. // }
  478. // return ERR_CODE_MZ_COM_READ_LEN_OVER;
  479. //}
  480. if (LengthCheck(pBuffer) != 0)
  481. {
  482. SetEvent(m_hSemComm);
  483. TRACE("长度校验出错");
  484. if (pBuffer != NULL)
  485. {
  486. delete [] pBuffer;
  487. pBuffer = NULL;
  488. }
  489. return ERR_CODE_RTN_LCHKSUM_ERROR;
  490. }
  491. if (!ChkSumCheck(pBuffer, nReadLen))
  492. {
  493. TRACE("校验码校验出错");
  494. SetEvent(m_hSemComm);
  495. if (pBuffer != NULL)
  496. {
  497. delete [] pBuffer;
  498. pBuffer = NULL;
  499. }
  500. return ERR_CODE_RTN_CHKSUM_ERROR; //校验码校验出错
  501. }
  502. if (RtnCheck(pBuffer) != 0)
  503. {
  504. TRACE("RTN校验出错");
  505. SetEvent(m_hSemComm);
  506. if (pBuffer != NULL)
  507. {
  508. delete [] pBuffer;
  509. pBuffer = NULL;
  510. }
  511. return ERR_CODE_RTN_CHKSUM_RTN_ERROR; //RTN校验出错
  512. }
  513. SetMz_41VarMsg(nAddr, szCmd, pBuffer);
  514. SetMz_43VarMsg(nAddr, szCmd, pBuffer);
  515. SetMz_44VarMsg(nAddr, szCmd, pBuffer);
  516. m_dwOnlineTick[nAddr - 1] = GetTickCount();
  517. // 设置串口等待事件为有信号
  518. SetEvent( m_hSemComm );
  519. if( pBuffer != NULL)
  520. {
  521. delete[] pBuffer;
  522. pBuffer = NULL;
  523. }
  524. #else
  525. SimulationCommData(nAddr);
  526. #endif
  527. return 0;
  528. }
  529. int CM84c5z::WriteRequestStatus( int nAddr,
  530. char szCmd[MAX_CMD], // 命令
  531. CCommProcess *pComm, //串口对象指针
  532. char chSendMsg[MZ_SEND_MSG] //发送Buffer
  533. )
  534. {
  535. #if DEBUG_MZ
  536. int nDataLen = (int)strlen(chSendMsg);
  537. ResetEvent( m_hSemComm );
  538. int nResult = pComm->Write((unsigned char *)chSendMsg, nDataLen);
  539. if( nResult == nDataLen )
  540. {
  541. }
  542. else
  543. {
  544. SetEvent( m_hSemComm );
  545. return EER_CODE_MZ_COM_WRITE_DATA;
  546. }
  547. #endif
  548. return 0;
  549. }
  550. int CM84c5z::WriteResponseStatus( int nAddr, // 设备地址
  551. CCommProcess *pComm, //串口对象指针
  552. char szCmd[MAX_CMD], // 命令
  553. char szMsg[VAR_MSG], // 接收Buffer
  554. int &nIndex, // 变量索引,针对接收Buffer而言
  555. int &nLen, // 变量长度
  556. char szType[TYPE_LENGTH] // 变量数据类型
  557. )
  558. {
  559. SetEvent( m_hSemComm );
  560. return 0;
  561. }
  562. void CM84c5z::SimulationCommData(int nAddr)
  563. {
  564. m_szMz_41Msg[nAddr - 1][0] = 0x7E;
  565. m_szMz_41Msg[nAddr - 1][1] = 0x32;
  566. m_szMz_41Msg[nAddr - 1][2] = 0x30;
  567. m_szMz_41Msg[nAddr - 1][3] = 0x30;
  568. m_szMz_41Msg[nAddr - 1][4] = 0x31;
  569. m_szMz_41Msg[nAddr - 1][5] = 0x34;
  570. m_szMz_41Msg[nAddr - 1][6] = 0x30;
  571. m_szMz_41Msg[nAddr - 1][7] = 0x30;
  572. m_szMz_41Msg[nAddr - 1][8] = 0x30;
  573. m_szMz_41Msg[nAddr - 1][9] = 0x38;
  574. m_szMz_41Msg[nAddr - 1][10] = 0x30;
  575. m_szMz_41Msg[nAddr - 1][11] = 0x36;
  576. m_szMz_41Msg[nAddr - 1][12] = 0x32;
  577. m_szMz_41Msg[nAddr - 1][13] = 0x30;
  578. m_szMz_41Msg[nAddr - 1][14] = 0x30;
  579. m_szMz_41Msg[nAddr - 1][15] = 0x30;
  580. m_szMz_41Msg[nAddr - 1][16] = 0x31;
  581. m_szMz_41Msg[nAddr - 1][17] = 0x30;
  582. m_szMz_41Msg[nAddr - 1][18] = 0x32;
  583. m_szMz_41Msg[nAddr - 1][19] = 0x43;
  584. m_szMz_41Msg[nAddr - 1][20] = 0x34;
  585. m_szMz_41Msg[nAddr - 1][21] = 0x43;
  586. m_szMz_41Msg[nAddr - 1][22] = 0x45;
  587. m_szMz_41Msg[nAddr - 1][23] = 0x37;
  588. m_szMz_41Msg[nAddr - 1][24] = 0x31;
  589. m_szMz_41Msg[nAddr - 1][25] = 0x34;
  590. m_szMz_41Msg[nAddr - 1][26] = 0x33;
  591. m_szMz_41Msg[nAddr - 1][27] = 0x42;
  592. m_szMz_41Msg[nAddr - 1][28] = 0x46;
  593. m_szMz_41Msg[nAddr - 1][29] = 0x37;
  594. m_szMz_41Msg[nAddr - 1][30] = 0x36;
  595. m_szMz_41Msg[nAddr - 1][31] = 0x37;
  596. m_szMz_41Msg[nAddr - 1][32] = 0x32;
  597. m_szMz_41Msg[nAddr - 1][33] = 0x34;
  598. m_szMz_41Msg[nAddr - 1][34] = 0x33;
  599. m_szMz_41Msg[nAddr - 1][35] = 0x43;
  600. m_szMz_41Msg[nAddr - 1][36] = 0x38;
  601. m_szMz_41Msg[nAddr - 1][37] = 0x32;
  602. m_szMz_41Msg[nAddr - 1][38] = 0x36;
  603. m_szMz_41Msg[nAddr - 1][39] = 0x37;
  604. m_szMz_41Msg[nAddr - 1][40] = 0x31;
  605. m_szMz_41Msg[nAddr - 1][41] = 0x34;
  606. m_szMz_41Msg[nAddr - 1][42] = 0x33;
  607. m_szMz_41Msg[nAddr - 1][43] = 0x20;
  608. m_szMz_41Msg[nAddr - 1][44] = 0x20;
  609. m_szMz_41Msg[nAddr - 1][45] = 0x20;
  610. m_szMz_41Msg[nAddr - 1][46] = 0x20;
  611. m_szMz_41Msg[nAddr - 1][47] = 0x20;
  612. m_szMz_41Msg[nAddr - 1][48] = 0x20;
  613. m_szMz_41Msg[nAddr - 1][49] = 0x20;
  614. m_szMz_41Msg[nAddr - 1][50] = 0x20;
  615. m_szMz_41Msg[nAddr - 1][51] = 0x30;
  616. m_szMz_41Msg[nAddr - 1][52] = 0x30;
  617. m_szMz_41Msg[nAddr - 1][53] = 0x43;
  618. m_szMz_41Msg[nAddr - 1][54] = 0x31;
  619. m_szMz_41Msg[nAddr - 1][55] = 0x41;
  620. m_szMz_41Msg[nAddr - 1][56] = 0x30;
  621. m_szMz_41Msg[nAddr - 1][57] = 0x37;
  622. m_szMz_41Msg[nAddr - 1][58] = 0x32;
  623. m_szMz_41Msg[nAddr - 1][59] = 0x34;
  624. m_szMz_41Msg[nAddr - 1][60] = 0x33;
  625. m_szMz_41Msg[nAddr - 1][61] = 0x43;
  626. m_szMz_41Msg[nAddr - 1][62] = 0x34;
  627. m_szMz_41Msg[nAddr - 1][63] = 0x43;
  628. m_szMz_41Msg[nAddr - 1][64] = 0x45;
  629. m_szMz_41Msg[nAddr - 1][65] = 0x37;
  630. m_szMz_41Msg[nAddr - 1][66] = 0x31;
  631. m_szMz_41Msg[nAddr - 1][67] = 0x34;
  632. m_szMz_41Msg[nAddr - 1][68] = 0x33;
  633. m_szMz_41Msg[nAddr - 1][69] = 0x46;
  634. m_szMz_41Msg[nAddr - 1][70] = 0x37;
  635. m_szMz_41Msg[nAddr - 1][71] = 0x46;
  636. m_szMz_41Msg[nAddr - 1][72] = 0x41;
  637. m_szMz_41Msg[nAddr - 1][73] = 0x36;
  638. m_szMz_41Msg[nAddr - 1][74] = 0x46;
  639. m_szMz_41Msg[nAddr - 1][75] = 0x34;
  640. m_szMz_41Msg[nAddr - 1][76] = 0x33;
  641. m_szMz_43Msg[nAddr - 1][0] = 0x7E;
  642. m_szMz_43Msg[nAddr - 1][1] = 0x32;
  643. m_szMz_43Msg[nAddr - 1][2] = 0x30;
  644. m_szMz_43Msg[nAddr - 1][3] = 0x30;
  645. m_szMz_43Msg[nAddr - 1][4] = 0x31;
  646. m_szMz_43Msg[nAddr - 1][5] = 0x34;
  647. m_szMz_43Msg[nAddr - 1][6] = 0x30;
  648. m_szMz_43Msg[nAddr - 1][7] = 0x30;
  649. m_szMz_43Msg[nAddr - 1][8] = 0x30;
  650. m_szMz_43Msg[nAddr - 1][9] = 0x34;
  651. m_szMz_43Msg[nAddr - 1][10] = 0x30;
  652. m_szMz_43Msg[nAddr - 1][11] = 0x30;
  653. m_szMz_43Msg[nAddr - 1][12] = 0x43;
  654. m_szMz_43Msg[nAddr - 1][13] = 0x30;
  655. m_szMz_43Msg[nAddr - 1][14] = 0x30;
  656. m_szMz_43Msg[nAddr - 1][15] = 0x30;
  657. m_szMz_43Msg[nAddr - 1][16] = 0x31;
  658. m_szMz_43Msg[nAddr - 1][17] = 0x30;
  659. m_szMz_43Msg[nAddr - 1][18] = 0x30;
  660. m_szMz_43Msg[nAddr - 1][19] = 0x30;
  661. m_szMz_43Msg[nAddr - 1][20] = 0x32;
  662. m_szMz_43Msg[nAddr - 1][21] = 0x45;
  663. m_szMz_43Msg[nAddr - 1][22] = 0x30;
  664. m_szMz_43Msg[nAddr - 1][23] = 0x45;
  665. m_szMz_43Msg[nAddr - 1][24] = 0x34;
  666. m_szMz_43Msg[nAddr - 1][25] = 0x46;
  667. m_szMz_43Msg[nAddr - 1][26] = 0x42;
  668. m_szMz_43Msg[nAddr - 1][27] = 0x33;
  669. m_szMz_43Msg[nAddr - 1][28] = 0x31;
  670. m_szMz_43Msg[nAddr - 1][29] = 0x0D;
  671. m_szMz_44Msg[nAddr - 1][0] = 0x7E;
  672. m_szMz_44Msg[nAddr - 1][1] = 0x32;
  673. m_szMz_44Msg[nAddr - 1][2] = 0x30;
  674. m_szMz_44Msg[nAddr - 1][3] = 0x30;
  675. m_szMz_44Msg[nAddr - 1][4] = 0x31;
  676. m_szMz_44Msg[nAddr - 1][5] = 0x34;
  677. m_szMz_44Msg[nAddr - 1][6] = 0x30;
  678. m_szMz_44Msg[nAddr - 1][7] = 0x30;
  679. m_szMz_44Msg[nAddr - 1][8] = 0x30;
  680. m_szMz_44Msg[nAddr - 1][9] = 0x32;
  681. m_szMz_44Msg[nAddr - 1][10] = 0x30;
  682. m_szMz_44Msg[nAddr - 1][11] = 0x32;
  683. m_szMz_44Msg[nAddr - 1][12] = 0x43;
  684. m_szMz_44Msg[nAddr - 1][13] = 0x30;
  685. m_szMz_44Msg[nAddr - 1][14] = 0x30;
  686. m_szMz_44Msg[nAddr - 1][15] = 0x30;
  687. m_szMz_44Msg[nAddr - 1][16] = 0x31;
  688. m_szMz_44Msg[nAddr - 1][17] = 0x30;
  689. m_szMz_44Msg[nAddr - 1][18] = 0x32;
  690. m_szMz_44Msg[nAddr - 1][19] = 0x30;
  691. m_szMz_44Msg[nAddr - 1][20] = 0x31;
  692. m_szMz_44Msg[nAddr - 1][21] = 0x30;
  693. m_szMz_44Msg[nAddr - 1][22] = 0x31;
  694. m_szMz_44Msg[nAddr - 1][23] = 0x30;
  695. m_szMz_44Msg[nAddr - 1][24] = 0x31;
  696. m_szMz_44Msg[nAddr - 1][25] = 0x20;
  697. m_szMz_44Msg[nAddr - 1][26] = 0x20;
  698. m_szMz_44Msg[nAddr - 1][27] = 0x30;
  699. m_szMz_44Msg[nAddr - 1][28] = 0x30;
  700. m_szMz_44Msg[nAddr - 1][29] = 0x30;
  701. m_szMz_44Msg[nAddr - 1][30] = 0x34;
  702. m_szMz_44Msg[nAddr - 1][31] = 0x30;
  703. m_szMz_44Msg[nAddr - 1][32] = 0x35;
  704. m_szMz_44Msg[nAddr - 1][33] = 0x20;
  705. m_szMz_44Msg[nAddr - 1][34] = 0x20;
  706. m_szMz_44Msg[nAddr - 1][35] = 0x30;
  707. m_szMz_44Msg[nAddr - 1][36] = 0x35;
  708. m_szMz_44Msg[nAddr - 1][37] = 0x30;
  709. m_szMz_44Msg[nAddr - 1][38] = 0x35;
  710. m_szMz_44Msg[nAddr - 1][39] = 0x30;
  711. m_szMz_44Msg[nAddr - 1][40] = 0x31;
  712. m_szMz_44Msg[nAddr - 1][41] = 0x30;
  713. m_szMz_44Msg[nAddr - 1][42] = 0x31;
  714. m_szMz_44Msg[nAddr - 1][43] = 0x30;
  715. m_szMz_44Msg[nAddr - 1][44] = 0x31;
  716. m_szMz_44Msg[nAddr - 1][45] = 0x20;
  717. m_szMz_44Msg[nAddr - 1][46] = 0x20;
  718. m_szMz_44Msg[nAddr - 1][47] = 0x30;
  719. m_szMz_44Msg[nAddr - 1][48] = 0x31;
  720. m_szMz_44Msg[nAddr - 1][49] = 0x30;
  721. m_szMz_44Msg[nAddr - 1][50] = 0x31;
  722. }
  723. WORD CM84c5z::RtnCheck(char Msg[VAR_MSG])
  724. {
  725. char buffer[3] = {0};
  726. int j = 0;
  727. for (int i = 7; i < 9; i++)
  728. {
  729. buffer[j++] = Msg[i];
  730. }
  731. buffer[j] = '\0';
  732. if (strcmp(buffer,"00") == 0)
  733. {
  734. return 0;
  735. }
  736. else if (strcmp(buffer,"01") == 0)
  737. {
  738. return ERR_CODE_RTN_VER_ERROR;
  739. }
  740. else if (strcmp(buffer,"02") == 0)
  741. {
  742. return ERR_CODE_RTN_CHKSUM_ERROR;
  743. }
  744. else if (strcmp(buffer,"03") == 0)
  745. {
  746. return ERR_CODE_RTN_LCHKSUM_ERROR;
  747. }
  748. else if (strcmp(buffer,"04") == 0)
  749. {
  750. return ERR_CODE_RTN_CID_ERROR;
  751. }
  752. else if (strcmp(buffer,"05") == 0)
  753. {
  754. return ERR_CODE_RTN_COMMAND_FORMAT;
  755. }
  756. else if (strcmp(buffer,"06") == 0)
  757. {
  758. return ERR_CODE_RTN_INVALID_LIMIT;
  759. }
  760. else if (strcmp(buffer,"E0") == 0)
  761. {
  762. return ERR_CODE_RTN_OPERATE_FAIL;
  763. }
  764. else if (strcmp(buffer,"E1") == 0)
  765. {
  766. return ERR_CODE_RTN_EQUIT_FAIL;
  767. }
  768. else if (strcmp(buffer,"E3")==0 ||
  769. strcmp(buffer,"E4")==0
  770. )
  771. {
  772. return ERR_CODE_RTN_KEEP;
  773. }
  774. else if (strcmp(buffer, "E5")==0 ||
  775. strcmp(buffer, "E6") == 0 ||
  776. strcmp(buffer, "E7") == 0 ||
  777. strcmp(buffer, "E8") == 0 ||
  778. strcmp(buffer, "E9") == 0
  779. )
  780. {
  781. return ERR_CODE_RTN_WATCH;
  782. }
  783. else if (strcmp(buffer,"EA") == 0 ||
  784. strcmp(buffer, "EB") == 0 ||
  785. strcmp(buffer, "EC") == 0 ||
  786. strcmp(buffer, "ED") == 0 ||
  787. strcmp(buffer, "EE") == 0 ||
  788. strcmp(buffer, "EF") == 0
  789. )
  790. {
  791. return ERR_CODE_RTN_ELECTICAL_SOURCE;
  792. }
  793. return 0;
  794. }
  795. UINT CM84c5z::GetCheckSum(char *pBuf, char chDest[5], int len)
  796. {
  797. WORD iSum = 0;
  798. for(int i=0; i<len; i++)//求和
  799. {
  800. iSum += pBuf[i];
  801. }
  802. WORD iCompliment = iSum;
  803. iCompliment = ~iCompliment;//取反
  804. iCompliment++;
  805. itoa(iCompliment, chDest, 16);
  806. chDest[0] = lowercase2uppercase(chDest[0]);
  807. chDest[1] = lowercase2uppercase(chDest[1]);
  808. chDest[2] = lowercase2uppercase(chDest[2]);
  809. chDest[3] = lowercase2uppercase(chDest[3]);
  810. return atoi(chDest);
  811. }
  812. BYTE CM84c5z::GetLengthSum(BYTE szChar[])
  813. {
  814. unsigned int nData = 0;
  815. unsigned int nData1 =0;
  816. unsigned short nDataLength = 0;
  817. unsigned short nChar1;
  818. nChar1 =AsciiToBYTE(szChar[1]) +
  819. AsciiToBYTE(szChar[2]) +
  820. AsciiToBYTE(szChar[3]);
  821. nChar1 = (~nChar1) + 1;
  822. nChar1 %=16;
  823. return (BYTE)nChar1;
  824. }
  825. int CM84c5z::LengthCheck(char szSendMsg[])
  826. {
  827. int len = (int)strlen(szSendMsg);
  828. char buffer[5] = {0};
  829. int j = 0;
  830. for (int i = 9; i< 13; i++)
  831. {
  832. buffer[j++] = szSendMsg[i]; //取出检验位
  833. }
  834. buffer[j] ='0';
  835. if(!ValiateLength(buffer)) // 相加模十六取反加一
  836. {
  837. return ERR_CODE_RTN_LCHKSUM_ERROR;
  838. }
  839. /*转换为十六进制*/
  840. return 0;
  841. }
  842. BOOL CM84c5z::ValiateLength(char szChar[])
  843. {
  844. unsigned int nData = 0;
  845. unsigned int nData1 =0;
  846. unsigned short nDataLength = 0;
  847. unsigned short nChar1;
  848. nChar1 =AsciiToBYTE(szChar[1]) +
  849. AsciiToBYTE(szChar[2]) +
  850. AsciiToBYTE(szChar[3]);
  851. nChar1 = (~nChar1) + 1;
  852. nChar1 %=16;
  853. nDataLength = AsciiToBYTE(szChar[0]);
  854. if (nDataLength != nChar1)
  855. {
  856. return FALSE;
  857. }
  858. return TRUE;
  859. }