Module_LcmControl.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. #include "Module_LcmControl.h"
  2. bool needReloadQr = true;
  3. void PRINTF_FUNC(char *string, ...);
  4. int StoreLogMsg(const char *fmt, ...);
  5. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  6. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  7. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  8. char* getTimeString(void);
  9. //=================================
  10. // Common routine
  11. //=================================
  12. int StoreLogMsg(const char *fmt, ...)
  13. {
  14. char Buf[4096+256];
  15. char buffer[4096];
  16. time_t CurrentTime;
  17. struct tm *tm;
  18. va_list args;
  19. va_start(args, fmt);
  20. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  21. va_end(args);
  22. memset(Buf,0,sizeof(Buf));
  23. CurrentTime = time(NULL);
  24. tm=localtime(&CurrentTime);
  25. sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  26. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
  27. buffer,
  28. tm->tm_year+1900,tm->tm_mon+1);
  29. system(Buf);
  30. return rc;
  31. }
  32. char* getTimeString(void)
  33. {
  34. char *result=malloc(21);
  35. time_t timep;
  36. struct tm *p;
  37. time(&timep);
  38. p=gmtime(&timep);
  39. sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
  40. return result;
  41. }
  42. void PRINTF_FUNC(char *string, ...)
  43. {
  44. va_list args;
  45. char buffer[4096];
  46. va_start(args, string);
  47. vsnprintf(buffer, sizeof(buffer), string, args);
  48. va_end(args);
  49. if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
  50. printf("%s \n", buffer);
  51. else
  52. DEBUG_INFO("%s \n", buffer);
  53. }
  54. //==========================================
  55. // Init all share memory
  56. //==========================================
  57. int InitShareMemory()
  58. {
  59. int result = PASS;
  60. int MeterSMId;
  61. //creat ShmSysConfigAndInfo
  62. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  63. {
  64. #ifdef SystemLogMessage
  65. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  66. #endif
  67. result = FAIL;
  68. }
  69. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  70. {
  71. #ifdef SystemLogMessage
  72. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  73. #endif
  74. result = FAIL;
  75. }
  76. else
  77. {}
  78. //creat ShmStatusCodeData
  79. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  80. {
  81. #ifdef SystemLogMessage
  82. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  83. #endif
  84. result = FAIL;
  85. }
  86. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  87. {
  88. #ifdef SystemLogMessage
  89. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  90. #endif
  91. result = FAIL;
  92. }
  93. else
  94. {}
  95. return result;
  96. }
  97. //==========================================
  98. // Open and Close RS232 and R/W
  99. //==========================================
  100. int CreateCommunicationLcmPort()
  101. {
  102. int fd;
  103. struct termios tios;
  104. fd = open(pPortName, O_RDWR);
  105. if (fd <= 0) {
  106. #ifdef SystemLogMessage
  107. DEBUG_ERROR("open /dev/ttyS3 NG \n");
  108. #endif
  109. return -1;
  110. }
  111. ioctl(fd, TCGETS, &tios);
  112. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  113. tios.c_lflag = 0;
  114. tios.c_iflag = 0;
  115. tios.c_oflag = 0;
  116. tios.c_cc[VMIN] = 0;
  117. tios.c_cc[VTIME] = (unsigned char) 5;
  118. tios.c_lflag = 0;
  119. tcflush(fd, TCIFLUSH);
  120. ioctl(fd, TCSETS, &tios);
  121. return fd;
  122. }
  123. void CloseCommunicationLcmPort()
  124. {
  125. close(_port);
  126. }
  127. void WriteCmdToLcm(byte *cmd, byte cmdLen)
  128. {
  129. int len = write(_port, cmd, cmdLen);
  130. if(len >= sizeof(cmd))
  131. {
  132. //PRINTF_FUNC("Write cmd to LCM successfully. \n");
  133. }
  134. }
  135. void ReadMsgFromLcm(byte *msg, byte readLen)
  136. {
  137. read(_port, msg, readLen);
  138. if(*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2)
  139. {
  140. if(*(msg + 3) == CMD_WRITE)
  141. {
  142. switch (*(msg + 4))
  143. {
  144. case CMD_REGISTER:
  145. {
  146. // 頁面
  147. strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
  148. }
  149. break;
  150. }
  151. }
  152. else if (*(msg + 3) == CMD_MULTI_READ)
  153. {
  154. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  155. // {
  156. // case BUTTON_GUN_INDEX:
  157. // {
  158. // // 當前選的槍號
  159. // _curGunIndex = (*(msg + 8));
  160. // }
  161. // break;
  162. // }
  163. }
  164. }
  165. }
  166. //================================================
  167. // Function
  168. //================================================
  169. void ChangeToOtherPage(short newPage)
  170. {
  171. byte cmd[7];
  172. memset(cmd, 0x00, sizeof(cmd));
  173. cmd[0] = CMD_TITLE_1;
  174. cmd[1] = CMD_TITLE_2;
  175. cmd[2] = 0x02 + sizeof(newPage);
  176. cmd[3] = CMD_READ;
  177. cmd[4] = CMD_REGISTER;
  178. cmd[5] = newPage >> 8;
  179. cmd[6] = newPage & 0x00FF;
  180. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  181. usleep(100000);
  182. }
  183. void ChangeBackLight(bool islight)
  184. {
  185. byte value = 0x01;
  186. if (islight)
  187. {
  188. value = 0x20;
  189. }
  190. byte cmd[7];
  191. memset(cmd, 0x00, sizeof(cmd));
  192. cmd[0] = CMD_TITLE_1;
  193. cmd[1] = CMD_TITLE_2;
  194. cmd[2] = 0x03;
  195. cmd[3] = CMD_READ;
  196. cmd[4] = CMD_BACKLIGHT;
  197. cmd[5] = value;
  198. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  199. usleep(100000);
  200. }
  201. void GetCurrentPage()
  202. {
  203. byte cmd[6];
  204. memset(cmd, 0x00, sizeof(cmd));
  205. byte msg[8];
  206. memset(msg, 0x00, sizeof(msg));
  207. cmd[0] = CMD_TITLE_1;
  208. cmd[1] = CMD_TITLE_2;
  209. cmd[2] = 0x03; // 底下總長度
  210. cmd[3] = CMD_WRITE;
  211. cmd[4] = CMD_REGISTER;
  212. cmd[5] = 0x02;
  213. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  214. usleep(100000);
  215. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  216. }
  217. void DisplayValueToLcm(short address, byte *data, byte len)
  218. {
  219. byte cmd[256];
  220. memset(cmd, 0x00, sizeof(cmd));
  221. cmd[0] = CMD_TITLE_1;
  222. cmd[1] = CMD_TITLE_2;
  223. cmd[2] = 0x03 + len;
  224. cmd[3] = CMD_MULTI_WRITE;
  225. cmd[4] = address >> 8;
  226. cmd[5] = address & 0x00FF;
  227. for(byte count = 0; count < len; count++)
  228. {
  229. cmd[6 + count] = *(data + count);
  230. }
  231. WriteCmdToLcm(cmd, cmd[2] + 3);
  232. }
  233. void ChangeDisplay2Value(short address, short value)
  234. {
  235. byte data[2];
  236. data[0] = value >> 8;
  237. data[1] = value & 0x00FF;
  238. DisplayValueToLcm(address, data, sizeof(data));
  239. }
  240. void GetBtnStatus(short address, byte len)
  241. {
  242. byte cmd[8];
  243. memset(cmd, 0x00, sizeof(cmd));
  244. byte msg[8];
  245. memset(msg, 0x00, sizeof(msg));
  246. cmd[0] = CMD_TITLE_1;
  247. cmd[1] = CMD_TITLE_2;
  248. cmd[2] = 0x03 + len;
  249. cmd[3] = CMD_MULTI_READ;
  250. cmd[4] = address >> 8;
  251. cmd[5] = address & 0x00FF;
  252. cmd[6] = 0x00 + len;
  253. WriteCmdToLcm(cmd, cmd[2] + 3);
  254. usleep(100000);
  255. ReadMsgFromLcm(msg, (len * 2) + sizeof(msg));
  256. }
  257. //================================================
  258. // Warning process
  259. //================================================
  260. void string2ByteArray(unsigned char *input, byte *output)
  261. {
  262. int loop;
  263. int i;
  264. loop = 0;
  265. i = 0;
  266. while(input[loop] != '\0')
  267. {
  268. output[i++] = input[loop++];
  269. }
  270. output[loop] = '\0';
  271. }
  272. void ChangeWarningFunc()
  273. {
  274. byte cmd[7];
  275. byte i = 0;
  276. //PRINTF_FUNC("ChangeWarningFunc \n");
  277. // 最多一次五筆
  278. //PRINTF_FUNC("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
  279. //PRINTF_FUNC("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
  280. for(i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
  281. {
  282. memset(cmd, 0x00, sizeof(cmd));
  283. if(i >= 5)
  284. {
  285. break;
  286. }
  287. //error code
  288. string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
  289. DisplayValueToLcm(0x0010 + (i * 6), cmd, sizeof(cmd));
  290. //警告標示
  291. memset(cmd, 0x00, sizeof(cmd));
  292. cmd[0] = 0x00;
  293. cmd[1] = 0x01;
  294. DisplayValueToLcm(0x0002 + (i * 2), cmd, 2);
  295. }
  296. memset(cmd, 0x00, sizeof(cmd));
  297. for(; i < 5; i++)
  298. {
  299. DisplayValueToLcm(0x0010 + (i * 6), cmd, sizeof(cmd));
  300. DisplayValueToLcm(0x0002 + (i * 2), cmd, 2);
  301. }
  302. }
  303. //================================================
  304. // QR Code process
  305. //================================================
  306. void ChangeQrCode_Idle(char *input)
  307. {
  308. int len = strlen(input);
  309. byte cmd[len];
  310. int loop = 0;
  311. int i = 0;
  312. while(input[loop] != '\0')
  313. {
  314. cmd[i++] = input[loop++];
  315. }
  316. DisplayValueToLcm(__qr_code, cmd, len);
  317. }
  318. void ChangeQrCode_Charge(char *input)
  319. {
  320. int len = strlen(input);
  321. byte cmd[len];
  322. int loop = 0;
  323. int i = 0;
  324. while(input[loop] != '\0')
  325. {
  326. cmd[i++] = input[loop++];
  327. }
  328. DisplayValueToLcm(__qr_code_pre, cmd, len);
  329. }
  330. //================================================
  331. // Change current page
  332. //================================================
  333. void ChangeCurPage()
  334. {
  335. //PRINTF_FUNC("cur = %d, new = %d \n", _currentPage, ShmSysConfigAndInfo->SysInfo.PageIndex);
  336. if (_currentPage != ShmSysConfigAndInfo->SysInfo.PageIndex)
  337. {
  338. _currentPage = ShmSysConfigAndInfo->SysInfo.PageIndex;
  339. ChangeToOtherPage(_currentPage);
  340. _everyPageRollChange = 0;
  341. }
  342. }
  343. //================================================
  344. // Main process
  345. //================================================
  346. byte demoCount = 0;
  347. void DemoFunction()
  348. {
  349. if (demoCount == 0)
  350. {
  351. ShmSysConfigAndInfo->SysWarningInfo.WarningCount = 6;
  352. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[0][0], "000001", 7);
  353. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[1][0], "000002", 7);
  354. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[2][0], "000003", 7);
  355. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[3][0], "000004", 7);
  356. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[4][0], "000005", 7);
  357. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[5][0], "000006", 7);
  358. }
  359. else
  360. {
  361. if (demoCount == 20) {
  362. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_IDLE;
  363. } else if (demoCount == 80) {
  364. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZING;
  365. } else if (demoCount == 100) {
  366. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_COMP;
  367. } else if (demoCount == 120) {
  368. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_FAIL;
  369. } else if (demoCount == 140) {
  370. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_PRE_CHARGE;
  371. } else if (demoCount == 180) {
  372. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_CHARGING;
  373. }
  374. }
  375. if (demoCount < 180)
  376. demoCount++;
  377. }
  378. //================================================
  379. // Main process
  380. //================================================
  381. bool FindChargingInfoData(byte target, struct ChargingInfoData **_chargingData)
  382. {
  383. for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
  384. {
  385. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
  386. {
  387. _chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
  388. return true;
  389. }
  390. }
  391. for (byte index = 0; index < CCS_QUANTITY; index++)
  392. {
  393. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
  394. {
  395. _chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
  396. return true;
  397. }
  398. }
  399. for (byte index = 0; index < GB_QUANTITY; index++)
  400. {
  401. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
  402. {
  403. _chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
  404. return true;
  405. }
  406. }
  407. return false;
  408. }
  409. bool FindAcChargingInfoData(byte target, struct ChargingInfoData **acChargingData)
  410. {
  411. if (target < AC_QUANTITY)
  412. {
  413. acChargingData[target] = &ShmSysConfigAndInfo->SysInfo.AcChargingData[target];
  414. return true;
  415. }
  416. return false;
  417. }
  418. void ChangeAcBattMapAndValue(short page)
  419. {
  420. if (page == _LCM_CHARGING)
  421. {
  422. if (isDiffStatus != _battery_display_ani)
  423. {
  424. isChangeBattMap = false;
  425. isDiffStatus = _battery_display_ani;
  426. }
  427. if (ac_chargingInfo[0]->IsCharging && !isChangeBattMap)
  428. {
  429. isChangeBattMap = true;
  430. if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5)
  431. {
  432. ChangeDisplay2Value(__batt_map, _battery_empty);
  433. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_EMP;
  434. }
  435. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP)
  436. {
  437. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  438. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV1;
  439. }
  440. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1)
  441. {
  442. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  443. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV2;
  444. }
  445. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2)
  446. {
  447. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  448. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV3;
  449. }
  450. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3)
  451. {
  452. ChangeDisplay2Value(__batt_map, _battery_cap_80);
  453. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV4;
  454. }
  455. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4)
  456. {
  457. ChangeDisplay2Value(__batt_map, _battery_cap_100);
  458. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
  459. }
  460. }
  461. }
  462. else if (page == _LCM_COMPLETE)
  463. {
  464. if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5)
  465. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  466. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP)
  467. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  468. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1)
  469. ChangeDisplay2Value(__batt_map, _battery_soc_40);
  470. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2)
  471. ChangeDisplay2Value(__batt_map, _battery_soc_60);
  472. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3)
  473. ChangeDisplay2Value(__batt_map, _battery_soc_80);
  474. else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4)
  475. ChangeDisplay2Value(__batt_map, _battery_soc_100);
  476. }
  477. ChangeDisplay2Value(__soc_value_charging, _disappear);
  478. }
  479. void ChangeBattMapAndValue(short page, int soc)
  480. {
  481. // srand(time(NULL));
  482. // int min = 10;
  483. // int max = 90;
  484. // soc = rand() % (max - min + 1) + min;
  485. if (page == _LCM_CHARGING)
  486. {
  487. if (soc < 20)
  488. {
  489. if (_battery_display_ani)
  490. ChangeDisplay2Value(__batt_map, _battery_empty);
  491. else
  492. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  493. }
  494. else if (soc >= 20 && soc < 40)
  495. {
  496. if (_battery_display_ani)
  497. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  498. else
  499. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  500. }
  501. else if (soc >= 40 && soc < 60)
  502. {
  503. if (_battery_display_ani)
  504. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  505. else
  506. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  507. }
  508. else if (soc >= 60 && soc < 80)
  509. {
  510. if (_battery_display_ani)
  511. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  512. else
  513. ChangeDisplay2Value(__batt_map, _battery_cap_80);
  514. }
  515. else if (soc >= 80 && soc <= 100)
  516. ChangeDisplay2Value(__batt_map, _battery_cap_100);
  517. }
  518. else if (page == _LCM_COMPLETE)
  519. {
  520. if (soc < 20)
  521. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  522. else if (soc >= 20 && soc < 40)
  523. ChangeDisplay2Value(__batt_map, _battery_soc_40);
  524. else if (soc >= 40 && soc < 60)
  525. ChangeDisplay2Value(__batt_map, _battery_soc_60);
  526. else if (soc >= 60 && soc < 80)
  527. ChangeDisplay2Value(__batt_map, _battery_soc_80);
  528. else if (soc >= 80 && soc <= 100)
  529. ChangeDisplay2Value(__batt_map, _battery_soc_100);
  530. }
  531. byte cmd[5];
  532. byte value[5];
  533. memset(cmd, 0x00, sizeof(cmd));
  534. memset(value, 0x00, sizeof(value));
  535. sprintf((char *)value, "%d%%", soc);
  536. string2ByteArray(value, cmd);
  537. DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
  538. }
  539. void ChangeRemainTime(int sec)
  540. {
  541. int h, m, s;
  542. byte cmd[10];
  543. byte value[10];
  544. memset(cmd, 0x00, sizeof(cmd));
  545. // srand(time(NULL));
  546. // int min = 0;
  547. // int max = 65536;
  548. // sec = rand() % (max - min + 1) + min;
  549. h = (sec / 3600);
  550. m = (sec - (3600 * h)) / 60;
  551. s = (sec - (3600 * h) - (m * 60));
  552. sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
  553. string2ByteArray(value, cmd);
  554. DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
  555. }
  556. void ChangeChargingEnergyValue(float energy)
  557. {
  558. byte cmd[10];
  559. byte value[10];
  560. memset(cmd, 0x00, sizeof(cmd));
  561. if (energy >= 0.05)
  562. {
  563. energy -= 0.05;
  564. }
  565. sprintf((char *) value, "%.1f kWh", energy);
  566. string2ByteArray(value, cmd);
  567. DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
  568. }
  569. void ChangeChargingPowerValue(float pow)
  570. {
  571. byte cmd[10];
  572. byte value[10];
  573. memset(cmd, 0x00, sizeof(cmd));
  574. // float min = 0.0;
  575. // float max = 50;
  576. // pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
  577. sprintf((char *) value, "%.1f kW", pow);
  578. string2ByteArray(value, cmd);
  579. DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
  580. }
  581. void ChangeChargingFeeValue(float fee)
  582. {
  583. byte cmd[10];
  584. byte value[10];
  585. memset(cmd, 0x00, sizeof(cmd));
  586. sprintf((char *) value, "%.2f", fee);
  587. string2ByteArray(value, cmd);
  588. DisplayValueToLcm(__charging_fee_tx, cmd, sizeof(cmd));
  589. }
  590. void DisplayMoneyRate(float money)
  591. {
  592. byte cmd[8];
  593. byte value[8];
  594. memset(cmd, 0x00, sizeof(cmd));
  595. sprintf((char *) value, "%.2f", money);
  596. string2ByteArray(value, cmd);
  597. DisplayValueToLcm(__money_by_rate, cmd, sizeof(cmd));
  598. }
  599. void DisplayMoneyCur(byte *cur)
  600. {
  601. byte cmd[5];
  602. byte buf[5];
  603. *(cur + 3) = '\0';
  604. memset(cmd, 0x00, sizeof(cmd));
  605. sprintf((char *) buf, "%s", cur);
  606. string2ByteArray(buf, cmd);
  607. DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
  608. }
  609. void RefreshPageAnimation(byte value)
  610. {
  611. switch(_currentPage)
  612. {
  613. case _LCM_IDLE:
  614. {
  615. }
  616. break;
  617. case _LCM_WAIT_FOR_PLUG:
  618. {
  619. if(_everyPageRollChange == 0)
  620. ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
  621. else if(_everyPageRollChange == 15)
  622. ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
  623. _everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  624. }
  625. break;
  626. case _LCM_PRE_CHARGE:
  627. case _LCM_CHARGING:
  628. case _LCM_COMPLETE:
  629. {
  630. if (_currentPage == _LCM_PRE_CHARGE)
  631. {
  632. if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
  633. ChangeDisplay2Value(__conn_line, _conn_map1);
  634. else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
  635. ChangeDisplay2Value(__conn_line, _conn_map2);
  636. }
  637. else if (_currentPage == _LCM_CHARGING)
  638. {
  639. if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
  640. ChangeDisplay2Value(__conn_line_chag, _charging_map1);
  641. else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
  642. ChangeDisplay2Value(__conn_line_chag, _charging_map2);
  643. }
  644. else if (_currentPage == _LCM_COMPLETE)
  645. {
  646. if (_everyPageRollChange == 0)
  647. ChangeDisplay2Value(__conn_line_comp, _complete_map);
  648. }
  649. _everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  650. }
  651. break;
  652. }
  653. }
  654. void RefreshConnStatus()
  655. {
  656. // Wifi priority is higher than Ethernet
  657. if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES)
  658. {
  659. _wifi_conn_status = true;
  660. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  661. ChangeDisplay2Value(__ethernet_status, _disappear);
  662. }
  663. else
  664. {
  665. _wifi_conn_status = false;
  666. ChangeDisplay2Value(__wifi_status, _disappear);
  667. }
  668. if (!_wifi_conn_status)
  669. {
  670. if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
  671. {
  672. ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
  673. }
  674. else
  675. {
  676. ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
  677. }
  678. }
  679. // 連線到後台
  680. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES)
  681. ChangeDisplay2Value(__conn_status, _connect);
  682. else
  683. ChangeDisplay2Value(__conn_status, _disconnect);
  684. }
  685. byte FirstPageChanged()
  686. {
  687. byte result = NO;
  688. if (_currentPage != _oldPage)
  689. {
  690. result = YES;
  691. _oldPage = _currentPage;
  692. }
  693. return result;
  694. }
  695. void ProcessPageInfo()
  696. {
  697. switch(_currentPage)
  698. {
  699. case _LCM_IDLE:
  700. {
  701. if (ShmSysConfigAndInfo->SysConfig.isRFID)
  702. ChangeDisplay2Value(__main_rfid, _main_rfid);
  703. else
  704. ChangeDisplay2Value(__main_rfid, _main_none_rfid);
  705. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  706. ChangeDisplay2Value(__main_qr, _main_qr);
  707. else
  708. {
  709. ChangeDisplay2Value(__qr_code, _disappear);
  710. ChangeDisplay2Value(__main_qr, _main_none_qr);
  711. needReloadQr = true;
  712. }
  713. if (ShmSysConfigAndInfo->SysConfig.isAPP)
  714. ChangeDisplay2Value(__main_app, _main_app);
  715. else
  716. ChangeDisplay2Value(__main_app, _main_none_app);
  717. if (FirstPageChanged() == YES || needReloadQr)
  718. {
  719. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  720. {
  721. needReloadQr = false;
  722. ChangeQrCode_Idle("http://google.com.tw");
  723. }
  724. }
  725. }
  726. break;
  727. case _LCM_AUTHORIZING:
  728. case _LCM_AUTHORIZ_COMP:
  729. case _LCM_AUTHORIZ_FAIL:
  730. case _LCM_WAIT_FOR_PLUG:
  731. {
  732. FirstPageChanged();
  733. }
  734. break;
  735. case _LCM_PRE_CHARGE:
  736. case _LCM_CHARGING:
  737. case _LCM_COMPLETE:
  738. {
  739. if (_totalCount + acgunCount >= 2)
  740. {
  741. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  742. if (ShmSysConfigAndInfo->SysConfig.isRFID)
  743. ChangeDisplay2Value(__side_top, _side_rfid);
  744. else
  745. ChangeDisplay2Value(__side_top, _side_none_rfid);
  746. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  747. ChangeDisplay2Value(__side_mid, _side_qr);
  748. else
  749. {
  750. ChangeDisplay2Value(__qr_code_pre, _disappear);
  751. ChangeDisplay2Value(__side_mid, _side_none_qr);
  752. needReloadQr = true;
  753. }
  754. if (ShmSysConfigAndInfo->SysConfig.isAPP)
  755. ChangeDisplay2Value(__side_down, _side_app);
  756. else
  757. ChangeDisplay2Value(__side_down, _side_none_app);
  758. }
  759. else
  760. {
  761. ChangeDisplay2Value(__side_top, _disappear);
  762. ChangeDisplay2Value(__side_mid, _disappear);
  763. ChangeDisplay2Value(__side_down, _disappear);
  764. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  765. }
  766. bool isShowAc = false;
  767. if (acgunCount > 0)
  768. {
  769. if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc != NO_DEFINE)
  770. {
  771. isShowAc = true;
  772. ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_light);
  773. if (_currentPage == _LCM_CHARGING)
  774. {
  775. ChangeAcBattMapAndValue(_LCM_CHARGING);
  776. if (ac_chargingInfo[0]->RemainChargingDuration >= 0)
  777. ChangeRemainTime(ac_chargingInfo[0]->RemainChargingDuration);
  778. else
  779. ChangeRemainTime(0);
  780. if (ac_chargingInfo[0]->PresentChargingPower >= 0.1)
  781. ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
  782. else
  783. ChangeChargingPowerValue(0);
  784. if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1)
  785. ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
  786. else
  787. ChangeChargingEnergyValue(0);
  788. if (strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == 0)
  789. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  790. else
  791. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  792. }
  793. else if (_currentPage == _LCM_COMPLETE)
  794. {
  795. ChangeAcBattMapAndValue(_LCM_COMPLETE);
  796. if (ac_chargingInfo[0]->RemainChargingDuration >= 0)
  797. ChangeRemainTime(ac_chargingInfo[0]->RemainChargingDuration);
  798. else
  799. ChangeRemainTime(0);
  800. if (ac_chargingInfo[0]->PresentChargingPower >= 0.1)
  801. ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
  802. else
  803. ChangeChargingPowerValue(0);
  804. if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1)
  805. {
  806. ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
  807. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  808. ac_chargingInfo[0]->ChargingFee >= 0)
  809. {
  810. ChangeChargingFeeValue(ac_chargingInfo[0]->ChargingFee);
  811. }
  812. }
  813. else
  814. {
  815. ChangeChargingEnergyValue(0);
  816. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  817. ChangeChargingFeeValue(0);
  818. }
  819. if(!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  820. {
  821. ChangeDisplay2Value(__charging_fee_map, _disappear);
  822. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  823. }
  824. else
  825. {
  826. ChangeDisplay2Value(__charging_fee_map, _money_map);
  827. }
  828. }
  829. }
  830. else
  831. ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_dark);
  832. }
  833. else
  834. ChangeDisplay2Value(__gun_type_index + (2 * 2), _disappear);
  835. for(byte i = 0; i < _totalCount; i++)
  836. {
  837. switch(_chargingInfoData[i]->Type)
  838. {
  839. case _Type_Chademo:
  840. {
  841. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
  842. {
  843. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_light);
  844. }
  845. else
  846. {
  847. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_dark);
  848. }
  849. }
  850. break;
  851. case _Type_GB:
  852. {
  853. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
  854. {
  855. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_light);
  856. }
  857. else
  858. {
  859. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_dark);
  860. }
  861. }
  862. break;
  863. case _Type_CCS_2:
  864. {
  865. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
  866. {
  867. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_light);
  868. }
  869. else
  870. {
  871. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_dark);
  872. }
  873. }
  874. break;
  875. }
  876. if (_currentPage == _LCM_CHARGING && !isShowAc)
  877. {
  878. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
  879. {
  880. ChangeBattMapAndValue(_LCM_CHARGING, _chargingInfoData[i]->EvBatterySoc);
  881. if (_chargingInfoData[i]->RemainChargingDuration >= 0)
  882. ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
  883. else
  884. ChangeRemainTime(0);
  885. if (_chargingInfoData[i]->PresentChargingPower >= 0)
  886. ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
  887. else
  888. ChangeChargingPowerValue(0);
  889. if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1)
  890. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  891. else
  892. ChangeChargingEnergyValue(0);
  893. if (strcmp((char *)_chargingInfoData[i]->StartUserId, "") == 0)
  894. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  895. else
  896. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  897. }
  898. }
  899. else if (_currentPage == _LCM_COMPLETE && !isShowAc)
  900. {
  901. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
  902. {
  903. ChangeBattMapAndValue(_LCM_COMPLETE, _chargingInfoData[i]->EvBatterySoc);
  904. if (_chargingInfoData[i]->RemainChargingDuration >= 0)
  905. ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
  906. else
  907. ChangeRemainTime(0);
  908. if (_chargingInfoData[i]->PresentChargingPower >= 0)
  909. ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
  910. else
  911. ChangeChargingPowerValue(0);
  912. if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1)
  913. {
  914. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  915. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  916. _chargingInfoData[i]->ChargingFee >= 0)
  917. {
  918. ChangeChargingFeeValue(_chargingInfoData[i]->ChargingFee);
  919. }
  920. }
  921. else
  922. {
  923. ChangeChargingEnergyValue(0);
  924. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  925. ChangeChargingFeeValue(0);
  926. }
  927. if(!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  928. {
  929. ChangeDisplay2Value(__charging_fee_map, _disappear);
  930. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  931. }
  932. else
  933. {
  934. ChangeDisplay2Value(__charging_fee_map, _money_map);
  935. }
  936. }
  937. }
  938. }
  939. // gun btn and QR code
  940. if (_totalCount + acgunCount >= 2 && _currentPage)
  941. {
  942. byte index = 0;
  943. for(index = 0; index < _totalCount; index++)
  944. {
  945. if(ShmSysConfigAndInfo->SysInfo.CurGunSelected != index)
  946. {
  947. break;
  948. }
  949. }
  950. if (_chargingInfoData[index]->SystemStatus == S_IDLE ||
  951. _chargingInfoData[index]->SystemStatus == S_RESERVATION ||
  952. _chargingInfoData[index]->SystemStatus == S_BOOTING)
  953. {
  954. if (FirstPageChanged() == YES || needReloadQr)
  955. {
  956. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  957. {
  958. needReloadQr = false;
  959. ChangeQrCode_Charge("http://google.com.tw");
  960. }
  961. }
  962. }
  963. }
  964. }
  965. break;
  966. }
  967. }
  968. void ChangeDisplayMoneyInfo()
  969. {
  970. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  971. {
  972. struct timeb csuTime;
  973. struct tm *tmCSU;
  974. ftime(&csuTime);
  975. tmCSU = localtime(&csuTime.time);
  976. ChangeDisplay2Value(__money_rate_map, _charging_money);
  977. if (tmCSU->tm_hour <= 23)
  978. {
  979. ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = ShmSysConfigAndInfo->SysConfig.BillingData.Fee[tmCSU->tm_hour];
  980. DisplayMoneyRate(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
  981. }
  982. if (ShmSysConfigAndInfo->SysConfig.BillingData.Currency <= 53)
  983. DisplayMoneyCur((byte *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
  984. }
  985. else
  986. {
  987. ChangeDisplay2Value(__money_rate_map, _disappear);
  988. ChangeDisplay2Value(__money_by_rate, _disappear);
  989. ChangeDisplay2Value(__money_rate, _disappear);
  990. }
  991. }
  992. void Initialization()
  993. {
  994. bool isPass = false;
  995. byte count = 5;
  996. while(!isPass && count > 0)
  997. {
  998. isPass = true;
  999. for (byte _index = 0; _index < _totalCount; _index++)
  1000. {
  1001. if (!FindChargingInfoData(_index, &_chargingInfoData[0]))
  1002. {
  1003. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  1004. isPass = false;
  1005. count--;
  1006. break;
  1007. }
  1008. }
  1009. }
  1010. isPass = false;
  1011. if (acgunCount > 0)
  1012. {
  1013. while(!isPass)
  1014. {
  1015. isPass = true;
  1016. for (byte _index = 0; _index < acgunCount; _index++)
  1017. {
  1018. if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0]))
  1019. {
  1020. DEBUG_ERROR("EvComm : FindAcChargingInfoData false \n");
  1021. isPass = false;
  1022. break;
  1023. }
  1024. }
  1025. }
  1026. }
  1027. if (count == 0)
  1028. PRINTF_FUNC("LCM Initialization Gun Fail.............\n");
  1029. }
  1030. int main(void)
  1031. {
  1032. if(InitShareMemory() == FAIL)
  1033. {
  1034. #ifdef SystemLogMessage
  1035. DEBUG_ERROR("InitShareMemory NG\n");
  1036. #endif
  1037. if (ShmStatusCodeData != NULL)
  1038. {
  1039. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  1040. }
  1041. sleep(5);
  1042. return 0;
  1043. }
  1044. _port = CreateCommunicationLcmPort();
  1045. byte changeWarningPriority = 0;
  1046. byte curWarningCount = 255;
  1047. ChangeBackLight(true);
  1048. _totalCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  1049. acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
  1050. Initialization();
  1051. //return 0;
  1052. while(_port != -1)
  1053. {
  1054. if (strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName) != 0x00)
  1055. {
  1056. GetCurrentPage();
  1057. sleep(1);
  1058. }
  1059. else
  1060. {
  1061. //DemoFunction();
  1062. // Warning 處理
  1063. if(curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
  1064. {
  1065. changeWarningPriority = 0;
  1066. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1067. curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
  1068. ChangeWarningFunc();
  1069. }
  1070. else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0)
  1071. {
  1072. // 當有兩頁 Warning 則每隔三秒改變一次
  1073. if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
  1074. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
  1075. else
  1076. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1077. ChangeWarningFunc();
  1078. }
  1079. // 頁面資訊處理
  1080. ProcessPageInfo();
  1081. // 網路 - wifi - 連線訊號處理
  1082. RefreshConnStatus();
  1083. // 換頁處理
  1084. ChangeCurPage();
  1085. RefreshPageAnimation(_everyPageRollChange);
  1086. if (changeWarningPriority == 0)
  1087. ChangeDisplayMoneyInfo();
  1088. changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);
  1089. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1090. usleep(100000);
  1091. }
  1092. }
  1093. CloseCommunicationLcmPort();
  1094. return FAIL;
  1095. }