Module_LcmControl.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  1. #include "Module_LcmContro.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. energy -= 0.05;
  563. sprintf((char *) value, "%.1f kWh", energy);
  564. string2ByteArray(value, cmd);
  565. DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
  566. }
  567. void ChangeChargingPowerValue(float pow)
  568. {
  569. byte cmd[10];
  570. byte value[10];
  571. memset(cmd, 0x00, sizeof(cmd));
  572. // float min = 0.0;
  573. // float max = 50;
  574. // pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
  575. sprintf((char *) value, "%.1f kW", pow);
  576. string2ByteArray(value, cmd);
  577. DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
  578. }
  579. void ChangeChargingFeeValue(float fee)
  580. {
  581. byte cmd[10];
  582. byte value[10];
  583. memset(cmd, 0x00, sizeof(cmd));
  584. sprintf((char *) value, "%.2f", fee);
  585. string2ByteArray(value, cmd);
  586. DisplayValueToLcm(__charging_fee_tx, cmd, sizeof(cmd));
  587. }
  588. void DisplayMoneyRate(float money)
  589. {
  590. byte cmd[8];
  591. byte value[8];
  592. memset(cmd, 0x00, sizeof(cmd));
  593. sprintf((char *) value, "%.2f", money);
  594. string2ByteArray(value, cmd);
  595. DisplayValueToLcm(__money_by_rate, cmd, sizeof(cmd));
  596. }
  597. void DisplayMoneyCur(byte *cur)
  598. {
  599. byte cmd[5];
  600. byte buf[5];
  601. *(cur + 3) = '\0';
  602. memset(cmd, 0x00, sizeof(cmd));
  603. sprintf((char *) buf, "%s", cur);
  604. string2ByteArray(buf, cmd);
  605. DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
  606. }
  607. void RefreshPageAnimation(byte value)
  608. {
  609. switch(_currentPage)
  610. {
  611. case _LCM_IDLE:
  612. {
  613. }
  614. break;
  615. case _LCM_WAIT_FOR_PLUG:
  616. {
  617. if(_everyPageRollChange == 0)
  618. ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
  619. else if(_everyPageRollChange == 15)
  620. ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
  621. _everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  622. }
  623. break;
  624. case _LCM_PRE_CHARGE:
  625. case _LCM_CHARGING:
  626. case _LCM_COMPLETE:
  627. {
  628. if (_currentPage == _LCM_PRE_CHARGE)
  629. {
  630. if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
  631. ChangeDisplay2Value(__conn_line, _conn_map1);
  632. else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
  633. ChangeDisplay2Value(__conn_line, _conn_map2);
  634. }
  635. else if (_currentPage == _LCM_CHARGING)
  636. {
  637. if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
  638. ChangeDisplay2Value(__conn_line_chag, _charging_map1);
  639. else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
  640. ChangeDisplay2Value(__conn_line_chag, _charging_map2);
  641. }
  642. else if (_currentPage == _LCM_COMPLETE)
  643. {
  644. if (_everyPageRollChange == 0)
  645. ChangeDisplay2Value(__conn_line_comp, _complete_map);
  646. }
  647. _everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  648. }
  649. break;
  650. }
  651. }
  652. void RefreshConnStatus()
  653. {
  654. // Wifi priority is higher than Ethernet
  655. if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES)
  656. {
  657. _wifi_conn_status = true;
  658. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  659. ChangeDisplay2Value(__ethernet_status, _disappear);
  660. }
  661. else
  662. {
  663. _wifi_conn_status = false;
  664. ChangeDisplay2Value(__wifi_status, _disappear);
  665. }
  666. if (!_wifi_conn_status)
  667. {
  668. if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
  669. {
  670. ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
  671. }
  672. else
  673. {
  674. ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
  675. }
  676. }
  677. // 連線到後台
  678. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES)
  679. ChangeDisplay2Value(__conn_status, _connect);
  680. else
  681. ChangeDisplay2Value(__conn_status, _disconnect);
  682. }
  683. byte FirstPageChanged()
  684. {
  685. byte result = NO;
  686. if (_currentPage != _oldPage)
  687. {
  688. result = YES;
  689. _oldPage = _currentPage;
  690. }
  691. return result;
  692. }
  693. void ProcessPageInfo()
  694. {
  695. switch(_currentPage)
  696. {
  697. case _LCM_IDLE:
  698. {
  699. if (ShmSysConfigAndInfo->SysConfig.isRFID)
  700. ChangeDisplay2Value(__main_rfid, _main_rfid);
  701. else
  702. ChangeDisplay2Value(__main_rfid, _main_none_rfid);
  703. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  704. ChangeDisplay2Value(__main_qr, _main_qr);
  705. else
  706. {
  707. ChangeDisplay2Value(__qr_code, _disappear);
  708. ChangeDisplay2Value(__main_qr, _main_none_qr);
  709. needReloadQr = true;
  710. }
  711. if (ShmSysConfigAndInfo->SysConfig.isAPP)
  712. ChangeDisplay2Value(__main_app, _main_app);
  713. else
  714. ChangeDisplay2Value(__main_app, _main_none_app);
  715. if (FirstPageChanged() == YES || needReloadQr)
  716. {
  717. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  718. {
  719. needReloadQr = false;
  720. ChangeQrCode_Idle("http://google.com.tw");
  721. }
  722. }
  723. }
  724. break;
  725. case _LCM_AUTHORIZING:
  726. case _LCM_AUTHORIZ_COMP:
  727. case _LCM_AUTHORIZ_FAIL:
  728. case _LCM_WAIT_FOR_PLUG:
  729. {
  730. FirstPageChanged();
  731. }
  732. break;
  733. case _LCM_PRE_CHARGE:
  734. case _LCM_CHARGING:
  735. case _LCM_COMPLETE:
  736. {
  737. if (_totalCount + acgunCount >= 2)
  738. {
  739. if (ShmSysConfigAndInfo->SysConfig.isRFID)
  740. ChangeDisplay2Value(__side_top, _side_rfid);
  741. else
  742. ChangeDisplay2Value(__side_top, _side_none_rfid);
  743. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  744. ChangeDisplay2Value(__side_mid, _side_qr);
  745. else
  746. {
  747. ChangeDisplay2Value(__qr_code_pre, _disappear);
  748. ChangeDisplay2Value(__side_mid, _side_none_qr);
  749. needReloadQr = true;
  750. }
  751. if (ShmSysConfigAndInfo->SysConfig.isAPP)
  752. ChangeDisplay2Value(__side_down, _side_app);
  753. else
  754. ChangeDisplay2Value(__side_down, _side_none_app);
  755. }
  756. else
  757. {
  758. ChangeDisplay2Value(__side_top, _disappear);
  759. ChangeDisplay2Value(__side_mid, _disappear);
  760. ChangeDisplay2Value(__side_down, _disappear);
  761. }
  762. bool isShowAc = false;
  763. if (acgunCount > 0)
  764. {
  765. if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc != NO_DEFINE)
  766. {
  767. isShowAc = true;
  768. ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_light);
  769. if (_currentPage == _LCM_CHARGING)
  770. {
  771. ChangeAcBattMapAndValue(_LCM_CHARGING);
  772. if (ac_chargingInfo[0]->RemainChargingDuration >= 0)
  773. ChangeRemainTime(ac_chargingInfo[0]->RemainChargingDuration);
  774. else
  775. ChangeRemainTime(0);
  776. if (ac_chargingInfo[0]->PresentChargingPower >= 0.1)
  777. ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
  778. else
  779. ChangeChargingPowerValue(0);
  780. if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1)
  781. ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
  782. else
  783. ChangeChargingEnergyValue(0);
  784. if (strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == 0)
  785. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  786. else
  787. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  788. }
  789. else if (_currentPage == _LCM_COMPLETE)
  790. {
  791. ChangeAcBattMapAndValue(_LCM_COMPLETE);
  792. if (ac_chargingInfo[0]->RemainChargingDuration >= 0)
  793. ChangeRemainTime(ac_chargingInfo[0]->RemainChargingDuration);
  794. else
  795. ChangeRemainTime(0);
  796. if (ac_chargingInfo[0]->PresentChargingPower >= 0.1)
  797. ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
  798. else
  799. ChangeChargingPowerValue(0);
  800. if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1)
  801. {
  802. ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
  803. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  804. ac_chargingInfo[0]->ChargingFee >= 0)
  805. {
  806. ChangeChargingFeeValue(ac_chargingInfo[0]->ChargingFee);
  807. }
  808. }
  809. else
  810. {
  811. ChangeChargingEnergyValue(0);
  812. ChangeChargingFeeValue(0);
  813. }
  814. if(!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  815. {
  816. ChangeDisplay2Value(__charging_fee_map, _disappear);
  817. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  818. }
  819. else
  820. {
  821. ChangeDisplay2Value(__charging_fee_map, _money_map);
  822. }
  823. }
  824. }
  825. else
  826. ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_dark);
  827. }
  828. else
  829. ChangeDisplay2Value(__gun_type_index + (2 * 2), _disappear);
  830. for(byte i = 0; i < _totalCount; i++)
  831. {
  832. switch(_chargingInfoData[i]->Type)
  833. {
  834. case _Type_Chademo:
  835. {
  836. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
  837. {
  838. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_light);
  839. }
  840. else
  841. {
  842. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_dark);
  843. }
  844. }
  845. break;
  846. case _Type_GB:
  847. {
  848. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
  849. {
  850. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_light);
  851. }
  852. else
  853. {
  854. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_dark);
  855. }
  856. }
  857. break;
  858. case _Type_CCS_2:
  859. {
  860. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
  861. {
  862. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_light);
  863. }
  864. else
  865. {
  866. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_dark);
  867. }
  868. }
  869. break;
  870. }
  871. if (_currentPage == _LCM_CHARGING && !isShowAc)
  872. {
  873. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
  874. {
  875. ChangeBattMapAndValue(_LCM_CHARGING, _chargingInfoData[i]->EvBatterySoc);
  876. if (_chargingInfoData[i]->RemainChargingDuration >= 0)
  877. ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
  878. else
  879. ChangeRemainTime(0);
  880. if (_chargingInfoData[i]->PresentChargingPower >= 0)
  881. ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
  882. else
  883. ChangeChargingPowerValue(0);
  884. if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1)
  885. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  886. else
  887. ChangeChargingEnergyValue(0);
  888. if (strcmp((char *)_chargingInfoData[i]->StartUserId, "") == 0)
  889. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  890. else
  891. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  892. }
  893. }
  894. else if (_currentPage == _LCM_COMPLETE && !isShowAc)
  895. {
  896. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
  897. {
  898. ChangeBattMapAndValue(_LCM_COMPLETE, _chargingInfoData[i]->EvBatterySoc);
  899. if (_chargingInfoData[i]->RemainChargingDuration >= 0)
  900. ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
  901. else
  902. ChangeRemainTime(0);
  903. if (_chargingInfoData[i]->PresentChargingPower >= 0)
  904. ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
  905. else
  906. ChangeChargingPowerValue(0);
  907. if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1)
  908. {
  909. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  910. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  911. _chargingInfoData[i]->ChargingFee >= 0)
  912. {
  913. ChangeChargingFeeValue(_chargingInfoData[i]->ChargingFee);
  914. }
  915. }
  916. else
  917. {
  918. ChangeChargingEnergyValue(0);
  919. ChangeChargingFeeValue(0);
  920. }
  921. if(!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  922. {
  923. ChangeDisplay2Value(__charging_fee_map, _disappear);
  924. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  925. }
  926. else
  927. {
  928. ChangeDisplay2Value(__charging_fee_map, _money_map);
  929. }
  930. }
  931. }
  932. }
  933. // gun btn and QR code
  934. if (_totalCount + acgunCount >= 2 && _currentPage)
  935. {
  936. byte index = 0;
  937. for(index = 0; index < _totalCount; index++)
  938. {
  939. if(ShmSysConfigAndInfo->SysInfo.CurGunSelected != index)
  940. {
  941. break;
  942. }
  943. }
  944. if (_chargingInfoData[index]->SystemStatus == S_IDLE ||
  945. _chargingInfoData[index]->SystemStatus == S_RESERVATION ||
  946. _chargingInfoData[index]->SystemStatus == S_BOOTING)
  947. {
  948. if (FirstPageChanged() == YES || needReloadQr)
  949. {
  950. if (ShmSysConfigAndInfo->SysConfig.isQRCode)
  951. {
  952. needReloadQr = false;
  953. ChangeQrCode_Charge("http://google.com.tw");
  954. }
  955. }
  956. }
  957. }
  958. }
  959. break;
  960. }
  961. }
  962. void ChangeDisplayMoneyInfo()
  963. {
  964. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  965. {
  966. struct timeb csuTime;
  967. struct tm *tmCSU;
  968. ftime(&csuTime);
  969. tmCSU = localtime(&csuTime.time);
  970. ChangeDisplay2Value(__money_rate_map, _charging_money);
  971. if (tmCSU->tm_hour <= 23)
  972. {
  973. ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = ShmSysConfigAndInfo->SysConfig.BillingData.Fee[tmCSU->tm_hour];
  974. DisplayMoneyRate(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
  975. }
  976. if (ShmSysConfigAndInfo->SysConfig.BillingData.Currency <= 53)
  977. DisplayMoneyCur((byte *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
  978. }
  979. else
  980. {
  981. ChangeDisplay2Value(__money_rate_map, _disappear);
  982. ChangeDisplay2Value(__money_by_rate, _disappear);
  983. ChangeDisplay2Value(__money_rate, _disappear);
  984. }
  985. }
  986. void Initialization()
  987. {
  988. bool isPass = false;
  989. byte count = 5;
  990. while(!isPass && count > 0)
  991. {
  992. isPass = true;
  993. for (byte _index = 0; _index < _totalCount; _index++)
  994. {
  995. if (!FindChargingInfoData(_index, &_chargingInfoData[0]))
  996. {
  997. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  998. isPass = false;
  999. count--;
  1000. break;
  1001. }
  1002. }
  1003. }
  1004. isPass = false;
  1005. if (acgunCount > 0)
  1006. {
  1007. while(!isPass)
  1008. {
  1009. isPass = true;
  1010. for (byte _index = 0; _index < acgunCount; _index++)
  1011. {
  1012. if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0]))
  1013. {
  1014. DEBUG_ERROR("EvComm : FindAcChargingInfoData false \n");
  1015. isPass = false;
  1016. break;
  1017. }
  1018. }
  1019. }
  1020. }
  1021. if (count == 0)
  1022. PRINTF_FUNC("LCM Initialization Gun Fail.............\n");
  1023. }
  1024. int main(void)
  1025. {
  1026. if(InitShareMemory() == FAIL)
  1027. {
  1028. #ifdef SystemLogMessage
  1029. DEBUG_ERROR("InitShareMemory NG\n");
  1030. #endif
  1031. if (ShmStatusCodeData != NULL)
  1032. {
  1033. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  1034. }
  1035. sleep(5);
  1036. return 0;
  1037. }
  1038. _port = CreateCommunicationLcmPort();
  1039. byte changeWarningPriority = 0;
  1040. byte curWarningCount = 255;
  1041. ChangeBackLight(true);
  1042. _totalCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  1043. acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
  1044. Initialization();
  1045. //ChangeToOtherPage(_LCM_COMPLETE);
  1046. //return 0;
  1047. while(_port != -1)
  1048. {
  1049. if (strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName) != 0x00)
  1050. {
  1051. GetCurrentPage();
  1052. sleep(1);
  1053. }
  1054. else
  1055. {
  1056. //DemoFunction();
  1057. // Warning 處理
  1058. if(curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
  1059. {
  1060. changeWarningPriority = 0;
  1061. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1062. curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
  1063. ChangeWarningFunc();
  1064. }
  1065. else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0)
  1066. {
  1067. // 當有兩頁 Warning 則每隔三秒改變一次
  1068. if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
  1069. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
  1070. else
  1071. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1072. ChangeWarningFunc();
  1073. }
  1074. // 頁面資訊處理
  1075. ProcessPageInfo();
  1076. // 網路 - wifi - 連線訊號處理
  1077. RefreshConnStatus();
  1078. // 換頁處理
  1079. ChangeCurPage();
  1080. RefreshPageAnimation(_everyPageRollChange);
  1081. if (changeWarningPriority == 0)
  1082. ChangeDisplayMoneyInfo();
  1083. changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);
  1084. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1085. usleep(100000);
  1086. }
  1087. }
  1088. CloseCommunicationLcmPort();
  1089. return FAIL;
  1090. }