PB9315.cpp 30 KB

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