Module_LcmControl.c 48 KB

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