Module_LcmControl.c 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036
  1. #include <stdint.h>
  2. #include "Module_LcmControl.h"
  3. #include "../Config.h"
  4. #include "../SelectGun/SelectGun.h"
  5. static SelectGunInfo *ShmSelectGunInfo = NULL;
  6. bool needReloadQr = true;
  7. bool _isShow = false; //DS60-120 add
  8. uint8_t _showInformIndex = 0; //DS60-120 add
  9. #define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  10. #define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  11. #define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  12. //=================================
  13. // Common routine
  14. //=================================
  15. int StoreLogMsg(const char *fmt, ...)
  16. {
  17. char Buf[4096 + 256];
  18. char buffer[4096];
  19. va_list args;
  20. struct timeb SeqEndTime;
  21. struct tm *tm;
  22. va_start(args, fmt);
  23. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  24. va_end(args);
  25. memset(Buf, 0, sizeof(Buf));
  26. ftime(&SeqEndTime);
  27. SeqEndTime.time = time(NULL);
  28. tm = localtime(&SeqEndTime.time);
  29. if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
  30. sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
  31. tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
  32. printf("%s \n", Buf);
  33. } else {
  34. sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  35. tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
  36. buffer,
  37. tm->tm_year + 1900, tm->tm_mon + 1);
  38. system(Buf);
  39. }
  40. return rc;
  41. }
  42. char *getTimeString(void)
  43. {
  44. char *result = malloc(21);
  45. time_t timep;
  46. struct tm *p;
  47. time(&timep);
  48. p = gmtime(&timep);
  49. 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);
  50. return result;
  51. }
  52. //==========================================
  53. // Init all share memory
  54. //==========================================
  55. int InitShareMemory()
  56. {
  57. int result = PASS;
  58. int MeterSMId;
  59. //creat ShmSysConfigAndInfo
  60. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0) {
  61. #ifdef SystemLogMessage
  62. log_error("shmget ShmSysConfigAndInfo NG\n");
  63. #endif
  64. result = FAIL;
  65. } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  66. #ifdef SystemLogMessage
  67. log_error("shmat ShmSysConfigAndInfo NG\n");
  68. #endif
  69. result = FAIL;
  70. } else
  71. {}
  72. //creat ShmStatusCodeData
  73. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0) {
  74. #ifdef SystemLogMessage
  75. log_error("shmget ShmStatusCodeData NG\n");
  76. #endif
  77. result = FAIL;
  78. } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  79. #ifdef SystemLogMessage
  80. log_error("shmat ShmStatusCodeData NG\n");
  81. #endif
  82. result = FAIL;
  83. } else
  84. {}
  85. //creat Audi customization info
  86. if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
  87. log_error("[main]CreatShareMemory:shmget select gun info NG \n");
  88. return 0;
  89. } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  90. log_error("[main]CreatShareMemory:shmat shmget select gun info \n");
  91. return 0;
  92. }
  93. //creat ShmStatusCodeData
  94. if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
  95. #ifdef SystemLogMessage
  96. log_error("shmget ShmPrimaryMcuData NG\n");
  97. #endif
  98. result = FAIL;
  99. } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  100. #ifdef ShmPrimaryMcuData
  101. log_error("shmat ShmPrimaryMcuData NG\n");
  102. #endif
  103. result = FAIL;
  104. }
  105. return result;
  106. }
  107. //==========================================
  108. // Open and Close RS232 and R/W
  109. //==========================================
  110. int CreateCommunicationLcmPort()
  111. {
  112. int fd;
  113. struct termios tios;
  114. fd = open(pPortName, O_RDWR);
  115. if (fd <= 0) {
  116. #ifdef SystemLogMessage
  117. log_error("open /dev/ttyS3 NG \n");
  118. #endif
  119. return -1;
  120. }
  121. ioctl(fd, TCGETS, &tios);
  122. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  123. tios.c_lflag = 0;
  124. tios.c_iflag = 0;
  125. tios.c_oflag = 0;
  126. tios.c_cc[VMIN] = 0;
  127. tios.c_cc[VTIME] = (uint8_t) 5;
  128. tios.c_lflag = 0;
  129. tcflush(fd, TCIFLUSH);
  130. ioctl(fd, TCSETS, &tios);
  131. return fd;
  132. }
  133. void CloseCommunicationLcmPort()
  134. {
  135. close(_port);
  136. }
  137. void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
  138. {
  139. int len = write(_port, cmd, cmdLen);
  140. if (len >= sizeof(cmd)) {
  141. //log_info("Write cmd to LCM successfully. \n");
  142. }
  143. }
  144. void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
  145. {
  146. read(_port, msg, readLen);
  147. if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2) {
  148. if (*(msg + 3) == CMD_WRITE) {
  149. switch (*(msg + 4)) {
  150. case CMD_REGISTER: {
  151. // 頁面
  152. strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
  153. }
  154. break;
  155. }
  156. } else if (*(msg + 3) == CMD_MULTI_READ) {
  157. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  158. // {
  159. // case BUTTON_GUN_INDEX:
  160. // {
  161. // // 當前選的槍號
  162. // _curGunIndex = (*(msg + 8));
  163. // }
  164. // break;
  165. // }
  166. }
  167. }
  168. }
  169. //================================================
  170. // Function
  171. //================================================
  172. void ChangeToOtherPage(short newPage)
  173. {
  174. uint8_t cmd[7];
  175. memset(cmd, 0x00, sizeof(cmd));
  176. cmd[0] = CMD_TITLE_1;
  177. cmd[1] = CMD_TITLE_2;
  178. cmd[2] = 0x02 + sizeof(newPage);
  179. cmd[3] = CMD_READ;
  180. cmd[4] = CMD_REGISTER;
  181. cmd[5] = newPage >> 8;
  182. cmd[6] = newPage & 0x00FF;
  183. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  184. usleep(100000);
  185. }
  186. void ChangeBackLight(bool islight)
  187. {
  188. uint8_t value = 0x01;
  189. if (islight) {
  190. value = 0x20;
  191. }
  192. uint8_t cmd[7];
  193. memset(cmd, 0x00, sizeof(cmd));
  194. cmd[0] = CMD_TITLE_1;
  195. cmd[1] = CMD_TITLE_2;
  196. cmd[2] = 0x03;
  197. cmd[3] = CMD_READ;
  198. cmd[4] = CMD_BACKLIGHT;
  199. cmd[5] = value;
  200. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  201. usleep(100000);
  202. }
  203. void GetCurrentPage()
  204. {
  205. uint8_t cmd[6];
  206. memset(cmd, 0x00, sizeof(cmd));
  207. uint8_t msg[8];
  208. memset(msg, 0x00, sizeof(msg));
  209. cmd[0] = CMD_TITLE_1;
  210. cmd[1] = CMD_TITLE_2;
  211. cmd[2] = 0x03; // 底下總長度
  212. cmd[3] = CMD_WRITE;
  213. cmd[4] = CMD_REGISTER;
  214. cmd[5] = 0x02;
  215. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  216. usleep(100000);
  217. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  218. }
  219. void DisplayValueToLcm(short address, uint8_t *data, uint8_t len)
  220. {
  221. uint8_t cmd[256];
  222. memset(cmd, 0x00, sizeof(cmd));
  223. cmd[0] = CMD_TITLE_1;
  224. cmd[1] = CMD_TITLE_2;
  225. cmd[2] = 0x03 + len;
  226. cmd[3] = CMD_MULTI_WRITE;
  227. cmd[4] = address >> 8;
  228. cmd[5] = address & 0x00FF;
  229. for (uint8_t count = 0; count < len; count++) {
  230. cmd[6 + count] = *(data + count);
  231. }
  232. WriteCmdToLcm(cmd, cmd[2] + 3);
  233. }
  234. void ChangeDisplay2Value(short address, short value)
  235. {
  236. uint8_t data[2];
  237. data[0] = value >> 8;
  238. data[1] = value & 0x00FF;
  239. DisplayValueToLcm(address, data, sizeof(data));
  240. }
  241. void GetBtnStatus(short address, uint8_t len)
  242. {
  243. uint8_t cmd[8];
  244. memset(cmd, 0x00, sizeof(cmd));
  245. uint8_t msg[8];
  246. memset(msg, 0x00, sizeof(msg));
  247. cmd[0] = CMD_TITLE_1;
  248. cmd[1] = CMD_TITLE_2;
  249. cmd[2] = 0x03 + len;
  250. cmd[3] = CMD_MULTI_READ;
  251. cmd[4] = address >> 8;
  252. cmd[5] = address & 0x00FF;
  253. cmd[6] = 0x00 + len;
  254. WriteCmdToLcm(cmd, cmd[2] + 3);
  255. usleep(100000);
  256. ReadMsgFromLcm(msg, (len * 2) + sizeof(msg));
  257. }
  258. //================================================
  259. // Warning process
  260. //================================================
  261. void string2ByteArray(uint8_t *input, uint8_t *output)
  262. {
  263. int loop;
  264. int i;
  265. loop = 0;
  266. i = 0;
  267. while (input[loop] != '\0') {
  268. output[i++] = input[loop++];
  269. }
  270. output[loop] = '\0';
  271. }
  272. void ChangeWarningFunc()
  273. {
  274. uint8_t cmd[7] = {0};
  275. uint8_t i = 0;
  276. //uint8_t j = 0;
  277. //log_info("ChangeWarningFunc \n");
  278. // 最多一次五筆
  279. //log_info("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
  280. //log_info("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
  281. //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  282. for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
  283. memset(cmd, 0x00, sizeof(cmd));
  284. if ((i) >= 5) {
  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. DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
  299. DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
  300. }
  301. /*#else
  302. for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
  303. memset(cmd, 0x00, sizeof(cmd));
  304. if ((i - j) >= 5) {
  305. break;
  306. }
  307. if (
  308. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
  309. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
  310. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
  311. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
  312. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
  313. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0) ||
  314. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
  315. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
  316. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
  317. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0) ||
  318. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
  319. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
  320. ) {
  321. j++;
  322. continue;
  323. }
  324. //error code
  325. string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
  326. DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
  327. //警告標示
  328. memset(cmd, 0x00, sizeof(cmd));
  329. cmd[0] = 0x00;
  330. cmd[1] = 0x01;
  331. DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
  332. }
  333. memset(cmd, 0x00, sizeof(cmd));
  334. i = i - j;
  335. for (; (i) < 5; i++) {
  336. DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
  337. DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
  338. }
  339. #endif //!defined DD360 && !defined DD360Audi
  340. */
  341. }
  342. //================================================
  343. // QR Code process
  344. //================================================
  345. void ChangeQrCode_Idle(char *input)
  346. {
  347. #if defined DD360Audi
  348. int len = strlen(input) + 3;
  349. int loop = 0;
  350. int i = 0, j = 0, k = 0, l = 0;
  351. uint8_t qrUrl[128] = {0};
  352. uint16_t urlLen = 0;
  353. uint8_t cmd[len];
  354. uint8_t tmpBuf[15] = {0};
  355. //uint8_t tmpLen = sizeof(tmpBuf) - 1;
  356. strncpy((char *)cmd, " ", len);
  357. while (input[loop] != '\0') {
  358. cmd[i++] = input[loop++];
  359. l = loop - 1;
  360. if (len >= 25) {
  361. if (i >= 16 && i <= 19) {
  362. tmpBuf[k++] = input[l];
  363. //printf("tmpBuf = %s\r\n", tmpBuf);
  364. } else if (i >= 21 && i <= 23) {
  365. tmpBuf[k++] = input[l];
  366. }
  367. }
  368. }
  369. tmpBuf[k] = '\0';
  370. //printf("tmpBuf = %s\r\n", tmpBuf);
  371. j += sprintf((char *)&cmd[i], ":%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
  372. cmd[len - 1] = '\0';
  373. urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
  374. qrUrl[urlLen] = '\0';
  375. //printf("qr url = %s\r\n", qrUrl);
  376. DisplayValueToLcm(__qr_code, qrUrl, urlLen);
  377. j = 0;
  378. j += sprintf((char *)&tmpBuf[k], "0%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
  379. tmpBuf[k + j] = '\0';
  380. //if (len < 25) {
  381. // strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  382. //}
  383. //tmpBuf[tmpLen] = '\0';
  384. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  385. /*if (len > sizeof(tmpBuf)) {
  386. strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  387. tmpBuf[tmpLen] = '\0';
  388. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  389. memset(tmpBuf, 0, sizeof(tmpBuf));
  390. strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
  391. tmpBuf[tmpLen] = '\0';
  392. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  393. } else {
  394. DisplayValueToLcm(__custStationIdL1, cmd, len);
  395. strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
  396. tmpBuf[tmpLen] = '\0';
  397. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  398. }*/
  399. #else
  400. int len = strlen(input);
  401. uint8_t cmd[len];
  402. int loop = 0;
  403. int i = 0;
  404. while (input[loop] != '\0') {
  405. cmd[i++] = input[loop++];
  406. }
  407. DisplayValueToLcm(__qr_code, cmd, len + 1);
  408. #endif //defined DD360Audi
  409. }
  410. void ChangeQrCode_Charge(char *input)
  411. {
  412. #if defined DD360Audi
  413. int len = strlen(input) + 3;
  414. int loop = 0;
  415. int i = 0, j = 0, k = 0, l = 0;
  416. uint8_t qrUrl[128] = {0};
  417. uint16_t urlLen = 0;
  418. uint8_t cmd[len];
  419. uint8_t tmpBuf[15] = {0};
  420. //uint8_t tmpLen = sizeof(tmpBuf) - 1;
  421. strncpy((char *)cmd, " ", len);
  422. while (input[loop] != '\0') {
  423. cmd[i++] = input[loop++];
  424. l = loop - 1;
  425. if (len >= 25) {
  426. if (i >= 16 && i <= 19) {
  427. tmpBuf[k++] = input[l];
  428. //printf("tmpBuf = %s\r\n", tmpBuf);
  429. } else if (i >= 21 && i <= 23) {
  430. tmpBuf[k++] = input[l];
  431. }
  432. }
  433. }
  434. tmpBuf[k] = '\0';
  435. //printf("tmpBuf = %s\r\n", tmpBuf);
  436. j += sprintf((char *)&cmd[i], ":%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
  437. cmd[len - 1] = '\0';
  438. urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
  439. qrUrl[urlLen] = '\0';
  440. DisplayValueToLcm(__qr_code, qrUrl, urlLen);
  441. j = 0;
  442. j += sprintf((char *)&tmpBuf[k], "0%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
  443. tmpBuf[k + j] = '\0';
  444. if (len < 25) {
  445. strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  446. }
  447. //tmpBuf[tmpLen] = '\0';
  448. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  449. /*if (len > sizeof(tmpBuf)) {
  450. strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  451. tmpBuf[tmpLen] = '\0';
  452. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  453. memset(tmpBuf, 0, sizeof(tmpBuf));
  454. strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
  455. tmpBuf[tmpLen] = '\0';
  456. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  457. } else {
  458. DisplayValueToLcm(__custStationIdL1, cmd, len);
  459. strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
  460. tmpBuf[tmpLen] = '\0';
  461. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  462. }*/
  463. #else
  464. int len = strlen(input);
  465. uint8_t cmd[len];
  466. int loop = 0;
  467. int i = 0;
  468. while (input[loop] != '\0') {
  469. cmd[i++] = input[loop++];
  470. }
  471. DisplayValueToLcm(__qr_code_pre, cmd, len + 1);
  472. #endif //defined DD360Audi
  473. }
  474. //================================================
  475. // Change current page
  476. //================================================
  477. void ChangeCurPage()
  478. {
  479. //log_info("cur = %d, new = %d \n", _currentPage, ShmSysConfigAndInfo->SysInfo.PageIndex);
  480. if (_currentPage != ShmSysConfigAndInfo->SysInfo.PageIndex) {
  481. _currentPage = ShmSysConfigAndInfo->SysInfo.PageIndex;
  482. ChangeToOtherPage(_currentPage);
  483. _everyPageRollChange = 0;
  484. }
  485. }
  486. //================================================
  487. // Main process
  488. //================================================
  489. uint8_t demoCount = 0;
  490. void DemoFunction()
  491. {
  492. if (demoCount == 0) {
  493. ShmSysConfigAndInfo->SysWarningInfo.WarningCount = 6;
  494. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[0][0], "000001", 7);
  495. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[1][0], "000002", 7);
  496. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[2][0], "000003", 7);
  497. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[3][0], "000004", 7);
  498. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[4][0], "000005", 7);
  499. memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[5][0], "000006", 7);
  500. } else {
  501. if (demoCount == 20) {
  502. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_IDLE;
  503. } else if (demoCount == 80) {
  504. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZING;
  505. } else if (demoCount == 100) {
  506. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_COMP;
  507. } else if (demoCount == 120) {
  508. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_FAIL;
  509. } else if (demoCount == 140) {
  510. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_PRE_CHARGE;
  511. } else if (demoCount == 180) {
  512. ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_CHARGING;
  513. }
  514. }
  515. if (demoCount < 180) {
  516. demoCount++;
  517. }
  518. }
  519. //================================================
  520. // Main process
  521. //================================================
  522. bool FindChargingInfoData(uint8_t target, struct ChargingInfoData **_chargingData)
  523. {
  524. for (uint8_t index = 0; index < CHAdeMO_QUANTITY; index++) {
  525. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target) {
  526. _chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
  527. return true;
  528. }
  529. }
  530. for (uint8_t index = 0; index < CCS_QUANTITY; index++) {
  531. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target) {
  532. _chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
  533. return true;
  534. }
  535. }
  536. for (uint8_t index = 0; index < GB_QUANTITY; index++) {
  537. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target) {
  538. _chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
  539. return true;
  540. }
  541. }
  542. return false;
  543. }
  544. bool FindAcChargingInfoData(uint8_t target, struct ChargingInfoData **acChargingData)
  545. {
  546. if (target < AC_QUANTITY) {
  547. acChargingData[target] = &ShmSysConfigAndInfo->SysInfo.AcChargingData[target];
  548. return true;
  549. }
  550. return false;
  551. }
  552. /**
  553. * [ChangeBalanceValue :print balance information]
  554. * @Author
  555. * @DateTime 2020-11-26
  556. */
  557. static void ChangeBalanceValue(uint16_t addr, uint8_t index) ////For Audi
  558. {
  559. uint8_t cmd[10] = {0};
  560. uint8_t value[10] = {0};
  561. uint8_t len = 0;
  562. float balance = ShmSelectGunInfo->PricesInfo[index].Balance;
  563. if ((balance) == (FAIL_BALANCE_PRICES)) {
  564. balance = 0.00;
  565. }
  566. len += sprintf((char *) value, "%.2f", balance);
  567. if (len < 6) {
  568. sprintf((char *)&value[len], "%s",
  569. (uint8_t *)GetCurrency(ShmSysConfigAndInfo->SysConfig.BillingData.Currency));
  570. }
  571. value[sizeof(value) - 1] = '\0';
  572. string2ByteArray(value, cmd);
  573. DisplayValueToLcm(addr, cmd, sizeof(cmd));
  574. }
  575. void ChangeAcBattMapAndValue(short page)
  576. {
  577. if (page == _LCM_CHARGING) {
  578. if (isDiffStatus != _battery_display_ani) {
  579. isChangeBattMap = false;
  580. isDiffStatus = _battery_display_ani;
  581. }
  582. if (ac_chargingInfo[0]->IsCharging && !isChangeBattMap) {
  583. isChangeBattMap = true;
  584. if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5) {
  585. ChangeDisplay2Value(__batt_map, _battery_empty);
  586. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_EMP;
  587. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP) {
  588. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  589. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV1;
  590. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1) {
  591. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  592. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV2;
  593. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2) {
  594. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  595. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV3;
  596. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3) {
  597. ChangeDisplay2Value(__batt_map, _battery_cap_80);
  598. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV4;
  599. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4) {
  600. ChangeDisplay2Value(__batt_map, _battery_cap_100);
  601. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
  602. }
  603. }
  604. } else if (page == _LCM_COMPLETE) {
  605. if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5) {
  606. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  607. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP) {
  608. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  609. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1) {
  610. ChangeDisplay2Value(__batt_map, _battery_soc_40);
  611. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2) {
  612. ChangeDisplay2Value(__batt_map, _battery_soc_60);
  613. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3) {
  614. ChangeDisplay2Value(__batt_map, _battery_soc_80);
  615. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4) {
  616. ChangeDisplay2Value(__batt_map, _battery_soc_100);
  617. }
  618. }
  619. ChangeDisplay2Value(__soc_value_charging, _disappear);
  620. }
  621. void ChangeBattMapAndValue(short page, int soc)
  622. {
  623. // srand(time(NULL));
  624. // int min = 10;
  625. // int max = 90;
  626. // soc = rand() % (max - min + 1) + min;
  627. if (page == _LCM_PRE_CHARGE) {
  628. ChangeDisplay2Value(__batt_map_empty, _battery_empty);
  629. } else if (page == _LCM_CHARGING) {
  630. if (soc < 20) {
  631. if (_battery_display_ani) {
  632. ChangeDisplay2Value(__batt_map, _battery_empty);
  633. } else {
  634. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  635. }
  636. } else if (soc >= 20 && soc < 40) {
  637. if (_battery_display_ani) {
  638. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  639. } else {
  640. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  641. }
  642. } else if (soc >= 40 && soc < 60) {
  643. if (_battery_display_ani) {
  644. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  645. } else {
  646. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  647. }
  648. } else if (soc >= 60 && soc < 80) {
  649. if (_battery_display_ani) {
  650. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  651. } else {
  652. ChangeDisplay2Value(__batt_map, _battery_cap_80);
  653. }
  654. } else if (soc >= 80 && soc <= 100) {
  655. if (_battery_display_ani) {
  656. ChangeDisplay2Value(__batt_map, _battery_cap_80); //DS60-120 add
  657. } else {
  658. ChangeDisplay2Value(__batt_map, _battery_cap_100);
  659. }
  660. }
  661. } else if (page == _LCM_COMPLETE) {
  662. if (soc < 20) {
  663. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  664. } else if (soc >= 20 && soc < 40) {
  665. ChangeDisplay2Value(__batt_map, _battery_soc_40);
  666. } else if (soc >= 40 && soc < 60) {
  667. ChangeDisplay2Value(__batt_map, _battery_soc_60);
  668. } else if (soc >= 60 && soc < 80) {
  669. ChangeDisplay2Value(__batt_map, _battery_soc_80);
  670. } else if (soc >= 80 && soc <= 100) {
  671. ChangeDisplay2Value(__batt_map, _battery_soc_100);
  672. }
  673. }
  674. uint8_t cmd[5];
  675. uint8_t value[5];
  676. memset(cmd, 0x00, sizeof(cmd));
  677. memset(value, 0x00, sizeof(value));
  678. sprintf((char *)value, "%d%%", soc);
  679. string2ByteArray(value, cmd);
  680. DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
  681. }
  682. void ChangeRemainTime(int sec)
  683. {
  684. int h, m, s;
  685. uint8_t cmd[10];
  686. uint8_t value[10];
  687. memset(cmd, 0x00, sizeof(cmd));
  688. // srand(time(NULL));
  689. // int min = 0;
  690. // int max = 65536;
  691. // sec = rand() % (max - min + 1) + min;
  692. h = (sec / 3600);
  693. m = (sec - (3600 * h)) / 60;
  694. s = (sec - (3600 * h) - (m * 60));
  695. sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
  696. string2ByteArray(value, cmd);
  697. DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
  698. }
  699. void ChangeChargingEnergyValue(float energy)
  700. {
  701. uint8_t cmd[10];
  702. uint8_t value[10];
  703. memset(cmd, 0x00, sizeof(cmd));
  704. if (energy >= 0.05) {
  705. energy -= 0.05;
  706. }
  707. sprintf((char *) value, "%.1f kWh", energy);
  708. string2ByteArray(value, cmd);
  709. DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
  710. }
  711. void ChangeChargingPowerValue(float pow)
  712. {
  713. uint8_t cmd[10];
  714. uint8_t value[10];
  715. memset(cmd, 0x00, sizeof(cmd));
  716. // float min = 0.0;
  717. // float max = 50;
  718. // pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
  719. sprintf((char *) value, "%.1f kW", pow);
  720. string2ByteArray(value, cmd);
  721. DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
  722. }
  723. void ChangeChargingFeeValue(float fee)
  724. {
  725. uint8_t cmd[10];
  726. uint8_t value[10];
  727. memset(cmd, 0x00, sizeof(cmd));
  728. sprintf((char *) value, "%.2f", fee);
  729. string2ByteArray(value, cmd);
  730. DisplayValueToLcm(__charging_fee_tx, cmd, sizeof(cmd));
  731. }
  732. void DisplayMoneyRate(float money)
  733. {
  734. uint8_t cmd[8];
  735. uint8_t value[8];
  736. memset(cmd, 0x00, sizeof(cmd));
  737. sprintf((char *) value, "%.2f", money);
  738. string2ByteArray(value, cmd);
  739. DisplayValueToLcm(__money_by_rate, cmd, sizeof(cmd));
  740. }
  741. void DisplayMoneyCur(uint8_t *cur)
  742. {
  743. uint8_t cmd[10] = {0};
  744. uint8_t buf[10] = {0};
  745. uint8_t len = 0;
  746. *(cur + 3) = '\0';
  747. memset(cmd, 0x00, sizeof(cmd));
  748. len = sprintf((char *) buf, "%s/kWh", cur);
  749. buf[len] = '\0';
  750. string2ByteArray(buf, cmd);
  751. DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
  752. }
  753. void RefreshPageAnimation(uint8_t value)
  754. {
  755. switch (_currentPage) {
  756. case _LCM_IDLE: {
  757. }
  758. break;
  759. case _LCM_WAIT_FOR_PLUG: {
  760. if (_everyPageRollChange == 0) {
  761. ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
  762. } else if (_everyPageRollChange == 15) {
  763. ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
  764. }
  765. _everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  766. }
  767. break;
  768. case _LCM_PRE_CHARGE:
  769. case _LCM_CHARGING:
  770. case _LCM_COMPLETE: {
  771. if (_currentPage == _LCM_PRE_CHARGE) {
  772. if (_everyPageRollChange == 0 || _everyPageRollChange == 22) {
  773. ChangeDisplay2Value(__conn_line, _conn_map1);
  774. } else if (_everyPageRollChange == 11 || _everyPageRollChange == 33) {
  775. ChangeDisplay2Value(__conn_line, _conn_map2);
  776. }
  777. } else if (_currentPage == _LCM_CHARGING) {
  778. if (_everyPageRollChange == 0 || _everyPageRollChange == 22) {
  779. ChangeDisplay2Value(__conn_line_chag, _charging_map1);
  780. } else if (_everyPageRollChange == 11 || _everyPageRollChange == 33) {
  781. ChangeDisplay2Value(__conn_line_chag, _charging_map2);
  782. }
  783. } else if (_currentPage == _LCM_COMPLETE) {
  784. if (_everyPageRollChange == 0) {
  785. ChangeDisplay2Value(__conn_line_comp, _complete_map);
  786. }
  787. }
  788. _everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  789. }
  790. break;
  791. }
  792. }
  793. void RefreshConnStatus()
  794. {
  795. // Wifi priority is higher than Ethernet
  796. #if defined DD360 ||defined DD360Audi || defined DD360ComBox
  797. uint8_t i = 0;
  798. uint8_t ehtStatus = 0;
  799. for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
  800. if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == 0) {
  801. ehtStatus = 1;
  802. //if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
  803. // ShmSelectGunInfo->EthDevStatus.Ethernet = DEV_ST_ENABLE_NO_USE;
  804. //}
  805. break;
  806. }
  807. }
  808. if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_DISABLE) {
  809. ChangeDisplay2Value(__conn_status, _disappear);
  810. } else if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_ENABLE_USE) {
  811. ChangeDisplay2Value(__conn_status, _connect);
  812. } else if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_ENABLE_NO_USE) {
  813. ChangeDisplay2Value(__conn_status, _disconnect);
  814. }
  815. if (ehtStatus == 1) {
  816. if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
  817. ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
  818. }
  819. } else {
  820. if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
  821. ChangeDisplay2Value(__ethernet_status, _eth_connect);
  822. }
  823. //if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_DISABLE) {
  824. //} else if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_USE) {
  825. // ChangeDisplay2Value(__ethernet_status, _eth_connect);
  826. //} else if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_NO_USE) {
  827. // ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
  828. //}
  829. }
  830. if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_DISABLE) {
  831. ChangeDisplay2Value(__wifi_status, _disappear);
  832. ChangeDisplay2Value(__3G4G_status, _disappear);
  833. if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
  834. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  835. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
  836. ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
  837. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
  838. ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
  839. }
  840. } else if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_USE) {
  841. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  842. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  843. } else if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_NO_USE) {
  844. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  845. ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
  846. }
  847. if (ShmSelectGunInfo->EthDevStatus.Wifi != DEV_ST_DISABLE) {
  848. if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
  849. ChangeDisplay2Value(__3G4G_status, _disappear);
  850. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
  851. ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
  852. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
  853. ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
  854. }
  855. }
  856. //uint8_t flag[4] = {0};
  857. /*for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
  858. //printf("status code = %s\r\n", &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0]);
  859. if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == 0) {
  860. flag[0] = 1;
  861. continue;
  862. }
  863. if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "043625", 6) == 0) {
  864. //disconnected from AP through WiFi
  865. flag[1] = 1;
  866. continue;
  867. }
  868. if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "043627", 6) == 0) { //wifi disabled
  869. flag[1] = 2;
  870. continue;
  871. }
  872. if ((memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "033900", 6) == 0) ||
  873. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "033901", 6) == 0) ||
  874. (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "033902", 6) == 0)) {
  875. flag[2] = 1;
  876. continue;
  877. }
  878. if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "043626", 6) == 0) {
  879. //disconnected from APN through 3G/4G
  880. flag[3] = 1;
  881. continue;
  882. }
  883. if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "043628", 6) == 0) { //4g disabled
  884. flag[3] = 2;
  885. continue;
  886. }
  887. }
  888. if (flag[0] == 1) {
  889. ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
  890. } else {
  891. ChangeDisplay2Value(__ethernet_status, _eth_connect);
  892. }
  893. //ChangeDisplay2Value(__wifi_status, _disappear);
  894. //ChangeDisplay2Value(__conn_status, _disappear);
  895. //ChangeDisplay2Value(__3G4G_status, _disappear);
  896. if (flag[1] == 1) {
  897. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  898. ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
  899. } else if (flag[1] == 2) {
  900. ChangeDisplay2Value(__wifi_status, _disappear);
  901. } else {
  902. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  903. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  904. }
  905. if (flag[2] == 1) {
  906. ChangeDisplay2Value(__conn_status, _disconnect);
  907. } else {
  908. ChangeDisplay2Value(__conn_status, _connect);
  909. }
  910. if (flag[1] == 2) {
  911. ChangeDisplay2Value(__3G4G_status, _disappear);
  912. if (flag[3] == 1) {
  913. ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
  914. } else if (flag[3] == 2) {
  915. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  916. } else {
  917. ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
  918. }
  919. } else {
  920. if (flag[3] == 1) {
  921. ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
  922. } else if (flag[3] == 2) {
  923. ChangeDisplay2Value(__3G4G_status, _disappear);
  924. } else {
  925. ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
  926. }
  927. }
  928. */
  929. #else
  930. // eth
  931. if (ShmSysConfigAndInfo->SysInfo.ethInternetConn == YES) {
  932. ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
  933. } else {
  934. ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
  935. }
  936. // Wifi
  937. if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W' ||
  938. ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D') &&
  939. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE) {
  940. if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES ||
  941. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
  942. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  943. } else {
  944. ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
  945. }
  946. } else {
  947. ChangeDisplay2Value(__wifi_status, _disappear);
  948. }
  949. if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T' ||
  950. ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D') &&
  951. ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != NO) {
  952. if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == _SYS_WIFI_MODE_DISABLE) {
  953. ChangeDisplay2Value(__3G4G_status, _disappear);
  954. // 3G/4G
  955. if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
  956. { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
  957. else
  958. { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
  959. } else {
  960. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  961. // 3G/4G
  962. if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
  963. { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
  964. else
  965. { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
  966. }
  967. } else {
  968. ChangeDisplay2Value(__3G4G_status, _disappear);
  969. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  970. }
  971. // 連線到後台
  972. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES) {
  973. ChangeDisplay2Value(__conn_status, _connect);
  974. } else {
  975. ChangeDisplay2Value(__conn_status, _disconnect);
  976. }
  977. /*if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES ||
  978. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
  979. _wifi_conn_status = true;
  980. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  981. ChangeDisplay2Value(__ethernet_status, _disappear);
  982. } else {
  983. _wifi_conn_status = false;
  984. ChangeDisplay2Value(__wifi_status, _disappear);
  985. }
  986. if (!_wifi_conn_status) {
  987. if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES ||
  988. ShmSysConfigAndInfo->SysInfo.InternetConn == YES) {
  989. ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
  990. } else {
  991. ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
  992. }
  993. }
  994. // 連線到後台
  995. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES) {
  996. ChangeDisplay2Value(__conn_status, _connect);
  997. } else {
  998. ChangeDisplay2Value(__conn_status, _disconnect);
  999. }
  1000. */
  1001. #endif //defined DD360 || defined DD360Audi
  1002. }
  1003. uint8_t FirstPageChanged()
  1004. {
  1005. uint8_t result = NO;
  1006. if (_currentPage != _oldPage) {
  1007. result = YES;
  1008. _oldPage = _currentPage;
  1009. }
  1010. return result;
  1011. }
  1012. bool IsPageReloadChk()
  1013. {
  1014. bool result = false;
  1015. if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE) {
  1016. if (_curPage_index != ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
  1017. _curPage_index = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
  1018. result = true;
  1019. }
  1020. } else {
  1021. if (_curPage_index != ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc) {
  1022. _curPage_index = ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc;
  1023. result = true;
  1024. }
  1025. }
  1026. return result;
  1027. }
  1028. void ClearDisplayInfo()
  1029. {
  1030. ChangeDisplay2Value(__csu_ver_string, _disappear);
  1031. ChangeDisplay2Value(__csu_ver_value, _disappear);
  1032. ChangeDisplay2Value(__eth0_ip_string, _disappear);
  1033. ChangeDisplay2Value(__eth0_ip_value, _disappear);
  1034. ChangeDisplay2Value(__sn_string, _disappear);
  1035. ChangeDisplay2Value(__sn_value, _disappear);
  1036. ChangeDisplay2Value(__dc1_ver_string, _disappear);
  1037. ChangeDisplay2Value(__dc1_ver_value, _disappear);
  1038. ChangeDisplay2Value(__dc2_ver_string, _disappear);
  1039. ChangeDisplay2Value(__dc2_ver_value, _disappear);
  1040. ChangeDisplay2Value(__fan_speed_string, _disappear);
  1041. ChangeDisplay2Value(__fan_speed_value, _disappear);
  1042. }
  1043. void DisplayInfoCsuVer(bool isShow, uint8_t *modelName)
  1044. {
  1045. if (isShow) {
  1046. uint8_t value[10];
  1047. memset(value, 0x00, sizeof(value));
  1048. strcpy((char *)value, "CSU Ver >");
  1049. DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
  1050. memset(value, 0x00, sizeof(value));
  1051. strncpy((char *)value, (char *)modelName, 5);
  1052. DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
  1053. } else {
  1054. ChangeDisplay2Value(__csu_ver_string, _disappear);
  1055. ChangeDisplay2Value(__csu_ver_value, _disappear);
  1056. }
  1057. }
  1058. void ShowWifiMode(bool isShow, uint8_t mode)
  1059. {
  1060. if (isShow) {
  1061. uint8_t value[20];
  1062. memset(value, 0x00, sizeof(value));
  1063. strcpy((char *) value, "Wifi Mo. >");
  1064. DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
  1065. memset(value, 0x00, sizeof(value));
  1066. if (mode == 0) {
  1067. sprintf((char *)value, "disable");
  1068. } else if (mode == 1) {
  1069. sprintf((char *)value, "station");
  1070. } else if (mode == 2) {
  1071. sprintf((char *)value, "AP");
  1072. }
  1073. DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
  1074. } else {
  1075. ChangeDisplay2Value(__csu_ver_string, _disappear);
  1076. ChangeDisplay2Value(__csu_ver_value, _disappear);
  1077. }
  1078. }
  1079. void DisplayInfoEthIp(bool isShow, uint8_t *ip)
  1080. {
  1081. if (isShow) {
  1082. uint8_t value[20];
  1083. memset(value, 0x00, sizeof(value));
  1084. strcpy((char *) value, "Eth IP >");
  1085. DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
  1086. memset(value, 0x00, sizeof(value));
  1087. strcpy((char *) value, (char *) ip);
  1088. DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
  1089. } else {
  1090. ChangeDisplay2Value(__eth0_ip_string, _disappear);
  1091. ChangeDisplay2Value(__eth0_ip_value, _disappear);
  1092. }
  1093. }
  1094. void Show4GRssi(bool isShow, int dbValue)
  1095. {
  1096. if (isShow) {
  1097. uint8_t value[20];
  1098. memset(value, 0x00, sizeof(value));
  1099. strcpy((char *) value, "RSSI >");
  1100. DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
  1101. memset(value, 0x00, sizeof(value));
  1102. sprintf((char *)value, "%d dBm", dbValue);
  1103. DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
  1104. } else {
  1105. ChangeDisplay2Value(__eth0_ip_string, _disappear);
  1106. ChangeDisplay2Value(__eth0_ip_value, _disappear);
  1107. }
  1108. }
  1109. void DisplayInfoSN(bool isShow, uint8_t *sn)
  1110. {
  1111. if (isShow) {
  1112. uint8_t value[30];
  1113. memset(value, 0x00, sizeof(value));
  1114. strcpy((char *) value, "SN >");
  1115. DisplayValueToLcm(__sn_string, value, sizeof(value));
  1116. memset(value, 0x00, sizeof(value));
  1117. strcpy((char *) value, (char *) sn);
  1118. DisplayValueToLcm(__sn_value, value, sizeof(value));
  1119. } else {
  1120. ChangeDisplay2Value(__sn_string, _disappear);
  1121. ChangeDisplay2Value(__sn_value, _disappear);
  1122. }
  1123. }
  1124. void ShowWifiRssi(bool isShow, int dbValue)
  1125. {
  1126. if (isShow) {
  1127. uint8_t value[20];
  1128. memset(value, 0x00, sizeof(value));
  1129. strcpy((char *) value, "RSSI >");
  1130. DisplayValueToLcm(__sn_string, value, sizeof(value));
  1131. memset(value, 0x00, sizeof(value));
  1132. sprintf((char *)value, "%d dBm", dbValue);
  1133. DisplayValueToLcm(__sn_value, value, sizeof(value));
  1134. } else {
  1135. ChangeDisplay2Value(__sn_string, _disappear);
  1136. ChangeDisplay2Value(__sn_value, _disappear);
  1137. }
  1138. }
  1139. void DisplayInfoGun1Ver(bool isShow, uint8_t *version)
  1140. {
  1141. if (isShow) {
  1142. uint8_t value[10];
  1143. memset(value, 0x00, sizeof(value));
  1144. strcpy((char *) value, "Ct1 Ver >");
  1145. DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
  1146. memset(value, 0x00, sizeof(value));
  1147. strcpy((char *) value, (char *) version);
  1148. DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
  1149. } else {
  1150. ChangeDisplay2Value(__dc1_ver_string, _disappear);
  1151. ChangeDisplay2Value(__dc1_ver_value, _disappear);
  1152. }
  1153. }
  1154. void Show4GMode(bool isShow, uint8_t mode)
  1155. {
  1156. if (isShow) {
  1157. uint8_t value[20];
  1158. memset(value, 0x00, sizeof(value));
  1159. strcpy((char *) value, "3/4G Mo. >");
  1160. DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
  1161. memset(value, 0x00, sizeof(value));
  1162. if (mode == 0) {
  1163. sprintf((char *)value, "disable");
  1164. } else if (mode == 1) {
  1165. sprintf((char *)value, "enable");
  1166. }
  1167. DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
  1168. } else {
  1169. ChangeDisplay2Value(__dc1_ver_string, _disappear);
  1170. ChangeDisplay2Value(__dc1_ver_value, _disappear);
  1171. }
  1172. }
  1173. void DisplayInfoGun2Ver(bool isShow, uint8_t *version)
  1174. {
  1175. if (isShow) {
  1176. uint8_t value[10];
  1177. memset(value, 0x00, sizeof(value));
  1178. strcpy((char *) value, "Ct2 Ver >");
  1179. DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
  1180. memset(value, 0x00, sizeof(value));
  1181. strcpy((char *) value, (char *) version);
  1182. DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
  1183. } else {
  1184. ChangeDisplay2Value(__dc2_ver_string, _disappear);
  1185. ChangeDisplay2Value(__dc2_ver_value, _disappear);
  1186. }
  1187. }
  1188. void Show4GIP(bool isShow, uint8_t *ip)
  1189. {
  1190. if (isShow) {
  1191. uint8_t value[20];
  1192. memset(value, 0x00, sizeof(value));
  1193. strcpy((char *) value, "3/4G IP >");
  1194. DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
  1195. memset(value, 0x00, sizeof(value));
  1196. strcpy((char *) value, (char *) ip);
  1197. DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
  1198. } else {
  1199. ChangeDisplay2Value(__dc2_ver_string, _disappear);
  1200. ChangeDisplay2Value(__dc2_ver_value, _disappear);
  1201. }
  1202. }
  1203. void DisplayInfoSpeed(bool isShow, unsigned int fan)
  1204. {
  1205. if (isShow) {
  1206. uint8_t value[10];
  1207. memset(value, 0x00, sizeof(value));
  1208. strcpy((char *) value, "Fan Spd >");
  1209. DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
  1210. memset(value, 0x00, sizeof(value));
  1211. sprintf((char *)value, "%d", fan);
  1212. DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
  1213. } else {
  1214. ChangeDisplay2Value(__fan_speed_string, _disappear);
  1215. ChangeDisplay2Value(__fan_speed_value, _disappear);
  1216. }
  1217. }
  1218. void ShowWifiIP(bool isShow, uint8_t *ip)
  1219. {
  1220. if (isShow) {
  1221. uint8_t value[20];
  1222. memset(value, 0x00, sizeof(value));
  1223. strcpy((char *) value, "Wifi IP >");
  1224. DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
  1225. memset(value, 0x00, sizeof(value));
  1226. strcpy((char *) value, (char *) ip);
  1227. DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
  1228. } else {
  1229. ChangeDisplay2Value(__fan_speed_string, _disappear);
  1230. ChangeDisplay2Value(__fan_speed_value, _disappear);
  1231. }
  1232. }
  1233. void InformationShow()
  1234. {
  1235. if (ShmSysConfigAndInfo->SysConfig.ShowInformation == YES) {
  1236. bool show = _isShow = true;
  1237. if (_showInformIndex == 0) {
  1238. DisplayInfoCsuVer(show, ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  1239. DisplayInfoSpeed(show, ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed);
  1240. DisplayInfoSN(show, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  1241. DisplayInfoEthIp(show, ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress);
  1242. DisplayInfoGun1Ver(show, ShmSysConfigAndInfo->SysInfo.Connector1FwRev);
  1243. if (_totalCount > 1) {
  1244. DisplayInfoGun2Ver(show, ShmSysConfigAndInfo->SysInfo.Connector2FwRev);
  1245. } else {
  1246. DisplayInfoGun2Ver(false, ShmSysConfigAndInfo->SysInfo.Connector2FwRev);
  1247. }
  1248. } else if (_showInformIndex == 1) {
  1249. ShowWifiMode(show, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
  1250. ShowWifiIP(show, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress);
  1251. ShowWifiRssi(show, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi);
  1252. Show4GMode(show, ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled);
  1253. Show4GIP(show, ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
  1254. Show4GRssi(show, ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
  1255. }
  1256. } else {
  1257. ClearDisplayInfo();
  1258. if (_isShow) {
  1259. _isShow = false;
  1260. _showInformIndex++;
  1261. if (_showInformIndex >= 2) {
  1262. _showInformIndex = 0;
  1263. }
  1264. }
  1265. }
  1266. }
  1267. void ProcessPageInfo()
  1268. {
  1269. _page_reload = IsPageReloadChk();
  1270. // 隨插即充 - 可省略該按鈕 //DS60-120 add
  1271. if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE) {
  1272. ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
  1273. if (_totalCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO) {
  1274. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1275. } else {
  1276. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1277. }
  1278. }
  1279. switch (_currentPage) {
  1280. #if defined DD360Audi
  1281. case _LCM_SELECT_GUN: ////For Audi
  1282. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == 0) {
  1283. ChangeDisplay2Value(__left_gun_map, _left_gun_enable_map);
  1284. ChangeDisplay2Value(__right_gun_map, _right_gun_disable_map);
  1285. } else if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == 1) {
  1286. ChangeDisplay2Value(__left_gun_map, _left_gun_disable_map);
  1287. ChangeDisplay2Value(__right_gun_map, _right_gun_enable_map);
  1288. }
  1289. ChangeDisplay2Value(__add_chk_btn, _select_gun_btn);
  1290. break;
  1291. #endif //defined DD360Audi
  1292. case _LCM_IDLE: {
  1293. if (ShmSysConfigAndInfo->SysConfig.isRFID) {
  1294. ChangeDisplay2Value(__main_rfid, _main_rfid);
  1295. } else {
  1296. ChangeDisplay2Value(__main_rfid, _main_none_rfid);
  1297. }
  1298. if (ShmSysConfigAndInfo->SysConfig.isQRCode) {
  1299. ChangeDisplay2Value(__main_qr, _main_qr);
  1300. } else {
  1301. ChangeDisplay2Value(__qr_code, _disappear);
  1302. ChangeDisplay2Value(__main_qr, _main_none_qr);
  1303. needReloadQr = true;
  1304. }
  1305. if (ShmSysConfigAndInfo->SysConfig.isAPP) {
  1306. ChangeDisplay2Value(__main_app, _main_app);
  1307. } else {
  1308. ChangeDisplay2Value(__main_app, _main_none_app);
  1309. }
  1310. //if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
  1311. if (ShmSysConfigAndInfo->SysConfig.isQRCode) {
  1312. needReloadQr = false;
  1313. if (ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO) {
  1314. //uint8_t len = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
  1315. ChangeQrCode_Idle((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
  1316. } else {
  1317. //uint8_t len = strlen((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
  1318. ChangeQrCode_Idle((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
  1319. }
  1320. //ChangeQrCode_Idle((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
  1321. }
  1322. //}
  1323. //DS60-120 add
  1324. bool isCharging = false;
  1325. for (uint8_t i = 0; i < _totalCount; i++) {
  1326. if (_chargingInfoData[i]->SystemStatus == S_IDLE) {
  1327. continue;
  1328. }
  1329. isCharging = true;
  1330. break;
  1331. }
  1332. if (isCharging && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO) {
  1333. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1334. } else {
  1335. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1336. }
  1337. }
  1338. break;
  1339. case _LCM_AUTHORIZING:
  1340. case _LCM_AUTHORIZ_COMP:
  1341. case _LCM_AUTHORIZ_FAIL: {
  1342. //case _LCM_WAIT_FOR_PLUG: {
  1343. FirstPageChanged();
  1344. #if defined DD360Audi
  1345. if (_currentPage == _LCM_AUTHORIZ_COMP) { ////For Audi
  1346. ChangeBalanceValue(__balance, ShmSysConfigAndInfo->SysInfo.CurGunSelected);
  1347. }
  1348. #endif //defined DD360Audi
  1349. }
  1350. break;
  1351. case _LCM_WAIT_FOR_PLUG: {
  1352. FirstPageChanged();
  1353. if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) {
  1354. // 新增隨插即充功能預設在等待插槍頁面在開啟
  1355. ChangeDisplay2Value(__ret_home_btn, _disappear);
  1356. bool isCharging = false;
  1357. for (uint8_t i = 0; i < _totalCount; i++) {
  1358. if (_chargingInfoData[i]->SystemStatus == S_IDLE) {
  1359. continue;
  1360. }
  1361. isCharging = true;
  1362. break;
  1363. }
  1364. if (isCharging && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO) {
  1365. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1366. } else {
  1367. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1368. }
  1369. } else {
  1370. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1371. }
  1372. }
  1373. break;
  1374. case _LCM_PRE_CHARGE:
  1375. case _LCM_CHARGING:
  1376. case _LCM_COMPLETE: {
  1377. bool isShowAc = false;
  1378. uint8_t gunTargetIndex = 0;
  1379. if (acgunCount > 0) {
  1380. gunTargetIndex = 2;
  1381. if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc != NO_DEFINE) {
  1382. isShowAc = true;
  1383. //ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_light); //DS60-120 remove
  1384. if (_currentPage == _LCM_COMPLETE) {
  1385. ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_light_cmp);
  1386. } else {
  1387. ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_light);
  1388. }
  1389. if (_currentPage == _LCM_CHARGING) {
  1390. ChangeAcBattMapAndValue(_LCM_CHARGING);
  1391. if (ac_chargingInfo[0]->PresentChargedDuration >= 0 &&
  1392. ac_chargingInfo[0]->PresentChargedDuration <= TIME_MAX_SEC) {
  1393. ChangeRemainTime(ac_chargingInfo[0]->PresentChargedDuration);
  1394. } else {
  1395. ChangeRemainTime(0);
  1396. }
  1397. if (ac_chargingInfo[0]->PresentChargingPower >= 0.1 &&
  1398. ac_chargingInfo[0]->PresentChargingPower <= POWER_MAX_KW) {
  1399. ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
  1400. } else {
  1401. ChangeChargingPowerValue(0);
  1402. }
  1403. if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1 &&
  1404. ac_chargingInfo[0]->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1405. ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
  1406. } else {
  1407. ChangeChargingEnergyValue(0);
  1408. }
  1409. if (strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == 0 ||
  1410. ShmSysConfigAndInfo->SysConfig.StopChargingByButton == YES) {
  1411. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  1412. } else {
  1413. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  1414. }
  1415. } else if (_currentPage == _LCM_COMPLETE) {
  1416. ChangeAcBattMapAndValue(_LCM_COMPLETE);
  1417. if (ac_chargingInfo[0]->PresentChargedDuration >= 0 &&
  1418. ac_chargingInfo[0]->PresentChargedDuration <= TIME_MAX_SEC) {
  1419. ChangeRemainTime(ac_chargingInfo[0]->PresentChargedDuration);
  1420. } else {
  1421. ChangeRemainTime(0);
  1422. }
  1423. if (ac_chargingInfo[0]->PresentChargingPower >= 0.1 &&
  1424. ac_chargingInfo[0]->PresentChargingPower <= POWER_MAX_KW) {
  1425. ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
  1426. } else {
  1427. ChangeChargingPowerValue(0);
  1428. }
  1429. if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1 &&
  1430. ac_chargingInfo[0]->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1431. ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
  1432. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  1433. ac_chargingInfo[0]->ChargingFee >= 0) {
  1434. ChangeChargingFeeValue(ac_chargingInfo[0]->ChargingFee);
  1435. }
  1436. } else {
  1437. ChangeChargingEnergyValue(0);
  1438. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
  1439. ChangeChargingFeeValue(0);
  1440. }
  1441. }
  1442. if (!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
  1443. ChangeDisplay2Value(__charging_fee_map, _disappear);
  1444. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  1445. } else {
  1446. ChangeDisplay2Value(__charging_fee_map, _money_map);
  1447. }
  1448. }
  1449. } else {
  1450. //ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_dark); //DS60-120 remove
  1451. if (_currentPage == _LCM_COMPLETE) {
  1452. ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_dark_cmp);
  1453. } else {
  1454. ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_dark);
  1455. }
  1456. }
  1457. } else {
  1458. //ChangeDisplay2Value(__gun_type_index + (2 * 2), _disappear); //DS60-120 remove
  1459. if (_totalCount > 1) {
  1460. gunTargetIndex = 2;
  1461. ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _disappear);
  1462. ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _disappear);
  1463. }
  1464. }
  1465. gunTargetIndex = 0; //DS60-120 add
  1466. for (uint8_t i = 0; i < _totalCount; i++) {
  1467. if (_totalCount == 1 && acgunCount <= 0) { //DS60-120 add
  1468. gunTargetIndex = 2;
  1469. } else {
  1470. gunTargetIndex = i;
  1471. }
  1472. switch (_chargingInfoData[i]->Type) {
  1473. case _Type_Chademo: {
  1474. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc) {
  1475. if (_currentPage == _LCM_COMPLETE) {
  1476. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _chademo_light_cmp);
  1477. } else {
  1478. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_light);
  1479. }
  1480. } else {
  1481. if (_currentPage == _LCM_COMPLETE) {
  1482. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _chademo_dark_cmp);
  1483. } else {
  1484. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_dark);
  1485. }
  1486. }
  1487. }
  1488. break;
  1489. case _Type_GB: {
  1490. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc) {
  1491. if (_currentPage == _LCM_COMPLETE) {
  1492. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _gbt_light_cmp);
  1493. } else {
  1494. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_light);
  1495. }
  1496. } else {
  1497. if (_currentPage == _LCM_COMPLETE) {
  1498. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _gbt_dark_cmp);
  1499. } else {
  1500. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_dark);
  1501. }
  1502. }
  1503. }
  1504. break;
  1505. case _Type_CCS_2: {
  1506. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc) {
  1507. if (_currentPage == _LCM_COMPLETE) {
  1508. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _ccs_light_cmp);
  1509. } else {
  1510. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_light);
  1511. }
  1512. } else {
  1513. if (_currentPage == _LCM_COMPLETE) {
  1514. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _ccs_dark_cmp);
  1515. } else {
  1516. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_dark);
  1517. }
  1518. }
  1519. }
  1520. break;
  1521. }
  1522. if (_currentPage == _LCM_PRE_CHARGE && !isShowAc) {
  1523. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i) {
  1524. ChangeBattMapAndValue(_currentPage, _chargingInfoData[i]->EvBatterySoc);
  1525. }
  1526. } else if (_currentPage == _LCM_CHARGING && !isShowAc) {
  1527. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i) {
  1528. ChangeBattMapAndValue(_LCM_CHARGING, _chargingInfoData[i]->EvBatterySoc);
  1529. if (_chargingInfoData[i]->PresentChargedDuration >= 0 &&
  1530. _chargingInfoData[i]->PresentChargedDuration <= TIME_MAX_SEC) {
  1531. ChangeRemainTime(_chargingInfoData[i]->PresentChargedDuration);
  1532. } else {
  1533. ChangeRemainTime(0);
  1534. }
  1535. if (_chargingInfoData[i]->PresentChargingPower >= 0 &&
  1536. _chargingInfoData[i]->PresentChargingPower <= POWER_MAX_KW) {
  1537. ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
  1538. } else {
  1539. ChangeChargingPowerValue(0);
  1540. }
  1541. if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1 &&
  1542. _chargingInfoData[i]->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1543. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  1544. } else {
  1545. ChangeChargingEnergyValue(0);
  1546. }
  1547. if (strcmp((char *)_chargingInfoData[i]->StartUserId, "") == 0 ||
  1548. ShmSysConfigAndInfo->SysConfig.StopChargingByButton == YES) {
  1549. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  1550. } else {
  1551. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  1552. }
  1553. }
  1554. } else if (_currentPage == _LCM_COMPLETE && !isShowAc) {
  1555. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i) {
  1556. ChangeBattMapAndValue(_LCM_COMPLETE, _chargingInfoData[i]->EvBatterySoc);
  1557. if (_chargingInfoData[i]->PresentChargedDuration >= 0 &&
  1558. _chargingInfoData[i]->PresentChargedDuration <= TIME_MAX_SEC) {
  1559. ChangeRemainTime(_chargingInfoData[i]->PresentChargedDuration);
  1560. } else {
  1561. ChangeRemainTime(0);
  1562. }
  1563. if (_chargingInfoData[i]->PresentChargingPower >= 0 &&
  1564. _chargingInfoData[i]->PresentChargingPower <= POWER_MAX_KW) {
  1565. ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
  1566. } else {
  1567. ChangeChargingPowerValue(0);
  1568. }
  1569. #if 1
  1570. if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1 &&
  1571. _chargingInfoData[i]->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1572. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  1573. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  1574. _chargingInfoData[i]->ChargingFee >= 0) {
  1575. ChangeChargingFeeValue(_chargingInfoData[i]->ChargingFee);
  1576. ChangeBalanceValue(__remain_balance, i);
  1577. }
  1578. } else {
  1579. ChangeChargingEnergyValue(0);
  1580. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
  1581. ChangeChargingFeeValue(0);
  1582. ChangeBalanceValue(__remain_balance, i);
  1583. }
  1584. }
  1585. #else
  1586. ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
  1587. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
  1588. _chargingInfoData[i]->ChargingFee >= 0) {
  1589. ChangeChargingFeeValue(_chargingInfoData[i]->ChargingFee);
  1590. ChangeBalanceValue(__remain_balance, i);
  1591. }
  1592. #endif // 0
  1593. if (!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
  1594. ChangeDisplay2Value(__charging_fee_map, _disappear);
  1595. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  1596. } else {
  1597. ChangeDisplay2Value(__charging_fee_map, _money_map);
  1598. }
  1599. }
  1600. }
  1601. }
  1602. // gun btn and QR code
  1603. if (_totalCount + acgunCount >= 2 && _currentPage) {
  1604. uint8_t index = 0;
  1605. for (index = 0; index < _totalCount; index++) {
  1606. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != index) {
  1607. break;
  1608. }
  1609. }
  1610. if (_chargingInfoData[index]->SystemStatus == S_IDLE ||
  1611. _chargingInfoData[index]->SystemStatus == S_RESERVATION ||
  1612. _chargingInfoData[index]->SystemStatus == S_BOOTING) {
  1613. if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
  1614. if (ShmSysConfigAndInfo->SysConfig.isQRCode) {
  1615. needReloadQr = false;
  1616. //ChangeQrCode_Charge((char *)ShmSysConfigAndInfo->SysConfig.SystemId); //DS60-120 remove
  1617. if (ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO) {
  1618. //uint8_t len = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
  1619. ChangeQrCode_Charge((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
  1620. } else {
  1621. //uint8_t len = strlen((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
  1622. ChangeQrCode_Charge((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
  1623. }
  1624. }
  1625. }
  1626. }
  1627. }
  1628. }
  1629. break;
  1630. case _LCM_FIX:
  1631. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == 1) {
  1632. ChangeDisplay2Value(_emergency_map, _emergency_disable_map);
  1633. } else {
  1634. ChangeDisplay2Value(_emergency_map, _disappear);
  1635. }
  1636. break;
  1637. }
  1638. }
  1639. void ChangeDisplayMoneyInfo()
  1640. {
  1641. uint8_t curGun = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
  1642. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
  1643. struct timeb csuTime;
  1644. struct tm *tmCSU;
  1645. ftime(&csuTime);
  1646. tmCSU = localtime(&csuTime.time);
  1647. ChangeDisplay2Value(__money_rate_map, _charging_money);
  1648. #if defined DD360Audi
  1649. if (ShmSelectGunInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
  1650. DisplayMoneyRate(ShmSelectGunInfo->PricesInfo[curGun].UserPrices);
  1651. } else {
  1652. #endif //defined DD360Audi
  1653. if (tmCSU->tm_hour <= 23) {
  1654. ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = ShmSysConfigAndInfo->SysConfig.BillingData.Fee[tmCSU->tm_hour];
  1655. DisplayMoneyRate(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
  1656. }
  1657. if (ShmSysConfigAndInfo->SysConfig.BillingData.Currency <= 53) {
  1658. DisplayMoneyCur((uint8_t *)GetCurrency(ShmSysConfigAndInfo->SysConfig.BillingData.Currency));
  1659. }
  1660. #if defined DD360Audi
  1661. }
  1662. #endif //defined DD360Audi
  1663. } else {
  1664. ChangeDisplay2Value(__money_rate_map, _disappear);
  1665. ChangeDisplay2Value(__money_by_rate, _disappear);
  1666. ChangeDisplay2Value(__money_rate, _disappear);
  1667. }
  1668. }
  1669. void Initialization()
  1670. {
  1671. bool isPass = false;
  1672. uint8_t count = 5;
  1673. while (!isPass && count > 0) {
  1674. isPass = true;
  1675. for (uint8_t _index = 0; _index < _totalCount; _index++) {
  1676. if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
  1677. log_error("LcmComm (main) : FindChargingInfoData false \n");
  1678. isPass = false;
  1679. count--;
  1680. break;
  1681. }
  1682. }
  1683. sleep(1);
  1684. }
  1685. isPass = false;
  1686. if (acgunCount > 0) {
  1687. while (!isPass) {
  1688. isPass = true;
  1689. for (uint8_t _index = 0; _index < acgunCount; _index++) {
  1690. if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
  1691. log_error("LcmComm : FindAcChargingInfoData false \n");
  1692. isPass = false;
  1693. break;
  1694. }
  1695. }
  1696. sleep(1);
  1697. }
  1698. }
  1699. if (count == 0) {
  1700. log_info("LCM Initialization Gun Fail.............\n");
  1701. }
  1702. }
  1703. //DS60-120 add
  1704. void DefaultIconStatus()
  1705. {
  1706. for (uint8_t i = 0; i < 3; i++) {
  1707. ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
  1708. }
  1709. if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES || _totalCount == 1) {
  1710. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1711. } else {
  1712. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1713. }
  1714. }
  1715. int main(void)
  1716. {
  1717. if (InitShareMemory() == FAIL) {
  1718. #ifdef SystemLogMessage
  1719. log_error("InitShareMemory NG\n");
  1720. #endif
  1721. if (ShmStatusCodeData != NULL) {
  1722. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  1723. }
  1724. sleep(5);
  1725. return 0;
  1726. }
  1727. _port = CreateCommunicationLcmPort();
  1728. uint8_t changeWarningPriority = 0;
  1729. uint8_t curWarningCount = 255;
  1730. ChangeBackLight(true);
  1731. _totalCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  1732. acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
  1733. Initialization();
  1734. //printf("_LCM_COMPLETE \r\n");
  1735. //ChangeToOtherPage(_LCM_COMPLETE);
  1736. //return 0;
  1737. for (uint8_t i = 0; i < 3; i++) {
  1738. ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
  1739. }
  1740. DefaultIconStatus(); //DS60-120 add
  1741. while (_port != -1) {
  1742. if (strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName) != 0x00) {
  1743. GetCurrentPage();
  1744. sleep(1);
  1745. } else {
  1746. //DemoFunction();
  1747. // Warning 處理
  1748. if (curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount) {
  1749. changeWarningPriority = 0;
  1750. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1751. curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
  1752. ChangeWarningFunc();
  1753. } else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0) {
  1754. // 當有兩頁 Warning 則每隔三秒改變一次
  1755. if (ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0) {
  1756. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
  1757. } else {
  1758. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1759. }
  1760. ChangeWarningFunc();
  1761. }
  1762. // 頁面資訊處理
  1763. ProcessPageInfo();
  1764. // 網路 - wifi - 連線訊號處理
  1765. RefreshConnStatus();
  1766. // 換頁處理
  1767. GetCurrentPage(); //DS60-120 add
  1768. ChangeCurPage();
  1769. RefreshPageAnimation(_everyPageRollChange);
  1770. #if defined DD360Audi
  1771. ChangeDisplayMoneyInfo();
  1772. #else
  1773. if (changeWarningPriority == 0) { ////For Audi
  1774. ChangeDisplayMoneyInfo();
  1775. InformationShow();
  1776. }
  1777. #endif //defined DD360Audi
  1778. changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);
  1779. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1780. usleep(100000);
  1781. }
  1782. }
  1783. CloseCommunicationLcmPort();
  1784. return FAIL;
  1785. }