PB9355.cpp 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. #include "StdAfx.h"
  2. #include ".\pb9355.h"
  3. #include "StdAfx.h"
  4. #include "CommProcess.h"
  5. //#include ".\cms.h"
  6. CPB9355::CPB9355(
  7. char szPath[MAX_PATH], // 程序所在路径 ;
  8. char szIniName[MAX_PATH], // 配置文件名称;
  9. int nCommPort, // 串行端口;
  10. int nAddr, // 设备地址;
  11. int nRate, // 波特率 ;
  12. int nDataBit, // 数据位;
  13. int nStopBit, // 停止位;
  14. int nParity, // 校验位;
  15. int nInterval // 时间间隔;
  16. )
  17. {
  18. #if IS_USE_READMSG_CS
  19. InitializeCriticalSection( &m_csReadMsg ); //初始化一个临界资源对象;
  20. #endif
  21. MTVERIFY( m_hSemComm = CreateEvent( NULL, TRUE, TRUE, 0 ) ); //创建或打开一个命名的或无名的事件对象;
  22. memset(m_sz_33Msg, 0, sizeof(m_sz_33Msg));
  23. memset(m_sz_34Msg, 0, sizeof(m_sz_34Msg));
  24. memset(m_sz_35Msg, 0, sizeof(m_sz_35Msg));
  25. memset(m_szTemp, 0, sizeof(m_szTemp));
  26. memset(szProcessData, 0, sizeof(szProcessData));
  27. m_devOnline= TRUE;
  28. m_dwOnlineTick = 0;
  29. m_bRun = FALSE;
  30. }
  31. CPB9355::~CPB9355()
  32. {
  33. #if IS_USE_READMSG_CS
  34. DeleteCriticalSection( &m_csReadMsg );
  35. #endif
  36. MTVERIFY( CloseHandle( m_hSemComm ) );
  37. CloseComm();
  38. }
  39. BOOL CPB9355::PB9355OpenComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval)
  40. {
  41. BOOL bResult = FALSE;
  42. bResult = OpenComm( nCommPort, nAddr, nRate, nDataBit, nStopBit, nParity, nInterval );
  43. //LOG4C((LOG_NOTICE,"OpenComm Sucess"));
  44. return bResult;
  45. }
  46. int CPB9355::Authorization(CCommProcess *pComm)
  47. {
  48. int nRet = 0;
  49. /************************************************************************/
  50. /* SendMsg */
  51. /************************************************************************/
  52. BYTE SendPart[7] = {0};
  53. SendPart[0] = 0xAB;
  54. SendPart[1] = 0x04;
  55. SendPart[2] = 0xCF;
  56. SendPart[3] = 0x69;
  57. SendPart[4] = 0xE8;
  58. SendPart[5] = 0xD5;
  59. SendPart[6] = 0x5C;
  60. //WaitForSingObject();等待有信号;
  61. if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) {
  62. //ResetEvent()设置无信号状态
  63. ResetEvent( m_hSemComm );
  64. int nResult = pComm->Write(SendPart, 7);
  65. if( nResult != 7 ) {
  66. //SetEvent设置有信号;
  67. SetEvent( m_hSemComm );
  68. //返回 错误值;
  69. return EER_CODE_PB9355_COM_REGNUM;
  70. }
  71. }
  72. else{
  73. //如果m_hSemCom无信号,返回错误;
  74. return ERR_CODE_PB9355_COM_BUSY;
  75. }
  76. /************************************************************************/
  77. /* readfile ; */
  78. /************************************************************************/
  79. //int nRecvLen = 0;
  80. //BYTE pBuffer[270];
  81. //memset(pBuffer, 0, 270);
  82. //nRecvLen = pComm->Read(pBuffer,270);
  83. SetEvent( m_hSemComm );
  84. //LOG4C((LOG_NOTICE,"Authorization Sucess"));
  85. return 0;
  86. }
  87. int CPB9355::OnlyRequested(CCommProcess *pComm)
  88. {
  89. int nRet = 0;
  90. /************************************************************************/
  91. /* SendMsg */
  92. /************************************************************************/
  93. BYTE SendPart[4] = {0};
  94. SendPart[0] = 0xAB;
  95. SendPart[1] = 0x01;
  96. SendPart[2] = 0xA0;
  97. SendPart[3] = 0xB4;
  98. //WaitForSingObject();等待有信号;
  99. if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) {
  100. //ResetEvent()设置无信号状态
  101. ResetEvent( m_hSemComm );
  102. int nResult = pComm->Write(SendPart, 4);
  103. if( nResult != 4 ) {
  104. //SetEvent设置有信号;
  105. SetEvent( m_hSemComm );
  106. //返回 错误值;
  107. return EER_CODE_PB9355_COM_REGNUM;
  108. }
  109. }
  110. else{
  111. //如果m_hSemCom无信号,返回错误;
  112. return ERR_CODE_PB9355_COM_BUSY;
  113. }
  114. /************************************************************************/
  115. /* readfile ; */
  116. /************************************************************************/
  117. //int nRecvLen = 0;
  118. //BYTE pBuffer[270];
  119. //memset(pBuffer, 0, 270);
  120. //nRecvLen = pComm->Read(pBuffer,270);
  121. SetEvent( m_hSemComm );
  122. //LOG4C((LOG_NOTICE,"OnlyRequested Sucess"));
  123. return 0;
  124. }
  125. int CPB9355::ReadSetingData(CCommProcess *pComm)
  126. {
  127. int nRet = 0;
  128. /************************************************************************/
  129. /* SendMsg */
  130. /************************************************************************/
  131. BYTE SendPart[4] = {0};
  132. SendPart[0] = 0xAB;
  133. SendPart[1] = 0x01;
  134. SendPart[2] = 0x31;
  135. SendPart[3] = 0x23;
  136. //WaitForSingObject();等待有信号;
  137. if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) {
  138. //ResetEvent()设置无信号状态
  139. ResetEvent( m_hSemComm );
  140. int nResult = pComm->Write(SendPart, 4);
  141. if( nResult != 4 ) {
  142. //SetEvent设置有信号;
  143. SetEvent( m_hSemComm );
  144. //返回 错误值;
  145. return EER_CODE_PB9355_COM_REGNUM;
  146. }
  147. }
  148. else{
  149. //如果m_hSemCom无信号,返回错误;
  150. return ERR_CODE_PB9355_COM_BUSY;
  151. }
  152. /************************************************************************/
  153. /* readfile ; */
  154. /************************************************************************/
  155. int nRecvLen = 0;
  156. BYTE pBuffer[270];
  157. memset(pBuffer, 0, 270);
  158. nRecvLen = pComm->Read(pBuffer,270);
  159. SetEvent( m_hSemComm );
  160. //LOG4C((LOG_NOTICE,"ReadSetingData Sucess"));
  161. return 0;
  162. }
  163. // 发送读取设备参数请求;
  164. int CPB9355::SendReadRequest(
  165. char szPath[MAX_PATH], // 程序所在路径 ;
  166. char szIniName[MAX_PATH], // 配置文件名称 ;
  167. int nCommPort, // 串行端口;
  168. int nAddr, // 设备地址;
  169. char szCmd[MAX_CMD], // 请求命令;
  170. char szMsg[VAR_MSG], // 响应的值 ;
  171. int nReversed1, // 预留整形参数1接口
  172. int nReversed2, // 预留整形参数2接口
  173. int nReversed3, // 预留整形参数3接口
  174. int nReversed4, // 预留整形参数4接口
  175. int nReversed5, // 预留整形参数5接口
  176. float fReversed1, // 预留float参数1接口
  177. float fReversed2, // 预留float参数2接口
  178. float fReversed3, // 预留float参数3接口
  179. char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
  180. char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
  181. char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
  182. char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
  183. char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
  184. )
  185. {
  186. int nIndex = 0, nLen = 0;
  187. BYTE IniSendCMD = 0;
  188. char szType[TYPE_LENGTH] = {0};
  189. char szScreen[MAX_CMD] = {0};
  190. int StartBit = 0;
  191. int EndBit = 0;
  192. GetPB9355IniInfo(szPath, szIniName, szCmd, IniSendCMD, szType, nIndex, nLen, StartBit, EndBit);
  193. CCommProcess *pComm = FindComm(nCommPort);
  194. if (!m_bRun)
  195. {
  196. //Authorization(pComm);
  197. //OnlyRequested(pComm);
  198. //
  199. //ReadSetingData(pComm);
  200. //LOG4C((LOG_NOTICE,"Sucess Authorization"));
  201. m_bRun = TRUE;
  202. }
  203. if( pComm == NULL ) return -1;
  204. int nRet = -1;
  205. if(
  206. (strlen(m_sz_33Msg) == 0 &&
  207. (
  208. strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 || strcmp(szCmd, "cmd-3") == 0 ||
  209. strcmp(szCmd, "cmd-4") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 ||
  210. strcmp(szCmd, "cmd-7") == 0 || strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 ||
  211. strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 || strcmp(szCmd, "cmd-12") == 0 ||
  212. strcmp(szCmd, "cmd-13") == 0 || strcmp(szCmd, "cmd-14") == 0
  213. )) ||
  214. (strlen(m_sz_34Msg) == 0 &&
  215. (
  216. strcmp(szCmd, "cmd-15") == 0 || strcmp(szCmd, "cmd-16") == 0 || strcmp(szCmd, "cmd-17") == 0 ||
  217. strcmp(szCmd, "cmd-18") == 0 || strcmp(szCmd, "cmd-19") == 0 || strcmp(szCmd, "cmd-20") == 0 ||
  218. strcmp(szCmd, "cmd-21") == 0 || strcmp(szCmd, "cmd-22") == 0 || strcmp(szCmd, "cmd-23") == 0 ||
  219. strcmp(szCmd, "cmd-24") == 0 || strcmp(szCmd, "cmd-25") == 0 || strcmp(szCmd, "cmd-26") == 0 ||
  220. strcmp(szCmd, "cmd-27") == 0 || strcmp(szCmd, "cmd-28") == 0 || strcmp(szCmd, "cmd-29") == 0 || strcmp(szCmd, "cmd-30") == 0 ||
  221. strcmp(szCmd, "cmd-31") == 0 || strcmp(szCmd, "cmd-32") == 0 || strcmp(szCmd, "cmd-33") == 0 ||
  222. strcmp(szCmd, "cmd-34") == 0 || strcmp(szCmd, "cmd-35") == 0 || strcmp(szCmd, "cmd-36") == 0 ||
  223. strcmp(szCmd, "cmd-37") == 0 || strcmp(szCmd, "cmd-38") == 0 || strcmp(szCmd, "cmd-39") == 0 ||
  224. strcmp(szCmd, "cmd-40") == 0 || strcmp(szCmd, "cmd-41") == 0 || strcmp(szCmd, "cmd-42") == 0 ||
  225. strcmp(szCmd, "cmd-43") == 0 || strcmp(szCmd, "cmd-44") == 0 || strcmp(szCmd, "cmd-45") == 0 ||
  226. strcmp(szCmd, "cmd-46") == 0 || strcmp(szCmd, "cmd-47") == 0 || strcmp(szCmd, "cmd-48") == 0 ||
  227. strcmp(szCmd, "cmd-49") == 0 || strcmp(szCmd, "cmd-50") == 0 || strcmp(szCmd, "cmd-51") == 0 ||
  228. strcmp(szCmd, "cmd-52") == 0 || strcmp(szCmd, "cmd-53") == 0 ))
  229. ||
  230. (strlen(m_sz_35Msg) == 0 &&
  231. (
  232. strcmp(szCmd, "cmd-54") == 0 ||strcmp(szCmd, "cmd-55") == 0 || strcmp(szCmd, "cmd-56") == 0 || strcmp(szCmd, "cmd-57") == 0 ||
  233. strcmp(szCmd, "cmd-58") == 0 || strcmp(szCmd, "cmd-59") == 0 || strcmp(szCmd, "cmd-60") == 0 ||
  234. strcmp(szCmd, "cmd-61") == 0 || strcmp(szCmd, "cmd-62") == 0 || strcmp(szCmd, "cmd-63") == 0 ||
  235. strcmp(szCmd, "cmd-64") == 0 || strcmp(szCmd, "cmd-65") == 0 || strcmp(szCmd, "cmd-66") == 0 ||
  236. strcmp(szCmd, "cmd-67") == 0 || strcmp(szCmd, "cmd-68") == 0 || strcmp(szCmd, "cmd-69") == 0 ||
  237. strcmp(szCmd, "cmd-60") == 0 || strcmp(szCmd, "cmd-61") == 0 || strcmp(szCmd, "cmd-62") == 0 ||
  238. strcmp(szCmd, "cmd-63") == 0 || strcmp(szCmd, "cmd-64") == 0 || strcmp(szCmd, "cmd-65") == 0 ||
  239. strcmp(szCmd, "cmd-66") == 0 || strcmp(szCmd, "cmd-67") == 0 || strcmp(szCmd, "cmd-68") == 0 ||
  240. strcmp(szCmd, "cmd-69") == 0 || strcmp(szCmd, "cmd-70") == 0 || strcmp(szCmd, "cmd-71") == 0 ||
  241. strcmp(szCmd, "cmd-72") == 0 || strcmp(szCmd, "cmd-73") == 0 || strcmp(szCmd, "cmd-74") == 0 ||
  242. strcmp(szCmd, "cmd-75") == 0 || strcmp(szCmd, "cmd-76") == 0 || strcmp(szCmd, "cmd-77") == 0 ||
  243. strcmp(szCmd, "cmd-78") == 0 || strcmp(szCmd, "cmd-79") == 0 || strcmp(szCmd, "cmd-80") == 0 ||
  244. strcmp(szCmd, "cmd-81") == 0 || strcmp(szCmd, "cmd-82") == 0 || strcmp(szCmd, "cmd-83") == 0 ||
  245. strcmp(szCmd, "cmd-84") == 0 || strcmp(szCmd, "cmd-85") == 0 || strcmp(szCmd, "cmd-86") == 0 ||
  246. strcmp(szCmd, "cmd-87") == 0 || strcmp(szCmd, "cmd-88") == 0 || strcmp(szCmd, "cmd-89") == 0 ||
  247. strcmp(szCmd, "cmd-90") == 0 || strcmp(szCmd, "cmd-91") == 0 || strcmp(szCmd, "cmd-92") == 0 ||
  248. strcmp(szCmd, "cmd-93") == 0 || strcmp(szCmd, "cmd-94") == 0 || strcmp(szCmd, "cmd-95") == 0))
  249. ||
  250. strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-15") == 0 ||
  251. strcmp(szCmd, "cmd-54") == 0
  252. )
  253. {
  254. nRet = GetDeviceParam(pComm, IniSendCMD, szCmd, szMsg, nIndex, nLen, szType );
  255. if( nRet != 0 ) return nRet;
  256. }
  257. if( GetTickCount() - m_dwOnlineTick > 60 *1000 && m_dwOnlineTick > 0 )
  258. {
  259. m_devOnline = FALSE;
  260. }
  261. else if( GetTickCount() - m_dwOnlineTick< 60 *1000 && m_dwOnlineTick > 0 )
  262. {
  263. m_devOnline = TRUE;
  264. }
  265. if( m_devOnline == FALSE )
  266. {
  267. return -1;
  268. }
  269. LOG4C((LOG_NOTICE,"Begin GetData"));
  270. nRet = Get33VarMsg( szCmd, szMsg, nIndex, nLen, szType, StartBit, EndBit);
  271. nRet = Get34VarMsg( szCmd, szMsg, nIndex, nLen, szType, StartBit, EndBit);
  272. nRet = Get35VarMsg( szCmd, szMsg, nIndex, nLen, szType, StartBit, EndBit);
  273. LOG4C((LOG_NOTICE,"nRet = %d,cmd = %s,值 = %s",nRet,szCmd,szMsg));
  274. return nRet;
  275. }
  276. int CPB9355::GetDeviceParam(
  277. CCommProcess *pComm,
  278. BYTE &IniSendCMD,
  279. char szCmd[MAX_CMD],
  280. char szMsg[VAR_MSG],
  281. int &nIndex,
  282. int &nLen,
  283. char szType[TYPE_LENGTH])
  284. {
  285. int nRet = -1;
  286. nRet = RequestReadStatus(szCmd, pComm, IniSendCMD);
  287. if( nRet != 0 )
  288. {
  289. return nRet;
  290. }
  291. nRet = ResponseReadStatus(pComm, szCmd, szMsg, nIndex, nLen, szType);
  292. return nRet;
  293. }
  294. int CPB9355::RequestReadStatus(char szCmd[MAX_CMD], CCommProcess *pComm, BYTE &IniSendCMD)
  295. {
  296. int nRet = -1;
  297. #if DEBUG_PB9355
  298. BYTE byArray[5];
  299. //ZeroMemory(&byArray,5);
  300. memset(byArray,0,5);
  301. byArray[0] = 0xAB;
  302. byArray[1] = 0x01;
  303. byArray[2] = IniSendCMD; // 命令;
  304. byArray[3] = GetEndCheck((char *)byArray,3); // 校验;
  305. //LOG4C((LOG_NOTICE,"Begin WriteFile"));
  306. if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) { // 有信号才写串口;
  307. ResetEvent( m_hSemComm );
  308. int nResult = pComm->Write(byArray, 4);
  309. if( nResult == 4 ){
  310. }
  311. else{
  312. LOG4C((LOG_NOTICE,"EER_CODE_PB9355_COM_WRITE_DATA"));
  313. SetEvent( m_hSemComm );
  314. return EER_CODE_PB9355_COM_WRITE_DATA;
  315. }
  316. }
  317. else{
  318. LOG4C((LOG_NOTICE,"ERR_CODE_PB9355_COM_BUSY"));
  319. return ERR_CODE_PB9355_COM_BUSY;
  320. }
  321. #endif
  322. return 0;
  323. }
  324. int CPB9355::ResponseReadStatus(
  325. CCommProcess *pComm,
  326. char szCmd[MAX_CMD],
  327. char szMsg[VAR_MSG],
  328. int &nIndex,
  329. int &nLen,
  330. char szType[TYPE_LENGTH]
  331. )
  332. {
  333. #if DEBUG_PB9355
  334. int nRecvLen = 0;
  335. char *pBuffer = new char[270];
  336. memset(pBuffer, 0, 270);
  337. nRecvLen = pComm->Read((BYTE *)pBuffer,270);
  338. if( nRecvLen <= 0)
  339. {
  340. SetEvent( m_hSemComm );
  341. if( pBuffer != NULL)
  342. {
  343. delete[] pBuffer;
  344. pBuffer = NULL;
  345. }
  346. return ERR_CODE_PB9355_COM_READ_NO_DATA;
  347. }
  348. //LOG4C((LOG_NOTICE,"Begin SetData"));
  349. Set33VarMsg( szCmd, pBuffer);
  350. Set34VarMsg( szCmd, pBuffer);
  351. Set35VarMsg( szCmd, pBuffer);
  352. //LOG4C((LOG_NOTICE,"Sucess SetData"));
  353. m_dwOnlineTick = GetTickCount();
  354. SetEvent( m_hSemComm );
  355. if( pBuffer != NULL)
  356. {
  357. delete[] pBuffer;
  358. pBuffer = NULL;
  359. }
  360. #else
  361. SimulationCommData();
  362. #endif
  363. return 0;
  364. }
  365. void CPB9355::Set33VarMsg( char szCmd[MAX_CMD], char *pBuffer)
  366. {
  367. if( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 || strcmp(szCmd, "cmd-3") == 0 ||
  368. strcmp(szCmd, "cmd-4") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 ||
  369. strcmp(szCmd, "cmd-7") == 0 || strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 ||
  370. strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 || strcmp(szCmd, "cmd-12") == 0 ||
  371. strcmp(szCmd, "cmd-13") == 0 || strcmp(szCmd, "cmd-14") == 0 )
  372. {
  373. #if IS_USE_READMSG_CS
  374. EnterCriticalSection( &m_csReadMsg );
  375. #endif
  376. memcpy(m_sz_33Msg, pBuffer + 4, sizeof(m_sz_33Msg));
  377. #if IS_USE_READMSG_CS
  378. LeaveCriticalSection(&m_csReadMsg);
  379. #endif
  380. }
  381. }
  382. void CPB9355::Set34VarMsg( char szCmd[MAX_CMD], char *pBuffer)
  383. {
  384. if( strcmp(szCmd, "cmd-15") == 0 || strcmp(szCmd, "cmd-16") == 0 || strcmp(szCmd, "cmd-17") == 0 ||
  385. strcmp(szCmd, "cmd-18") == 0 || strcmp(szCmd, "cmd-19") == 0 || strcmp(szCmd, "cmd-20") == 0 ||
  386. strcmp(szCmd, "cmd-21") == 0 || strcmp(szCmd, "cmd-22") == 0 || strcmp(szCmd, "cmd-23") == 0 ||
  387. strcmp(szCmd, "cmd-24") == 0 || strcmp(szCmd, "cmd-25") == 0 || strcmp(szCmd, "cmd-26") == 0 ||
  388. strcmp(szCmd, "cmd-27") == 0 || strcmp(szCmd, "cmd-28") == 0 || strcmp(szCmd, "cmd-29") == 0 || strcmp(szCmd, "cmd-30") == 0 ||
  389. strcmp(szCmd, "cmd-31") == 0 || strcmp(szCmd, "cmd-32") == 0 || strcmp(szCmd, "cmd-33") == 0 ||
  390. strcmp(szCmd, "cmd-34") == 0 || strcmp(szCmd, "cmd-35") == 0 || strcmp(szCmd, "cmd-36") == 0 ||
  391. strcmp(szCmd, "cmd-37") == 0 || strcmp(szCmd, "cmd-38") == 0 || strcmp(szCmd, "cmd-39") == 0 ||
  392. strcmp(szCmd, "cmd-40") == 0 || strcmp(szCmd, "cmd-41") == 0 || strcmp(szCmd, "cmd-42") == 0 ||
  393. strcmp(szCmd, "cmd-43") == 0 || strcmp(szCmd, "cmd-44") == 0 || strcmp(szCmd, "cmd-45") == 0 ||
  394. strcmp(szCmd, "cmd-46") == 0 || strcmp(szCmd, "cmd-47") == 0 || strcmp(szCmd, "cmd-48") == 0 ||
  395. strcmp(szCmd, "cmd-49") == 0 || strcmp(szCmd, "cmd-50") == 0 || strcmp(szCmd, "cmd-51") == 0 ||
  396. strcmp(szCmd, "cmd-52") == 0 || strcmp(szCmd, "cmd-53") == 0 )
  397. {
  398. #if IS_USE_READMSG_CS
  399. EnterCriticalSection( &m_csReadMsg );
  400. #endif
  401. //memset(m_szTemp,0,1024);
  402. //memcpy(m_szTemp,pBuffer+4,sizeof(m_szTemp));
  403. memcpy(m_sz_34Msg, pBuffer + 4, sizeof(m_sz_34Msg));
  404. LOG4C((LOG_NOTICE,"pBuffer = %s",pBuffer));
  405. //GetDataSection();
  406. #if IS_USE_READMSG_CS
  407. LeaveCriticalSection(&m_csReadMsg);
  408. #endif
  409. }
  410. }
  411. void CPB9355::Set35VarMsg( char szCmd[MAX_CMD], char *pBuffer)
  412. {
  413. if( strcmp(szCmd, "cmd-54") == 0 ||strcmp(szCmd, "cmd-55") == 0 || strcmp(szCmd, "cmd-56") == 0 || strcmp(szCmd, "cmd-57") == 0 ||
  414. strcmp(szCmd, "cmd-58") == 0 || strcmp(szCmd, "cmd-59") == 0 || strcmp(szCmd, "cmd-60") == 0 ||
  415. strcmp(szCmd, "cmd-61") == 0 || strcmp(szCmd, "cmd-62") == 0 || strcmp(szCmd, "cmd-63") == 0 ||
  416. strcmp(szCmd, "cmd-64") == 0 || strcmp(szCmd, "cmd-65") == 0 || strcmp(szCmd, "cmd-66") == 0 ||
  417. strcmp(szCmd, "cmd-67") == 0 || strcmp(szCmd, "cmd-68") == 0 || strcmp(szCmd, "cmd-69") == 0 ||
  418. strcmp(szCmd, "cmd-60") == 0 || strcmp(szCmd, "cmd-61") == 0 || strcmp(szCmd, "cmd-62") == 0 ||
  419. strcmp(szCmd, "cmd-63") == 0 || strcmp(szCmd, "cmd-64") == 0 || strcmp(szCmd, "cmd-65") == 0 ||
  420. strcmp(szCmd, "cmd-66") == 0 || strcmp(szCmd, "cmd-67") == 0 || strcmp(szCmd, "cmd-68") == 0 ||
  421. strcmp(szCmd, "cmd-69") == 0 || strcmp(szCmd, "cmd-70") == 0 || strcmp(szCmd, "cmd-71") == 0 ||
  422. strcmp(szCmd, "cmd-72") == 0 || strcmp(szCmd, "cmd-73") == 0 || strcmp(szCmd, "cmd-74") == 0 ||
  423. strcmp(szCmd, "cmd-75") == 0 || strcmp(szCmd, "cmd-76") == 0 || strcmp(szCmd, "cmd-77") == 0 ||
  424. strcmp(szCmd, "cmd-78") == 0 || strcmp(szCmd, "cmd-79") == 0 || strcmp(szCmd, "cmd-80") == 0 ||
  425. strcmp(szCmd, "cmd-81") == 0 || strcmp(szCmd, "cmd-82") == 0 || strcmp(szCmd, "cmd-83") == 0 ||
  426. strcmp(szCmd, "cmd-84") == 0 || strcmp(szCmd, "cmd-85") == 0 || strcmp(szCmd, "cmd-86") == 0 ||
  427. strcmp(szCmd, "cmd-87") == 0 || strcmp(szCmd, "cmd-88") == 0 || strcmp(szCmd, "cmd-89") == 0 ||
  428. strcmp(szCmd, "cmd-90") == 0 || strcmp(szCmd, "cmd-91") == 0 || strcmp(szCmd, "cmd-92") == 0 ||
  429. strcmp(szCmd, "cmd-93") == 0 || strcmp(szCmd, "cmd-94") == 0 || strcmp(szCmd, "cmd-95") == 0 )
  430. {
  431. #if IS_USE_READMSG_CS
  432. EnterCriticalSection( &m_csReadMsg );
  433. #endif
  434. memcpy(m_sz_35Msg, pBuffer + 4, sizeof(m_sz_35Msg));
  435. #if IS_USE_READMSG_CS
  436. LeaveCriticalSection(&m_csReadMsg);
  437. #endif
  438. }
  439. }
  440. int CPB9355::Get33VarMsg( char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[TYPE_LENGTH], int startBit, int endBit )
  441. {
  442. int nRet = 0;
  443. if( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 || strcmp(szCmd, "cmd-3") == 0 ||
  444. strcmp(szCmd, "cmd-4") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 ||
  445. strcmp(szCmd, "cmd-7") == 0 || strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 ||
  446. strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 || strcmp(szCmd, "cmd-12") == 0 ||
  447. strcmp(szCmd, "cmd-13") == 0 || strcmp(szCmd, "cmd-14") == 0)
  448. {
  449. #if IS_USE_READMSG_CS
  450. EnterCriticalSection( &m_csReadMsg );
  451. #endif
  452. DataProcess(szType, m_sz_33Msg + nIndex, szMsg, nLen, startBit, endBit);
  453. #if IS_USE_READMSG_CS
  454. LeaveCriticalSection(&m_csReadMsg);
  455. #endif
  456. nRet = 0;
  457. }
  458. return nRet;
  459. }
  460. int CPB9355::Get34VarMsg( char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[TYPE_LENGTH], int startBit, int endBit )
  461. {
  462. int nRet = 0;
  463. if( strcmp(szCmd, "cmd-15") == 0 || strcmp(szCmd, "cmd-16") == 0 || strcmp(szCmd, "cmd-17") == 0 ||
  464. strcmp(szCmd, "cmd-18") == 0 || strcmp(szCmd, "cmd-19") == 0 || strcmp(szCmd, "cmd-20") == 0 ||
  465. strcmp(szCmd, "cmd-21") == 0 || strcmp(szCmd, "cmd-22") == 0 || strcmp(szCmd, "cmd-23") == 0 ||
  466. strcmp(szCmd, "cmd-24") == 0 || strcmp(szCmd, "cmd-25") == 0 || strcmp(szCmd, "cmd-26") == 0 ||
  467. strcmp(szCmd, "cmd-27") == 0 || strcmp(szCmd, "cmd-28") == 0 || strcmp(szCmd, "cmd-29") == 0 || strcmp(szCmd, "cmd-30") == 0 ||
  468. strcmp(szCmd, "cmd-31") == 0 || strcmp(szCmd, "cmd-32") == 0 || strcmp(szCmd, "cmd-33") == 0 ||
  469. strcmp(szCmd, "cmd-34") == 0 || strcmp(szCmd, "cmd-35") == 0 || strcmp(szCmd, "cmd-36") == 0 ||
  470. strcmp(szCmd, "cmd-37") == 0 || strcmp(szCmd, "cmd-38") == 0 || strcmp(szCmd, "cmd-39") == 0 ||
  471. strcmp(szCmd, "cmd-40") == 0 || strcmp(szCmd, "cmd-41") == 0 || strcmp(szCmd, "cmd-42") == 0 ||
  472. strcmp(szCmd, "cmd-43") == 0 || strcmp(szCmd, "cmd-44") == 0 || strcmp(szCmd, "cmd-45") == 0 ||
  473. strcmp(szCmd, "cmd-46") == 0 || strcmp(szCmd, "cmd-47") == 0 || strcmp(szCmd, "cmd-48") == 0 ||
  474. strcmp(szCmd, "cmd-49") == 0 || strcmp(szCmd, "cmd-50") == 0 || strcmp(szCmd, "cmd-51") == 0 ||
  475. strcmp(szCmd, "cmd-52") == 0 || strcmp(szCmd, "cmd-53") == 0 )
  476. {
  477. #if IS_USE_READMSG_CS
  478. EnterCriticalSection( &m_csReadMsg );
  479. #endif
  480. DataProcess(szType, m_sz_34Msg + nIndex, szMsg, nLen, startBit, endBit);
  481. #if IS_USE_READMSG_CS
  482. LeaveCriticalSection(&m_csReadMsg);
  483. #endif
  484. nRet = 0;
  485. }
  486. return nRet;
  487. }
  488. int CPB9355::Get35VarMsg( char szCmd[MAX_CMD], char szMsg[VAR_MSG], int &nIndex, int &nLen, char szType[TYPE_LENGTH], int startBit, int endBit )
  489. {
  490. int nRet = 0;
  491. if( strcmp(szCmd, "cmd-54") == 0 ||strcmp(szCmd, "cmd-55") == 0 || strcmp(szCmd, "cmd-56") == 0 || strcmp(szCmd, "cmd-57") == 0 ||
  492. strcmp(szCmd, "cmd-58") == 0 || strcmp(szCmd, "cmd-59") == 0 || strcmp(szCmd, "cmd-60") == 0 ||
  493. strcmp(szCmd, "cmd-61") == 0 || strcmp(szCmd, "cmd-62") == 0 || strcmp(szCmd, "cmd-63") == 0 ||
  494. strcmp(szCmd, "cmd-64") == 0 || strcmp(szCmd, "cmd-65") == 0 || strcmp(szCmd, "cmd-66") == 0 ||
  495. strcmp(szCmd, "cmd-67") == 0 || strcmp(szCmd, "cmd-68") == 0 || strcmp(szCmd, "cmd-69") == 0 ||
  496. strcmp(szCmd, "cmd-60") == 0 || strcmp(szCmd, "cmd-61") == 0 || strcmp(szCmd, "cmd-62") == 0 ||
  497. strcmp(szCmd, "cmd-63") == 0 || strcmp(szCmd, "cmd-64") == 0 || strcmp(szCmd, "cmd-65") == 0 ||
  498. strcmp(szCmd, "cmd-66") == 0 || strcmp(szCmd, "cmd-67") == 0 || strcmp(szCmd, "cmd-68") == 0 ||
  499. strcmp(szCmd, "cmd-69") == 0 || strcmp(szCmd, "cmd-70") == 0 || strcmp(szCmd, "cmd-71") == 0 ||
  500. strcmp(szCmd, "cmd-72") == 0 || strcmp(szCmd, "cmd-73") == 0 || strcmp(szCmd, "cmd-74") == 0 ||
  501. strcmp(szCmd, "cmd-75") == 0 || strcmp(szCmd, "cmd-76") == 0 || strcmp(szCmd, "cmd-77") == 0 ||
  502. strcmp(szCmd, "cmd-78") == 0 || strcmp(szCmd, "cmd-79") == 0 || strcmp(szCmd, "cmd-80") == 0 ||
  503. strcmp(szCmd, "cmd-81") == 0 || strcmp(szCmd, "cmd-82") == 0 || strcmp(szCmd, "cmd-83") == 0 ||
  504. strcmp(szCmd, "cmd-84") == 0 || strcmp(szCmd, "cmd-85") == 0 || strcmp(szCmd, "cmd-86") == 0 ||
  505. strcmp(szCmd, "cmd-87") == 0 || strcmp(szCmd, "cmd-88") == 0 || strcmp(szCmd, "cmd-89") == 0 ||
  506. strcmp(szCmd, "cmd-90") == 0 || strcmp(szCmd, "cmd-91") == 0 || strcmp(szCmd, "cmd-92") == 0 ||
  507. strcmp(szCmd, "cmd-93") == 0 || strcmp(szCmd, "cmd-94") == 0 || strcmp(szCmd, "cmd-95") == 0 )
  508. {
  509. #if IS_USE_READMSG_CS
  510. EnterCriticalSection( &m_csReadMsg );
  511. #endif
  512. DataProcess(szType, m_sz_35Msg + nIndex, szMsg, nLen, startBit, endBit);
  513. #if IS_USE_READMSG_CS
  514. LeaveCriticalSection(&m_csReadMsg);
  515. #endif
  516. nRet = 0;
  517. }
  518. return nRet;
  519. }
  520. int CPB9355::GetPB9355IniInfo(
  521. char szPath[MAX_PATH],
  522. char szIniName[MAX_PATH],
  523. char szCmd[MAX_CMD],
  524. BYTE &IniSendCMD,
  525. char szType[TYPE_LENGTH],
  526. int &nIndex,
  527. int &nLen,
  528. int &StaBit,
  529. int &EndBit
  530. )
  531. {
  532. char szFile[MAX_PATH + 1] = "";
  533. char szSendCmd[3] = {0};
  534. memset(szType, 0, TYPE_LENGTH);
  535. wsprintf(szFile, "%s\\config\\%s", szPath, szIniName);
  536. GetPrivateProfileString(szCmd, "SendCmd", "", szSendCmd, MAX_CMD, szFile);
  537. IniSendCMD = AsciiToBYTE(szSendCmd[0])*16 + AsciiToBYTE(szSendCmd[1]) ;
  538. GetPrivateProfileString(szCmd, "Type", "", szType, TYPE_LENGTH, szFile);
  539. nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile);
  540. nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile);
  541. StaBit = GetPrivateProfileInt(szCmd,"Sbit",0,szFile);
  542. EndBit = GetPrivateProfileInt(szCmd,"Ebit",0,szFile);
  543. return 0;
  544. }
  545. int CPB9355::GetEndCheck(char *buf,int len)
  546. {
  547. int iSum = 0;
  548. for (int i = 0; i < len; i++)
  549. {
  550. iSum += (BYTE)buf[i];
  551. }
  552. // 再求低8位,取反加+;
  553. iSum = iSum & 0x00FF;
  554. return iSum = ~iSum+1;
  555. }
  556. void CPB9355::GetDataSection(/*char *pBuf*/)
  557. {
  558. int nBlockLen1 = 0, nBlockLen2 = 0,nBlockLen3 = 0,nBlockLen4 =0;
  559. nBlockLen1 = m_szTemp[2] + 5;
  560. nBlockLen2 = m_szTemp[nBlockLen1+2] + 5;
  561. nBlockLen3 = m_szTemp[nBlockLen2 + nBlockLen1 +2] + 5;
  562. nBlockLen4 = m_szTemp[nBlockLen3 + nBlockLen2 + nBlockLen1] + 5 ;
  563. memcpy(m_sz_34Msg,m_szTemp + 4,nBlockLen1 - 5);
  564. memcpy(m_sz_34Msg + nBlockLen1 - 5,m_szTemp + nBlockLen1 + 4,nBlockLen2 - 5);
  565. }
  566. void CPB9355::PCRTo16HEXPCRT(char *szSour, char *pDsc,int len)
  567. {
  568. #if 1
  569. for (int i = 0,j = 0; i < len; i++)
  570. {
  571. pDsc[j++] = ByteToAscii((szSour[len -i-1] >> 4 ) & 0x0F);
  572. pDsc[j++] = ByteToAscii(szSour[len -i-1] & 0x0F);
  573. }
  574. #else
  575. int j = 0;
  576. int nNo = 0;
  577. for (int i = 0,j = 0; i < len; i++)
  578. {
  579. nNo = j++;
  580. pDsc[nNo] = ByteToAscii((szSour[len -i-1] >> 4 ) & 0x0F);
  581. nNo = j++;
  582. pDsc[nNo] = ByteToAscii(szSour[len -i-1] & 0x0F);
  583. }
  584. #endif
  585. }
  586. void CPB9355::ByteTo16HEXAscii(BYTE &bySour, char *pDsc)
  587. {
  588. pDsc[0] = ByteToAscii((bySour >> 4 ) & 0x0F);
  589. pDsc[1] = ByteToAscii(bySour & 0x0F);
  590. }
  591. //char* CPB9355::ByteTo16HEXAscii(BYTE &bySour)
  592. //{
  593. // //char *pDsc = new char[3];
  594. // //memset(pDsc,0,3);
  595. // char pDsc[3] = {0};
  596. //
  597. // pDsc[0] = ByteToAscii((bySour >> 4 ) & 0x0F);
  598. // pDsc[1] = ByteToAscii(bySour & 0x0F);
  599. //
  600. // return pDsc;
  601. //}
  602. void CPB9355::DataProcess(const char *szType, char *szMsg, char *szConvMsg, int len, int StaBit, int EndBit)
  603. {
  604. if ( strcmp(szType, "HEX") == 0)
  605. {
  606. //LOG4C((LOG_NOTICE,"szMsg = %s",szMsg));
  607. char abcd[5] = {0};
  608. abcd[0] = szMsg[3];
  609. abcd[1] = szMsg[2];
  610. abcd[2] = szMsg[1];
  611. abcd[3] = szMsg[0];
  612. LOG4C_HEX_DUMP((LOG_NOTICE, szMsg, sizeof(szMsg)));
  613. LOG4C_HEX_DUMP((LOG_NOTICE, abcd, sizeof(abcd)));
  614. //LOG4C((LOG_NOTICE,"abcd = %s",abcd));
  615. float fNum = *(float*)abcd;
  616. sprintf(szConvMsg,"%f",fNum);
  617. //LOG4C((LOG_NOTICE,"szConvMsg = %s",szConvMsg));
  618. }
  619. else if ( strcmp(szType, "BIT") == 0 )
  620. {
  621. BitDataProcess((BYTE)szMsg[0],szConvMsg,StaBit,EndBit);
  622. }
  623. else if (strcmp(szType,"FLOAT") == 0)
  624. {
  625. float fNum = *(float*)szMsg;
  626. sprintf(szConvMsg,"%f",fNum);
  627. }
  628. }
  629. void CPB9355::BitDataProcess(const BYTE &bySour, char *szRecv,int &StaBit,int &EndBit)
  630. {
  631. int ByteBit = 0;
  632. int sum = bySour;
  633. #if 0
  634. switch(StaBit)
  635. {
  636. case 7:
  637. ByteBit = sum & 0x01;
  638. break;
  639. case 6:
  640. ByteBit = (sum & 0x02) / 0x02 ;
  641. break;
  642. case 5:
  643. ByteBit = (sum & 0x04) / 0x04 ;
  644. break;
  645. case 4:
  646. ByteBit = (sum & 0x08) / 0x08 ;
  647. break;
  648. case 3:
  649. ByteBit = (sum & 0x10) / 0x10 ;
  650. break;
  651. case 2:
  652. ByteBit = (sum & 0x20) / 0x20 ;
  653. break;
  654. case 1:
  655. ByteBit = (sum & 0x40) / 0x40 ;
  656. break;
  657. case 0:
  658. ByteBit = (sum & 0x80) / 0x80;
  659. break;
  660. }
  661. #else
  662. switch(StaBit)
  663. {
  664. case 0:
  665. ByteBit = sum & 0x01;
  666. break;
  667. case 1:
  668. ByteBit = (sum & 0x02) / 0x02 ;
  669. break;
  670. case 2:
  671. ByteBit = (sum & 0x04) / 0x04 ;
  672. break;
  673. case 3:
  674. ByteBit = (sum & 0x08) / 0x08 ;
  675. break;
  676. case 4:
  677. ByteBit = (sum & 0x10) / 0x10 ;
  678. break;
  679. case 5:
  680. ByteBit = (sum & 0x20) / 0x20 ;
  681. break;
  682. case 6:
  683. ByteBit = (sum & 0x40) / 0x40 ;
  684. break;
  685. case 7:
  686. ByteBit = (sum & 0x80) / 0x80;
  687. break;
  688. }
  689. #endif
  690. sprintf(szRecv,"%d",ByteBit);
  691. }
  692. void CPB9355::SimulationCommData()
  693. {
  694. char sztemp[1024] = {0};
  695. sztemp[0] = 0xAB ;
  696. sztemp[1] = 0x04 ;
  697. sztemp[2] = 0x40 ;
  698. sztemp[3] = 0x01 ;
  699. // 输出线电压;
  700. sztemp[4] = 0x00;
  701. sztemp[5] = 0x00;
  702. sztemp[6] = 0xA0;
  703. sztemp[7] = 0x40;
  704. sztemp[8] = 0x00;
  705. sztemp[9] = 0x00;
  706. sztemp[10] = 0xC0;
  707. sztemp[11] = 0x40;
  708. sztemp[12] = 0x00;
  709. sztemp[13] = 0x00;
  710. sztemp[14] = 0xC0;
  711. sztemp[15] = 0x40;
  712. // 输入线电压;
  713. sztemp[16] = 0x00 ;
  714. sztemp[17] = 0x30;
  715. sztemp[18] = 0x3C;
  716. sztemp[19] = 0x45;
  717. sztemp[20] = 0x00;
  718. sztemp[21] = 0x10;
  719. sztemp[22] = 0x85;
  720. sztemp[23] = 0x45;
  721. sztemp[24] = 0x00;
  722. sztemp[25] = 0x00;
  723. sztemp[26] = 0x35;
  724. sztemp[27] = 0x3F;
  725. // 旁路线电压;
  726. sztemp[28] = 0x00;
  727. sztemp[29] = 0xEC;
  728. sztemp[30] = 0x47;
  729. sztemp[31] = 0x42;
  730. sztemp[32] = 0x00;
  731. sztemp[33] = 0xEC;
  732. sztemp[34] = 0x47;
  733. sztemp[35] = 0x42;
  734. sztemp[36] = 0x00;
  735. sztemp[37] = 0xEC;
  736. sztemp[38] = 0x47;
  737. sztemp[39] = 0x42;
  738. // 主输入电流;
  739. sztemp[40] = 0x00;
  740. sztemp[41] = 0xEC;
  741. sztemp[42] = 0x47;
  742. sztemp[43] = 0x42;
  743. sztemp[44] = 0x00;
  744. sztemp[45] = 0x00;
  745. sztemp[46] = 0x00;
  746. sztemp[47] = 0x00;
  747. sztemp[48] = 0x80;
  748. sztemp[49] = 0xD9;
  749. sztemp[50] = 0xCE;
  750. sztemp[51] = 0x43;
  751. // 输出功率;
  752. sztemp[52] = 0x00 ;
  753. sztemp[53] = 0xCC;
  754. sztemp[54] = 0xC7;
  755. sztemp[55] = 0x42;
  756. // 输入功率;
  757. sztemp[56] = 0x7F;
  758. sztemp[57] = 0x70;
  759. sztemp[58] = 0x00;
  760. sztemp[59] = 0x00;
  761. // 输出电量
  762. sztemp[60] = 0x00 ;
  763. sztemp[61] = 0xCD;
  764. sztemp[62] = 0xAC;
  765. sztemp[63] = 0x43;
  766. // 输入电量;
  767. sztemp[64] = 0x00;
  768. sztemp[65] = 0x00;
  769. sztemp[66] = 0xE8;
  770. sztemp[67] = 0x41;
  771. // 输出/输入功率因子;
  772. sztemp[68] = 0x4A;
  773. sztemp[69] = 0xAB;
  774. sztemp[70] = 0x04;
  775. sztemp[71] = 0x40;
  776. sztemp[72] = 0x02;
  777. sztemp[73] = 0x00;
  778. sztemp[74] = 0xCD;
  779. sztemp[75] = 0xAC;
  780. sztemp[76] = 0x43;
  781. sztemp[77] = 0x00;
  782. sztemp[78] = 0x00;
  783. sztemp[79] = 0x20;
  784. sztemp[80] = 0x41;
  785. sztemp[81] = 0x00;
  786. sztemp[82] = 0x00;
  787. sztemp[83] = 0x30;
  788. sztemp[84] = 0x42;
  789. sztemp[85] = 0x00;
  790. sztemp[86] = 0x9A;
  791. sztemp[87] = 0x5E;
  792. sztemp[88] = 0x43;
  793. sztemp[89] = 0x00;
  794. sztemp[90] = 0x00;
  795. sztemp[91] = 0x5F;
  796. sztemp[92] = 0x43;
  797. sztemp[93] = 0x00;
  798. sztemp[94] = 0xE6;
  799. sztemp[95] = 0x5D;
  800. sztemp[96] = 0x43;
  801. sztemp[97] = 0x00;
  802. sztemp[98] = 0x4D;
  803. sztemp[99] = 0x5F;
  804. sztemp[100] = 0x43;
  805. sztemp[101] = 0x00;
  806. sztemp[102] = 0x1A;
  807. sztemp[103] = 0x5D;
  808. sztemp[104] = 0x43;
  809. sztemp[105] = 0x00;
  810. sztemp[106] = 0xCD;
  811. sztemp[107] = 0x5D;
  812. sztemp[108] = 0x43;
  813. sztemp[109] = 0x00;
  814. sztemp[110] = 0xD0;
  815. sztemp[111] = 0x6C;
  816. sztemp[112] = 0x41;
  817. sztemp[113] = 0x00;
  818. sztemp[114] = 0xC0;
  819. sztemp[115] = 0x85;
  820. sztemp[116] = 0x40;
  821. sztemp[117] = 0x00;
  822. sztemp[118] = 0xA0;
  823. sztemp[119] = 0xB1;
  824. sztemp[120] = 0x40;
  825. sztemp[121] = 0x00;
  826. sztemp[122] = 0x60;
  827. sztemp[123] = 0x03;
  828. sztemp[124] = 0x41;
  829. sztemp[125] = 0x00;
  830. sztemp[126] = 0x00;
  831. sztemp[127] = 0xB0;
  832. sztemp[128] = 0x41;
  833. sztemp[129] = 0x00;
  834. sztemp[130] = 0x00;
  835. sztemp[131] = 0xB0;
  836. sztemp[132] = 0x41;
  837. sztemp[133] = 0x00;
  838. sztemp[134] = 0x00;
  839. sztemp[135] = 0xB0;
  840. sztemp[136] = 0x41;
  841. sztemp[137] = 0xCD;
  842. sztemp[138] = 0xAB;
  843. sztemp[139] = 0x04;
  844. sztemp[140] = 0x2C;
  845. sztemp[141] = 0x83;
  846. sztemp[142] = 0x00;
  847. sztemp[143] = 0x60;
  848. sztemp[144] = 0x6A;
  849. sztemp[145] = 0x46;
  850. sztemp[146] = 0x21;
  851. sztemp[147] = 0x11;
  852. sztemp[148] = 0x11;
  853. sztemp[149] = 0xA0;
  854. sztemp[150] = 0x69;
  855. sztemp[151] = 0x21;
  856. sztemp[152] = 0x11;
  857. sztemp[153] = 0x01;
  858. sztemp[154] = 0x00;
  859. sztemp[155] = 0x66;
  860. sztemp[156] = 0x5B;
  861. sztemp[157] = 0x43;
  862. sztemp[158] = 0x00;
  863. sztemp[159] = 0x1A;
  864. sztemp[160] = 0x5B;
  865. sztemp[161] = 0x43;
  866. sztemp[162] = 0x00;
  867. sztemp[163] = 0xCD;
  868. sztemp[164] = 0x5A;
  869. sztemp[165] = 0x43;
  870. sztemp[166] = 0x00;
  871. sztemp[167] = 0xC0;
  872. sztemp[168] = 0x7A;
  873. sztemp[169] = 0x44;
  874. sztemp[170] = 0x00;
  875. sztemp[171] = 0x40;
  876. sztemp[172] = 0x30;
  877. sztemp[173] = 0x44;
  878. sztemp[174] = 0x00;
  879. sztemp[175] = 0x40;
  880. sztemp[176] = 0xA2;
  881. sztemp[177] = 0x44;
  882. sztemp[178] = 0x00;
  883. sztemp[179] = 0xA0;
  884. sztemp[180] = 0x8C;
  885. sztemp[181] = 0x45;
  886. sztemp[182] = 0x06;
  887. sztemp[183] = 0x00;
  888. sztemp[184] = 0x00;
  889. sztemp[185] = 0x00;
  890. sztemp[186] = 0x1E;
  891. //memcpy(m_szTemp,sztemp,187);
  892. memcpy(m_sz_34Msg,sztemp,187);
  893. //GetDataSection();
  894. }