Module_LcmControl.c 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737
  1. #include <stdio.h> /*標準輸入輸出定義*/
  2. #include <stdlib.h> /*標準函數庫定義*/
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6. #include <termios.h>
  7. #include <fcntl.h>
  8. #include <time.h>
  9. #include <sys/ioctl.h>
  10. #include <sys/timeb.h>
  11. #include "Module_LcmControl.h"
  12. #include "../Log/log.h"
  13. #include "../ShareMemory/shmMem.h"
  14. #include "../Define/define.h"
  15. #include "../Config.h"
  16. #include "../SelectGun/SelectGun.h"
  17. #include "main.h"
  18. #include "../timeout.h"
  19. #define uSEC_VAL (1000000)
  20. //------------------------------------------------------------------------------
  21. //struct SysConfigAndInfo *ShmSysConfigAndInfo;
  22. //struct StatusCodeData *ShmStatusCodeData;
  23. static struct SysConfigData *pSysConfig = NULL;
  24. static struct SysInfoData *pSysInfo = NULL;
  25. static struct WARNING_CODE_INFO *pSysWarning = NULL;
  26. static struct FanModuleData *ShmFanModuleData;
  27. static struct PrimaryMcuData *ShmPrimaryMcuData;
  28. static SelectGunInfo *ShmSelectGunInfo = NULL;
  29. static struct ChargingInfoData *pDcChargingInfo = NULL;
  30. static DcCommonInfo *ShmDcCommonData = NULL;
  31. short _currentPage = _LCM_NONE;
  32. uint8_t _totalCount;
  33. uint8_t _showInformIndex = 0;
  34. float ChargeMaxPower_0 = 0;
  35. float ChargeMaxPower_1 = 0;
  36. int _port;
  37. //char* pPortName = "/dev/ttyO2";
  38. char *pPortName = "/dev/ttyS3";
  39. char *moduleName = "DMT80480T070_09WT";
  40. bool is_show = false;
  41. uint8_t _everyPageRollChange;
  42. void GetClockTime(struct timespec* _now_time, void* null)
  43. {
  44. clock_gettime(CLOCK_MONOTONIC, _now_time);
  45. }
  46. void StartSystemTimeoutDet(uint8_t flag)
  47. {
  48. if (pSysInfo->SystemTimeoutFlag != flag) {
  49. log_info("Set System Timeout Flag %d", flag);
  50. GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
  51. }
  52. pSysInfo->SystemTimeoutFlag = flag;
  53. }
  54. void StopSystemTimeoutDet(void)
  55. {
  56. GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
  57. pSysInfo->SystemTimeoutFlag = Timeout_None;
  58. }
  59. //==========================================
  60. // Open and Close RS232 and R/W
  61. //==========================================
  62. unsigned long GetClockTimeoutValue(struct timespec _start_time)
  63. {
  64. struct timespec ts_end;
  65. unsigned long ret = 0;
  66. clock_gettime(CLOCK_MONOTONIC, &ts_end);
  67. ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000)));
  68. return ret;
  69. }
  70. void changeTimeFormat(char* str, struct tm *_trTime)
  71. {
  72. //2022-04-29 06:22:00
  73. int i;
  74. char year[4];
  75. char mon[2];
  76. char day[2];
  77. char hr[2];
  78. char min[2];
  79. char sec[2];
  80. for (i = 0; i < 4; i++) {
  81. year[i] = str[i];
  82. }
  83. _trTime->tm_year = atoi(year) - 1900;
  84. for (i = 0; i < 2; i++) {
  85. mon[i] = str[i+5];
  86. }
  87. _trTime->tm_mon = atoi(mon) - 1;
  88. for (i = 0; i < 2; i++) {
  89. day[i] = str[i + 8];
  90. }
  91. _trTime->tm_mday = atoi(day);
  92. for (i = 0; i < 2; i++) {
  93. hr[i] = str[i + 11];
  94. }
  95. _trTime->tm_hour = atoi(hr);
  96. for (i = 0; i < 2; i++) {
  97. min[i] = str[i + 14];
  98. }
  99. _trTime->tm_min = atoi(min);
  100. for (i = 0; i < 2; i++) {
  101. sec[i] = str[i + 17];
  102. }
  103. _trTime->tm_sec = atoi(sec);
  104. _trTime->tm_isdst = 0;
  105. }
  106. int GetChargingDuration(char* st,char* et)
  107. {
  108. struct tm StartTime,EndTime;
  109. time_t t_start, t_end;
  110. changeTimeFormat(st, &StartTime);
  111. changeTimeFormat(et, &EndTime);
  112. t_start = mktime(&StartTime);
  113. t_end = mktime(&EndTime);
  114. return difftime(t_end, t_start);
  115. }
  116. int CreateCommunicationLcmPort()
  117. {
  118. int fd;
  119. struct termios tios;
  120. fd = open(pPortName, O_RDWR);
  121. if (fd <= 0) {
  122. log_error("open /dev/ttyS3 NG ");
  123. return -1;
  124. }
  125. ioctl(fd, TCGETS, &tios);
  126. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  127. tios.c_lflag = 0;
  128. tios.c_iflag = 0;
  129. tios.c_oflag = 0;
  130. tios.c_cc[VMIN] = 0;
  131. tios.c_cc[VTIME] = (uint8_t) 5;
  132. tios.c_lflag = 0;
  133. tcflush(fd, TCIFLUSH);
  134. ioctl(fd, TCSETS, &tios);
  135. return fd;
  136. }
  137. void CloseCommunicationLcmPort()
  138. {
  139. close(_port);
  140. }
  141. void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
  142. {
  143. int len = write(_port, cmd, cmdLen);
  144. if (len < sizeof(cmd)) {
  145. log_error("Write cmd to LCM Failure. ");
  146. }
  147. }
  148. void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
  149. {
  150. read(_port, msg, readLen);
  151. if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2) {
  152. if (*(msg + 3) == CMD_WRITE) {
  153. switch (*(msg + 4)) {
  154. case CMD_REGISTER: {
  155. // 頁面
  156. strcpy((char *)pSysInfo->LcmHwRev, moduleName);
  157. //_currentPage = *(msg + 7);
  158. }
  159. break;
  160. }
  161. } else if (*(msg + 3) == CMD_MULTI_READ) {
  162. short key = ((short)(*(msg + 4) << 8) + *(msg + 5));
  163. if (key == _LCM_VERSION) {
  164. if (strcmp((char*)pSysInfo->LcmHwRev, "") != EQUAL)
  165. strcpy((char*)pSysInfo->LcmHwRev, moduleName);
  166. if (atoi((char*)(msg + 7)) != 0)
  167. ShmDcCommonData->LcmFwVersion = atoi((char*)(msg + 7));
  168. }
  169. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  170. // {
  171. // case BUTTON_GUN_INDEX:
  172. // {
  173. // // 當前選的槍號
  174. // _curGunIndex = (*(msg + 8));
  175. // }
  176. // break;
  177. // }
  178. }
  179. }
  180. }
  181. void GetHrFormTimeString(char* time,char* hr)
  182. {
  183. //char tm[] = "2021-12-06 17:29:08:084";
  184. int _temp_hr;
  185. for(int i = 0 ; i < 2 ; i++) {
  186. hr[i] = time[i+11];
  187. }
  188. if ((atoi(hr) + 8) > 23) {
  189. _temp_hr = atoi(hr) + 8 - 24;
  190. sprintf(hr, "%02d", _temp_hr);
  191. } else if( atoi(hr) == NULL ) {
  192. strcpy(hr,"");
  193. }
  194. }
  195. void GetMinFormTimeString(char* time,char* min)
  196. {
  197. //char tm[] = "2021-12-06 17:29:08:084";
  198. for(int i = 0 ; i < 2 ; i++) {
  199. min[i] = time[i+14];
  200. }
  201. if( atoi(min) == NULL || atoi(min) > 60) {
  202. strcpy(min,"");
  203. }
  204. }
  205. void GetSecFormTimeString(char* time, char* sec)
  206. {
  207. //char tm[] = "2021-12-06 17:29:08:084";
  208. for (int i = 0; i < 2; i++) {
  209. sec[i] = time[i + 17];
  210. }
  211. if (atoi(sec) == NULL || atoi(sec) > 60) {
  212. strcpy(sec, "");
  213. }
  214. }
  215. //================================================
  216. // Function
  217. //================================================
  218. void ChangeToOtherPage(short newPage)
  219. {
  220. uint8_t cmd[7];
  221. memset(cmd, 0x00, sizeof(cmd));
  222. cmd[0] = CMD_TITLE_1;
  223. cmd[1] = CMD_TITLE_2;
  224. cmd[2] = 0x02 + sizeof(newPage);
  225. cmd[3] = CMD_READ;
  226. cmd[4] = CMD_REGISTER;
  227. cmd[5] = newPage >> 8;
  228. cmd[6] = newPage & 0x00FF;
  229. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  230. usleep(100000);
  231. }
  232. void ChangeBackLight(bool islight)
  233. {
  234. uint8_t value = 0x01;
  235. if (islight) {
  236. value = 0x20;
  237. }
  238. uint8_t cmd[7];
  239. memset(cmd, 0x00, sizeof(cmd));
  240. cmd[0] = CMD_TITLE_1;
  241. cmd[1] = CMD_TITLE_2;
  242. cmd[2] = 0x03;
  243. cmd[3] = CMD_READ;
  244. cmd[4] = CMD_BACKLIGHT;
  245. cmd[5] = value;
  246. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  247. usleep(100000);
  248. }
  249. void GetCurrentPage()
  250. {
  251. uint8_t cmd[6];
  252. memset(cmd, 0x00, sizeof(cmd));
  253. uint8_t msg[8];
  254. memset(msg, 0x00, sizeof(msg));
  255. cmd[0] = CMD_TITLE_1;
  256. cmd[1] = CMD_TITLE_2;
  257. cmd[2] = 0x03; // 底下總長度
  258. cmd[3] = CMD_WRITE;
  259. cmd[4] = CMD_REGISTER;
  260. cmd[5] = 0x02;
  261. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  262. usleep(5000);
  263. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  264. }
  265. void DisplayValueToLcm(short address, uint8_t *data, uint8_t len)
  266. {
  267. uint8_t cmd[256];
  268. memset(cmd, 0x00, sizeof(cmd));
  269. cmd[0] = CMD_TITLE_1;
  270. cmd[1] = CMD_TITLE_2;
  271. cmd[2] = 0x03 + len;
  272. cmd[3] = CMD_MULTI_WRITE;
  273. cmd[4] = address >> 8;
  274. cmd[5] = address & 0x00FF;
  275. for (uint8_t count = 0; count < len; count++) {
  276. cmd[6 + count] = *(data + count);
  277. }
  278. WriteCmdToLcm(cmd, cmd[2] + 3);
  279. }
  280. void ChangeDisplay2Value(short address, short value)
  281. {
  282. uint8_t data[2];
  283. data[0] = value >> 8;
  284. data[1] = value & 0x00FF;
  285. //log_info("Addr:0x%x, value:%d",address,value);
  286. DisplayValueToLcm(address, data, sizeof(data));
  287. }
  288. void ChangeDisplay2LongValue(short address, long value)
  289. {
  290. uint8_t data[4];
  291. data[0] = (value >> 24) & 0xFF;
  292. data[1] = (value >> 16 ) & 0xFF;
  293. data[2] = (value >> 8) & 0xFF;
  294. data[3] = value & 0x000000FF;
  295. /*
  296. log_info("long Addr:0x%x, value:%d",address,value);
  297. for (int i = 0; i < 4; i++) {
  298. log_info("data[%d]:%d",i,data[i]);
  299. }
  300. */
  301. DisplayValueToLcm(address, data, sizeof(data));
  302. }
  303. //================================================
  304. // Warning process
  305. //================================================
  306. void string2ByteArray(uint8_t *input, uint8_t *output)
  307. {
  308. int loop;
  309. int i;
  310. loop = 0;
  311. i = 0;
  312. while (input[loop] != '\0') {
  313. output[i++] = input[loop++];
  314. }
  315. output[loop] = '\0';
  316. }
  317. void RefreshProgressAnimation(uint8_t progress_index)
  318. {
  319. if(_everyPageRollChange % 2) {
  320. progress_index+=1;
  321. }
  322. ChangeDisplay2Value(_ProgressBar_LEVEL,progress_index);
  323. _everyPageRollChange++;
  324. }
  325. //================================================
  326. // Change current page
  327. //================================================
  328. void ChangeCurPage()
  329. {
  330. //log_info("cur = %d ,system = %d, lcm = %d ",_currentPage, pSysInfo->SystemPage, pSysInfo->PageIndex);
  331. struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  332. struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  333. if (pSysWarning->Level == WARN_LV_ER) {
  334. pSysInfo->SystemPage = _LCM_MAINTAIN;
  335. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton)
  336. pSysInfo->SystemPage = _LCM_EMERGENCY;
  337. }
  338. switch (pSysInfo->SystemPage) {
  339. case _LCM_VIEW:
  340. if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_IDLE ) {
  341. pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
  342. } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_IDLE) {
  343. pSysInfo->PageIndex = __VIEW_LEFT_CHARGE_;
  344. } else if(pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  345. pSysInfo->PageIndex = __VIEW_RIGHT_CHARGE_;
  346. } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  347. pSysInfo->PageIndex = __VIEW_ALL_CHARGE_;
  348. } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT )&&
  349. pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  350. if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
  351. pSysInfo->PageIndex = __VIEW_L_LINK_R_CHARGE;
  352. else
  353. pSysInfo->PageIndex = __VIEW_L_FAIL_R_CHARGE;
  354. } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING &&
  355. (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
  356. if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
  357. pSysInfo->PageIndex = __VIEW_L_CHARGE_R_LINK;
  358. else
  359. pSysInfo->PageIndex = __VIEW_L_CHARGE_R_FAIL;
  360. } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT) &&
  361. pDcChargingInfo_1->SystemStatus == S_IDLE) {
  362. if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
  363. pSysInfo->PageIndex = __VIEW_L_LINK_R_IDLE;
  364. else
  365. pSysInfo->PageIndex = __VIEW_L_FAIL_R_IDLE;
  366. } else if (pDcChargingInfo_0->SystemStatus == S_IDLE &&
  367. (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
  368. if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
  369. pSysInfo->PageIndex = __VIEW_L_IDLE_R_LINK;
  370. else
  371. pSysInfo->PageIndex = __VIEW_L_IDLE_R_FAIL;
  372. } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT) &&
  373. (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
  374. if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM] &&
  375. pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM]) {
  376. pSysInfo->PageIndex = __VIEW_L_OUT_R_OUT;
  377. } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM]) {
  378. pSysInfo->PageIndex = __VIEW_L_LINK_R_FAIL;
  379. } else if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM]) {
  380. pSysInfo->PageIndex = __VIEW_L_FAIL_R_LINK;
  381. } else
  382. pSysInfo->PageIndex = __VIEW_ALL_FAIL;
  383. } else if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
  384. pSysInfo->PageIndex = __VIEW_L_IDLE_R_MAINTAIN;
  385. } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_IDLE) {
  386. pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_IDLE;
  387. } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
  388. pSysInfo->PageIndex = __VIEW_L_CHARGE_R_MAINTAIN;
  389. } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  390. pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_CHARGE;
  391. } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
  392. pSysInfo->PageIndex = __MAINTAIN_PAGE_;
  393. } else if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_COMPLETE &&
  394. pDcChargingInfo_1->ConnectorPlugIn) {
  395. pSysInfo->PageIndex = __VIEW_L_IDLE_R_OUT;
  396. } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_IDLE &&
  397. pDcChargingInfo_0->ConnectorPlugIn) {
  398. pSysInfo->PageIndex = __VIEW_L_OUT_R_IDLE;
  399. } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_COMPLETE &&
  400. pDcChargingInfo_1->ConnectorPlugIn) {
  401. pSysInfo->PageIndex = __VIEW_L_CHARGE_R_OUT;
  402. } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_CHARGING &&
  403. pDcChargingInfo_0->ConnectorPlugIn) {
  404. pSysInfo->PageIndex = __VIEW_L_OUT_R_CHARGE;
  405. } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_COMPLETE &&
  406. pDcChargingInfo_1->ConnectorPlugIn) {
  407. pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_OUT;
  408. } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_MAINTAIN &&
  409. pDcChargingInfo_0->ConnectorPlugIn) {
  410. pSysInfo->PageIndex = __VIEW_L_OUT_R_MAINTAIN;
  411. } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_COMPLETE &&
  412. pDcChargingInfo_0->ConnectorPlugIn && pDcChargingInfo_1->ConnectorPlugIn) {
  413. pSysInfo->PageIndex = __VIEW_L_OUT_R_OUT;
  414. } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT) &&
  415. pDcChargingInfo_1->SystemStatus == S_COMPLETE && pDcChargingInfo_1->ConnectorPlugIn) {
  416. if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
  417. pSysInfo->PageIndex = __VIEW_L_LINK_R_OUT;
  418. else
  419. pSysInfo->PageIndex = __VIEW_L_FAIL_R_OUT;
  420. } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_0->ConnectorPlugIn &&
  421. (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
  422. if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
  423. pSysInfo->PageIndex = __VIEW_L_OUT_R_LINK;
  424. else
  425. pSysInfo->PageIndex = __VIEW_L_OUT_R_FAIL;
  426. } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN &&
  427. (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
  428. if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
  429. pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_LINK;
  430. else
  431. pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_FAIL;
  432. } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT ) &&
  433. pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
  434. if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
  435. pSysInfo->PageIndex = __VIEW_L_LINK_R_MAINTAIN;
  436. else
  437. pSysInfo->PageIndex = __VIEW_L_FAIL_R_MAINTAIN;
  438. } else {
  439. pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
  440. }
  441. break;
  442. case _LCM_START_SCAN:
  443. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  444. pSysInfo->PageIndex = __START_SCAN_LEFT;
  445. else
  446. pSysInfo->PageIndex = __START_SCAN_RIGHT;
  447. break;
  448. case _LCM_START_AUTHORIZING:
  449. pSysInfo->PageIndex = __START_AUTHORIZE_;
  450. break;
  451. case _LCM_START_AUTHORIZE_FAIL:
  452. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  453. pSysInfo->PageIndex = __START_AUTHORIZE_FAIL_LEFT;
  454. else
  455. pSysInfo->PageIndex = __START_AUTHORIZE_FAIL_RIGHT;
  456. break;
  457. case _LCM_WAIT_PLUGIN:
  458. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  459. pSysInfo->PageIndex = __WAIT_PLUGIN_;
  460. else
  461. pSysInfo->PageIndex = __WAIT_PLUGIN_RIGHT;
  462. break;
  463. case _LCM_PRECHARGE:
  464. pSysInfo->PageIndex =__PRE_CHARGE_;
  465. break;
  466. case _LCM_LINK_ERROR:
  467. if(pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  468. pSysInfo->PageIndex = __LINKING_ERROR_LEFT;
  469. else
  470. pSysInfo->PageIndex = __LINKING_ERROR_RIGHT;
  471. break;
  472. /*
  473. case _LCM_DETAIL_VIEW:
  474. pSysInfo->PageIndex =__DETAIL_VIEW_;
  475. break;
  476. case _LCM_STOP_RFID:
  477. pSysInfo->PageIndex =__STOP_SCAN_RFID_;
  478. break;
  479. case _LCM_STOP_APP:
  480. pSysInfo->PageIndex =__STOP_SCAN_APP_;
  481. break;
  482. case _LCM_STOP_RFID_FAIL:
  483. pSysInfo->PageIndex =__STOP_RFID_FAIL_;
  484. break;
  485. */
  486. case _LCM_STOPPING:
  487. pSysInfo->PageIndex = __STOP_AUTHORIZE_;
  488. break;
  489. case _LCM_WAIT_PLUGOUT:
  490. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  491. pSysInfo->PageIndex = __WAIT_PLUGOUT_LEFT;
  492. else
  493. pSysInfo->PageIndex = __WAIT_PLUGOUT_RIGHT;
  494. break;
  495. case _LCM_SUMMARY:
  496. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  497. pSysInfo->PageIndex = __SUMMARY_LEFT;
  498. else
  499. pSysInfo->PageIndex = __SUMMARY_RIGHT;
  500. break;
  501. case _LCM_MAINTAIN:
  502. pSysInfo->PageIndex =__MAINTAIN_PAGE_;
  503. break;
  504. case _LCM_ERROR:
  505. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  506. pSysInfo->PageIndex = __ERROR_PAGE_LEFT;
  507. else
  508. pSysInfo->PageIndex = __ERROR_PAGE_RIGHT;
  509. break;
  510. case _LCM_EMERGENCY:
  511. pSysInfo->PageIndex =__EMERGENCY_BUTTON_;
  512. break;
  513. case _LCM_CONFIRM_STOP:
  514. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  515. pSysInfo->PageIndex = __CONFIRM_STOP_LEFT;
  516. } else
  517. pSysInfo->PageIndex = __CONFIRM_STOP_RIGHT;
  518. break;
  519. case _LCM_COMMUNICATION:
  520. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  521. pSysInfo->PageIndex = __PRECHARGE_LEFT_CONNECT;
  522. } else {
  523. pSysInfo->PageIndex = __PRECHARGE_RIGHT_CONNECT;
  524. }
  525. break;
  526. case _LCM_CHARGING_DETECT:
  527. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  528. pSysInfo->PageIndex = __PRECHARGE_LEFT_CHECK;
  529. } else {
  530. pSysInfo->PageIndex = __PRECHARGE_RIGHT_CHECK;
  531. }
  532. break;
  533. case _LCM_PREPARECHARE:
  534. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  535. pSysInfo->PageIndex = __PRECHARGE_LEFT_START;
  536. } else {
  537. pSysInfo->PageIndex = __PRECHARGE_RIGHT_START;
  538. }
  539. break;
  540. }
  541. if (_currentPage != pSysInfo->PageIndex) {
  542. log_info("Gun%d Change Page from %d to %d",pSysInfo->CurGunSelected, _currentPage, pSysInfo->PageIndex);
  543. }
  544. _currentPage = pSysInfo->PageIndex;
  545. ChangeToOtherPage(pSysInfo->PageIndex);
  546. }
  547. /*
  548. * View Page
  549. *
  550. */
  551. void ShowViewChargingSoc(uint8_t gunIndex,int soc)
  552. {
  553. uint8_t digits = soc % 10;
  554. uint8_t tens = (soc / 10) %10;
  555. uint8_t hundreds = soc / 100;
  556. if (gunIndex == LEFT_GUN_NUM) {
  557. ChangeDisplay2Value(_LeftGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
  558. if (hundreds == 0 ) {
  559. ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Empty);
  560. if (tens == 0 )
  561. ChangeDisplay2Value(_LeftGun_Soc_Tens,(short)_ICON_Empty);
  562. else
  563. ChangeDisplay2Value(_LeftGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
  564. } else {
  565. ChangeDisplay2Value(_LeftGun_Soc_Hundreds, (short)_ICON_Red_Num_1);
  566. ChangeDisplay2Value(_LeftGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
  567. }
  568. } else {
  569. ChangeDisplay2Value(_RightGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
  570. if (hundreds == 0 ) {
  571. ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Empty);
  572. if (tens == 0)
  573. ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Empty);
  574. else
  575. ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Red_Num_0+ tens);
  576. } else {
  577. ChangeDisplay2Value(_RightGun_Soc_Hundreds, (short)_ICON_Red_Num_1);
  578. ChangeDisplay2Value(_RightGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
  579. }
  580. }
  581. }
  582. void ShowViewChargingTime(uint8_t gunIndex,int time)
  583. {
  584. int min,sec;
  585. int ShowTime;
  586. min = time/60;
  587. sec = time % 60;
  588. ShowTime = min * 100 + sec;
  589. //sprintf((char *)value,"%d:%02d",min,sec);
  590. if (gunIndex == LEFT_GUN_NUM) {
  591. ChangeDisplay2Value(_LeftGun_info_time, (short)ShowTime);
  592. } else {
  593. ChangeDisplay2Value(_RightGun_info_time, (short)ShowTime);
  594. }
  595. }
  596. void ShowViewChargingEngery(uint8_t gunIndex, float energy)
  597. {
  598. float data = energy * 10;
  599. if (energy < 0)
  600. data = fabs(energy);
  601. if (gunIndex == LEFT_GUN_NUM) {
  602. ChangeDisplay2Value(_LeftGun_info_cap, data);
  603. } else
  604. ChangeDisplay2Value(_RightGun_info_cap, data);
  605. /*
  606. if(energy < 100)
  607. sprintf((char*)value, "%.1f", energy);
  608. else
  609. sprintf((char*)value, "%d", (int)energy);
  610. //log_info("gun[%d] energy:%.1f", gunIndex, energy);
  611. if (gunIndex == LEFT_GUN_NUM) {
  612. DisplayValueToLcm(_LeftGun_info_cap, (uint8_t*)value, sizeof(value));
  613. }
  614. else
  615. DisplayValueToLcm(_RightGun_info_cap, (uint8_t*)value, sizeof(value));
  616. */
  617. }
  618. void ShowViewCharingMoney(uint8_t gunIndex,float money)
  619. {
  620. float data = money;
  621. if (money < 0)
  622. data = fabs(money);
  623. if (gunIndex == LEFT_GUN_NUM) {
  624. ChangeDisplay2Value(_LeftGun_info_money, data);
  625. } else
  626. ChangeDisplay2Value(_RightGun_info_money, data);
  627. /*
  628. uint8_t value[10] = {0};
  629. sprintf((char *)value,"%d",(int)money);
  630. //log_info("gun[%d] money:%.1f", gunIndex, money);
  631. if (gunIndex == LEFT_GUN_NUM) {
  632. DisplayValueToLcm(_LeftGun_info_money, (uint8_t *)value, sizeof(value));
  633. } else
  634. DisplayValueToLcm(_RightGun_info_money, (uint8_t *)value, sizeof(value));
  635. */
  636. }
  637. void ShowViewChargingPower(uint8_t gunIndex,float power)
  638. {
  639. uint8_t value[10] = {0};
  640. float _data = power * 10;
  641. sprintf((char *)value,"%.1f",power);
  642. //log_info("gun[%d] power:%.1f",gunIndex,power);
  643. if (power >= 0 && power <= POWER_MAX_KW) {
  644. if (gunIndex == LEFT_GUN_NUM) {
  645. ChangeDisplay2Value(_LeftGun_info_power_number, _data);
  646. //DisplayValueToLcm(_LeftGun_info_power_number, (uint8_t *)value, sizeof(value));
  647. } else {
  648. //DisplayValueToLcm(_RightGun_info_power_number, (uint8_t*)value, sizeof(value));
  649. ChangeDisplay2Value(_RightGun_info_power_number, _data);
  650. }
  651. }
  652. }
  653. void ShowConnectId()
  654. {
  655. int id = atoi(pSysConfig->SystemId);
  656. if (id == 0)
  657. id = 1;
  658. ChangeDisplay2Value(_Text_SystemID, id);
  659. if (ShmDcCommonData->ConnectorId[0] <= 2) {
  660. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
  661. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
  662. } else {
  663. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_C);
  664. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_D);
  665. }
  666. }
  667. void ShowViewLeftGunInfo()
  668. {
  669. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  670. if (pDcChargingInfo->SystemStatus == S_IDLE ) {
  671. switch (pDcChargingInfo->CCSGunType) {
  672. case _TYPE_CCS1_Liquid:
  673. case _TYPE_CCS1_Natural:
  674. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS1_GUN_U);
  675. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS1_GUN_L);
  676. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS1_Name);
  677. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  678. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  679. } else {
  680. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  681. }
  682. break;
  683. case _TYPE_CCS2_Liquid:
  684. case _TYPE_CCS2_Natural:
  685. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS2_GUN_U);
  686. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS2_GUN_L);
  687. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS2_Name);
  688. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  689. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  690. } else {
  691. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  692. }
  693. break;
  694. default:
  695. log_error("CCS Gun Type Error! Not Show in LCM!!");
  696. }
  697. } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
  698. ShowViewChargingSoc(LEFT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
  699. if (strlen(ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeStartTime) > 1) {
  700. int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeStartTime,
  701. ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeDuration);
  702. ShowViewChargingTime(LEFT_GUN_NUM, duration);
  703. } else {
  704. ShowViewChargingTime(LEFT_GUN_NUM, 0);
  705. }
  706. ShowViewCharingMoney(LEFT_GUN_NUM,pDcChargingInfo->ChargingFee);
  707. ShowViewChargingPower(LEFT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
  708. ShowViewChargingEngery(LEFT_GUN_NUM, pDcChargingInfo->PresentChargedEnergy);
  709. switch (pDcChargingInfo->CCSGunType) {
  710. case _TYPE_CCS1_Liquid:
  711. case _TYPE_CCS1_Natural:
  712. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS1_Name);
  713. break;
  714. case _TYPE_CCS2_Liquid:
  715. case _TYPE_CCS2_Natural:
  716. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS2_Name);
  717. break;
  718. }
  719. }
  720. }
  721. void ShowViewRightGunInfo()
  722. {
  723. char value[5];
  724. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  725. if (pDcChargingInfo->SystemStatus == S_IDLE ) {
  726. switch (pDcChargingInfo->CCSGunType) {
  727. case _TYPE_CCS1_Liquid:
  728. case _TYPE_CCS1_Natural:
  729. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS1_GUN_U);
  730. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS1_GUN_L);
  731. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS1_Name);
  732. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  733. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  734. } else {
  735. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  736. }
  737. break;
  738. case _TYPE_CCS2_Liquid:
  739. case _TYPE_CCS2_Natural:
  740. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS2_GUN_U);
  741. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS2_GUN_L);
  742. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS2_Name);
  743. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  744. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  745. } else {
  746. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  747. }
  748. break;
  749. default:
  750. log_error("CCS Gun Type Error! Not Show in LCM!!");
  751. }
  752. memset(value, 0x00, sizeof(value));
  753. sprintf((char *)value,"1 B");
  754. DisplayValueToLcm(_RightGun_location, (uint8_t *)value, sizeof(value));
  755. } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
  756. ShowViewChargingSoc(RIGHT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
  757. if (strlen(ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeStartTime) > 1) {
  758. int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeStartTime,
  759. ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeDuration);
  760. ShowViewChargingTime(RIGHT_GUN_NUM, duration);
  761. } else {
  762. ShowViewChargingTime(RIGHT_GUN_NUM, 0);
  763. }
  764. ShowViewCharingMoney(RIGHT_GUN_NUM,pDcChargingInfo->ChargingFee);
  765. ShowViewChargingPower(RIGHT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
  766. ShowViewChargingEngery(RIGHT_GUN_NUM, pDcChargingInfo->PresentChargedEnergy);
  767. switch (pDcChargingInfo->CCSGunType) {
  768. case _TYPE_CCS1_Liquid:
  769. case _TYPE_CCS1_Natural:
  770. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS1_Name);
  771. break;
  772. case _TYPE_CCS2_Liquid:
  773. case _TYPE_CCS2_Natural:
  774. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS2_Name);
  775. break;
  776. }
  777. }
  778. }
  779. void SetViewPage()
  780. {
  781. // Set Background pic.
  782. if (pSysConfig->TotalConnectorCount == 1) {
  783. } else if (pSysConfig->TotalConnectorCount == 2) {
  784. ShowConnectId();
  785. ShowViewLeftGunInfo();
  786. ShowViewRightGunInfo();
  787. }
  788. }
  789. void ShowSelectGunIcon()
  790. {
  791. uint8_t value[5] = {0};
  792. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  793. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  794. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  795. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  796. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
  797. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  798. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  799. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS2_Symbol);
  800. }
  801. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
  802. sprintf((char *)value,"%s",LEFT_GUN_LOCAL_NAME);
  803. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  804. memset(value, 0x00, sizeof(value));
  805. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  806. } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
  807. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  808. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  809. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS1_Symbol);
  810. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  811. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  812. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
  813. }
  814. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
  815. sprintf((char *)value,"%s",RIGHT_GUN_LOCAL_NAME);
  816. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  817. memset(value, 0x00, sizeof(value));
  818. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  819. }
  820. }
  821. void ShowCountDownTimer()
  822. {
  823. int min,sec;
  824. uint8_t value[10] = {0};
  825. int tm = 120 - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
  826. // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
  827. min = tm/60;
  828. sec = tm%60;
  829. sprintf((char *)value,"%02d:%02d",min,sec);
  830. if (pSysInfo->SystemPage == _LCM_SUMMARY) {
  831. sprintf((char*)value, "");
  832. DisplayValueToLcm(_Count_Down_Time, (uint8_t*)value, sizeof(value));
  833. }
  834. else
  835. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  836. }
  837. unsigned long GetTimeoutValue(struct timeval _sour_time)
  838. {
  839. struct timeval _end_time;
  840. gettimeofday(&_end_time, NULL);
  841. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  842. }
  843. void ShowGunCountDownTimer()
  844. {
  845. int min,sec;
  846. uint8_t value[10] = {0};
  847. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  848. int tm = 30 - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL);
  849. // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
  850. min = tm/60;
  851. sec = tm%60;
  852. sprintf((char *)value,"%02d:%02d",min,sec);
  853. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  854. }
  855. void ClearQrCode()
  856. {
  857. char cmd[200];
  858. memset(cmd, 0, 200);
  859. DisplayValueToLcm(_QR_CODE_AUTHORIZE, (uint8_t *)cmd, 200);
  860. }
  861. void ChangeQrCode()
  862. {
  863. char cmd[200];
  864. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  865. memset(cmd, 0 , 200);
  866. int len = sprintf(cmd, "https://qrcode.u-power.app/connector?chargebox=%s&connectorno=%d", ShmDcCommonData->QRCodeString, ShmDcCommonData->ConnectorId[pSysInfo->CurGunSelected]);
  867. //int len = sprintf(cmd, "http://www.u-power.com.tw/");
  868. if (len > 200) {
  869. log_info("QR Code URL length too long");
  870. }
  871. DisplayValueToLcm(_QR_CODE_AUTHORIZE, cmd, 200);
  872. }
  873. void ShowProgressBar()
  874. {
  875. /*
  876. for(int i = 0 ; i <= 19 ; i++) {
  877. ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+i);
  878. usleep(100000);
  879. }*/
  880. }
  881. void ShowChargeTime(int addr,int _time)
  882. {
  883. int tens, digits;
  884. tens = _time / 10;
  885. digits = _time % 10;
  886. ChangeDisplay2Value(addr, tens);
  887. ChangeDisplay2Value(addr+2, digits);
  888. }
  889. void ShowSummaryMoney(int addr, int money)
  890. {
  891. int dig, tens, hund, thou,shift;
  892. if (addr == _Summary_total_money) {
  893. shift = 42;
  894. } else {
  895. shift = 100;
  896. }
  897. if (money > 9999) {
  898. money = 9999;
  899. }
  900. thou = money / 1000;
  901. hund = (money / 100) % 10;
  902. tens = (money / 10) % 10;
  903. dig = money % 10;
  904. ChangeDisplay2Value(addr + 6, thou == 0 ? _ICON_Empty : thou+shift);
  905. if (thou == 0) {
  906. ChangeDisplay2Value(addr + 4, hund == 0 ? _ICON_Empty : hund + shift);
  907. if (addr == _Summary_cal_discount)
  908. ChangeDisplay2Value(addr + 8, _ICON_Empty);
  909. if (hund == 0) {
  910. ChangeDisplay2Value(addr + 2, tens == 0 ? _ICON_Empty : tens + shift);
  911. } else {
  912. ChangeDisplay2Value(addr + 2, tens + shift);
  913. }
  914. } else {
  915. ChangeDisplay2Value(addr + 4, hund + shift);
  916. ChangeDisplay2Value(addr + 2, tens + shift);
  917. }
  918. ChangeDisplay2Value(addr, dig + shift);
  919. // 給UPOINT負號
  920. if (addr == _Summary_cal_discount) {
  921. if (thou == 0) {
  922. if (hund == 0) {
  923. if (tens == 0) {
  924. ChangeDisplay2Value(addr + 2, _ICON_negative);
  925. } else {
  926. ChangeDisplay2Value(addr + 4, _ICON_negative);
  927. }
  928. } else {
  929. ChangeDisplay2Value(addr + 6, _ICON_negative);
  930. }
  931. } else {
  932. ChangeDisplay2Value(addr + 8, _ICON_negative);
  933. }
  934. }
  935. }
  936. void ShowSummaryMoneyDash(int addr)
  937. {
  938. if (addr == _Summary_total_money) {
  939. ChangeDisplay2Value(addr , _ICON_DASH_SINGLE);
  940. ChangeDisplay2Value(addr + 2, _ICON_DASH_SINGLE);
  941. ChangeDisplay2Value(addr + 4, _ICON_Empty);
  942. ChangeDisplay2Value(addr + 6, _ICON_Empty);
  943. } else {
  944. ChangeDisplay2Value(addr, _ICON_DASH_SINGLE);
  945. ChangeDisplay2Value(addr + 2, _ICON_DASH_SINGLE);
  946. ChangeDisplay2Value(addr + 4, _ICON_Empty);
  947. ChangeDisplay2Value(addr + 6, _ICON_Empty);
  948. ChangeDisplay2Value(addr + 8, _ICON_Empty);
  949. }
  950. }
  951. void ShowSummaryPage()
  952. {
  953. float data;
  954. char start_hr[3],start_min[3],start_sec[3],end_hr[3],end_min[3],end_sec[3];
  955. int t_hr;
  956. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  957. // Show Money
  958. if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].finalcost_flag) {
  959. ShowSummaryMoney(_Summary_total_money, (int)ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].RemainAmount);
  960. ShowSummaryMoney(_Summary_cal_Total_money, (int)pDcChargingInfo->ChargingFee);
  961. ShowSummaryMoney(_Summary_cal_discount, (int)ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Discount);
  962. } else {
  963. // 未收到Final cost
  964. ShowSummaryMoneyDash(_Summary_total_money);
  965. ShowSummaryMoneyDash(_Summary_cal_Total_money);
  966. ShowSummaryMoneyDash(_Summary_cal_discount);
  967. }
  968. /*
  969. log_info("start time:%s",pDcChargingInfo->StartDateTime);
  970. log_info("stop time:%s",pDcChargingInfo->StopDateTime);*/
  971. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_hr);
  972. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime,start_min);
  973. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_sec);
  974. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime,end_hr);
  975. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime,end_min);
  976. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_sec);
  977. t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
  978. if (t_hr >= 24)
  979. t_hr -= 24;
  980. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime) == 0) {
  981. ShowChargeTime(_Summary_Start_time_hr,0);
  982. ShowChargeTime(_Summary_Start_time_min, 0);
  983. ShowChargeTime(_Summary_Start_time_sec, 0);
  984. } else {
  985. ShowChargeTime(_Summary_Start_time_hr, t_hr);
  986. ShowChargeTime(_Summary_Start_time_min, atoi(start_min));
  987. ShowChargeTime(_Summary_Start_time_sec, atoi(start_sec));
  988. }
  989. t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
  990. if (t_hr >= 24)
  991. t_hr -= 24;
  992. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime) == 0) {
  993. ShowChargeTime(_Summary_end_time_hr, 0);
  994. ShowChargeTime(_Summary_end_time_min, 0);
  995. ShowChargeTime(_Summary_end_time_sec, 0);
  996. } else {
  997. ShowChargeTime(_Summary_end_time_hr, t_hr);
  998. ShowChargeTime(_Summary_end_time_min, atoi(end_min));
  999. ShowChargeTime(_Summary_end_time_sec, atoi(end_sec));
  1000. }
  1001. /*
  1002. DisplayValueToLcm(_Summary_Start_time_hr, (uint8_t *)start_hr, sizeof(start_hr));
  1003. DisplayValueToLcm(_Summary_Start_time_min, (uint8_t *)start_min, sizeof(start_min));
  1004. DisplayValueToLcm(_Summary_end_time_hr, (uint8_t *)end_hr, sizeof(end_hr));
  1005. DisplayValueToLcm(_Summary_end_time_min, (uint8_t *)end_min, sizeof(end_min));
  1006. */
  1007. int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime,
  1008. ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime);
  1009. //uint8_t _min = (pDcChargingInfo->PresentChargedDuration)/60;
  1010. //uint8_t _sec = (pDcChargingInfo->PresentChargedDuration) % 60;
  1011. /*
  1012. sprintf((char *)value,"%d",min);
  1013. DisplayValueToLcm(_Summary_duration_time, (uint8_t *)value, sizeof(value));
  1014. */
  1015. ChangeDisplay2Value(_Summary_duration_min, (int)duration/60);
  1016. ChangeDisplay2Value(_Summary_duration_sec, (int)duration%60);
  1017. if (pDcChargingInfo->PresentChargedEnergy > 0.001 &&
  1018. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1019. data = pDcChargingInfo->PresentChargedEnergy*1000;
  1020. } else
  1021. data = 0;
  1022. //sprintf((char *)value,"%.1f",data);
  1023. ChangeDisplay2LongValue(_Summary_cap, data);
  1024. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  1025. ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_0);
  1026. }
  1027. else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
  1028. ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_1);
  1029. }
  1030. if (pDcChargingInfo->PowerConsumption >= 0.1 ) {
  1031. data = pDcChargingInfo->PowerConsumption / pDcChargingInfo->PresentChargedDuration;
  1032. } else
  1033. data = 0;
  1034. //sprintf((char *)value,"%.1f",data);
  1035. ChangeDisplay2Value(_Summary_average_power, (int)data);
  1036. //DisplayValueToLcm(_Summary_average_power, (uint8_t *)value, sizeof(value));
  1037. }
  1038. void ProcessPageInfo()
  1039. {
  1040. switch (pSysInfo->SystemPage) {
  1041. case _LCM_VIEW:
  1042. // Confirm Charging Gun Number.
  1043. SetViewPage();
  1044. break;
  1045. case _LCM_START_SCAN:
  1046. ChangeQrCode();
  1047. ShowSelectGunIcon();
  1048. ShowCountDownTimer();
  1049. break;
  1050. case _LCM_START_AUTHORIZING:
  1051. case _LCM_PRECHARGE:
  1052. case _LCM_STOPPING:
  1053. ChangeDisplay2Value(_Animation_Running, 1);
  1054. break;
  1055. case _LCM_START_AUTHORIZE_FAIL:
  1056. case _LCM_LINK_ERROR:
  1057. ShowCountDownTimer();
  1058. break;
  1059. case _LCM_SUMMARY:
  1060. StartSystemTimeoutDet(Timeout_ReturnViewPage);
  1061. ShowCountDownTimer();
  1062. ShowSummaryPage();
  1063. break;
  1064. case _LCM_ERROR:
  1065. break;
  1066. case _LCM_MAINTAIN:
  1067. break;
  1068. case _LCM_WAIT_PLUGIN:
  1069. case _LCM_WAIT_PLUGOUT:
  1070. break;
  1071. case _LCM_EMERGENCY:
  1072. break;
  1073. case _LCM_COMMUNICATION:
  1074. ChangeDisplay2Value(_Animation_Communcation, 1);
  1075. break;
  1076. case _LCM_CHARGING_DETECT:
  1077. ChangeDisplay2Value(_Animation_GFD, 1);
  1078. break;
  1079. case _LCM_PREPARECHARE:
  1080. ChangeDisplay2Value(_Animation_Precharge, 1);
  1081. break;
  1082. }
  1083. }
  1084. void DemoFunction()
  1085. {
  1086. int i;
  1087. uint8_t value[10];
  1088. struct timeb SeqEndTime;
  1089. struct tm *tm;
  1090. int t_hr;
  1091. char start_hr[3], start_min[3], start_sec[3], end_hr[3], end_min[3], end_sec[3];
  1092. ChangeDisplay2Value(_Animation_Running, 1);
  1093. ChangeDisplay2Value(_Animation_Communcation, 1);
  1094. ChangeDisplay2Value(_Animation_GFD, 1);
  1095. ChangeDisplay2Value(_Animation_Precharge, 1);
  1096. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
  1097. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
  1098. ChangeDisplay2Value(_LeftGun_ConnectorId, _ICON_CONNECTOR_1);
  1099. ChangeDisplay2Value(_RightGun_ConnectorId, _ICON_CONNECTOR_1);
  1100. switch (pSysInfo->PageIndex) {
  1101. case __VIEW_ALL_IDLE_:
  1102. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
  1103. switch (pDcChargingInfo->CCSGunType) {
  1104. case _TYPE_CCS1_Liquid:
  1105. case _TYPE_CCS1_Natural:
  1106. ChangeDisplay2Value(_LeftGun_type_pic_U, _ICON_CCS1_GUN_U);
  1107. ChangeDisplay2Value(_LeftGun_type_pic_L, _ICON_CCS1_GUN_L);
  1108. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS1_Name);
  1109. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  1110. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_High_Speed);
  1111. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_B);
  1112. } else {
  1113. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
  1114. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_Speed);
  1115. }
  1116. break;
  1117. case _TYPE_CCS2_Liquid:
  1118. case _TYPE_CCS2_Natural:
  1119. ChangeDisplay2Value(_LeftGun_type_pic_U, _ICON_CCS2_GUN_U);
  1120. ChangeDisplay2Value(_LeftGun_type_pic_L, _ICON_CCS2_GUN_L);
  1121. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS2_Name);
  1122. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_C);
  1123. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  1124. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_High_Speed);
  1125. } else {
  1126. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_Speed);
  1127. }
  1128. break;
  1129. }
  1130. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1131. switch (pDcChargingInfo->CCSGunType) {
  1132. case _TYPE_CCS1_Liquid:
  1133. case _TYPE_CCS1_Natural:
  1134. ChangeDisplay2Value(_RightGun_type_pic_U, _ICON_CCS1_GUN_U);
  1135. ChangeDisplay2Value(_RightGun_type_pic_L, _ICON_CCS1_GUN_L);
  1136. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS1_Name);
  1137. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  1138. ChangeDisplay2Value(_RightGun_type_speed, _ICON_High_Speed);
  1139. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
  1140. } else {
  1141. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_A);
  1142. ChangeDisplay2Value(_RightGun_type_speed, _ICON_Speed);
  1143. }
  1144. break;
  1145. case _TYPE_CCS2_Liquid:
  1146. case _TYPE_CCS2_Natural:
  1147. ChangeDisplay2Value(_RightGun_type_pic_U, _ICON_CCS2_GUN_U);
  1148. ChangeDisplay2Value(_RightGun_type_pic_L, _ICON_CCS2_GUN_L);
  1149. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS2_Name);
  1150. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_D);
  1151. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  1152. ChangeDisplay2Value(_RightGun_type_speed, _ICON_High_Speed);
  1153. } else {
  1154. ChangeDisplay2Value(_RightGun_type_speed, _ICON_Speed);
  1155. }
  1156. break;
  1157. }
  1158. sleep(5);
  1159. break;
  1160. case __VIEW_LEFT_CHARGE_:
  1161. for (i = 0; i <= 100; i++) {
  1162. ShowViewChargingSoc(LEFT_GUN_NUM,66+i/20);
  1163. ShowViewChargingTime(LEFT_GUN_NUM,i);
  1164. ShowViewCharingMoney(LEFT_GUN_NUM,i);
  1165. ShowViewChargingPower(LEFT_GUN_NUM, (float)(66 + i *0.1));
  1166. ShowViewChargingEngery(LEFT_GUN_NUM,50+i/30);
  1167. usleep(100000);
  1168. }
  1169. break;
  1170. case __VIEW_RIGHT_CHARGE_:
  1171. for (i = 0; i <= 100; i++) {
  1172. ShowViewChargingSoc(RIGHT_GUN_NUM,88+i/25);
  1173. ShowViewChargingTime(RIGHT_GUN_NUM,i);
  1174. ShowViewCharingMoney(RIGHT_GUN_NUM,i);
  1175. ShowViewChargingPower(RIGHT_GUN_NUM, (float)(88 + i*0.1));
  1176. ShowViewChargingEngery(RIGHT_GUN_NUM, 30+i/30);
  1177. usleep(100000);
  1178. }
  1179. break;
  1180. case __VIEW_ALL_CHARGE_:
  1181. for(i=0;i<=100;i++) {
  1182. ShowViewChargingSoc(LEFT_GUN_NUM, 66 + i / 20);
  1183. ShowViewChargingTime(LEFT_GUN_NUM, i);
  1184. ShowViewCharingMoney(LEFT_GUN_NUM, i);
  1185. ShowViewChargingPower(LEFT_GUN_NUM, (float)(66 + i*0.1));
  1186. ShowViewChargingEngery(LEFT_GUN_NUM, 50 + i / 30);
  1187. ShowViewChargingSoc(RIGHT_GUN_NUM, 88 + i / 25);
  1188. ShowViewChargingTime(RIGHT_GUN_NUM, i);
  1189. ShowViewCharingMoney(RIGHT_GUN_NUM, i);
  1190. ShowViewChargingPower(RIGHT_GUN_NUM, (float)(88 + i *0.1));
  1191. ShowViewChargingEngery(RIGHT_GUN_NUM, 30 + i / 30);
  1192. usleep(100000);
  1193. }
  1194. break;
  1195. case 7:
  1196. case 9:
  1197. case 23:
  1198. case 24:
  1199. break;
  1200. case 11:
  1201. for(i = 0 ; i <= 100 ; i++) {
  1202. // RefreshProgressAnimation(_ICON_ProgressBar_10+((i/10)*2));
  1203. uint8_t digits = i % 10;
  1204. uint8_t tens = (i / 10) %10;
  1205. uint8_t hundreds = i / 100;
  1206. ChangeDisplay2Value(_Percent_Number_Digits,(short)_ICON_White_Num_0+digits);
  1207. ChangeDisplay2Value(_Percent_Number_Tens,(short)_ICON_White_Num_0+tens);
  1208. if (hundreds == 0 )
  1209. ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_Empty);
  1210. else
  1211. ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_White_Num_1);
  1212. sprintf((char *)value,"%03d",i);
  1213. DisplayValueToLcm(_Detail_Power_Num, (uint8_t *)value, sizeof(value));
  1214. DisplayValueToLcm(_Detail_Time_Num, (uint8_t *)value, sizeof(value));
  1215. DisplayValueToLcm(_Detail_Cap_Num, (uint8_t *)value, sizeof(value));
  1216. DisplayValueToLcm(_Detail_Money_Num, (uint8_t *)value, sizeof(value));
  1217. if (i%2 == 0 ) {
  1218. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
  1219. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
  1220. memset(value, 0x00, sizeof(value));
  1221. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  1222. sprintf((char *)value,"1 A");
  1223. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  1224. } else {
  1225. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
  1226. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
  1227. memset(value, 0x00, sizeof(value));
  1228. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  1229. sprintf((char *)value,"1 B");
  1230. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  1231. }
  1232. usleep(100000);
  1233. }
  1234. break;
  1235. case 12:
  1236. case 13:
  1237. case 15:
  1238. case 17:
  1239. case 28:
  1240. ftime(&SeqEndTime);
  1241. SeqEndTime.time = time(NULL);
  1242. tm = localtime(&SeqEndTime.time);
  1243. memset(value, 0x00, sizeof(value));
  1244. sprintf((char *)value,"%02d:%02d",tm->tm_hour,tm->tm_min);
  1245. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  1246. if (pSysInfo->PageIndex == 17 || pSysInfo->PageIndex == 28) {
  1247. for (i = 0; i <= 9999; i++) {
  1248. strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, "2022-05-15 16:42:11");
  1249. strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, "2022-05-15 16:47:44");
  1250. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_hr);
  1251. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_min);
  1252. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_sec);
  1253. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_hr);
  1254. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_min);
  1255. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_sec);
  1256. t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
  1257. if (t_hr >= 24)
  1258. t_hr -= 24;
  1259. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime) == 0) {
  1260. ShowChargeTime(_Summary_Start_time_hr, 0);
  1261. ShowChargeTime(_Summary_Start_time_min, 0);
  1262. ShowChargeTime(_Summary_Start_time_sec, 0);
  1263. } else {
  1264. ShowChargeTime(_Summary_Start_time_hr, t_hr);
  1265. ShowChargeTime(_Summary_Start_time_min, atoi(start_min));
  1266. ShowChargeTime(_Summary_Start_time_sec, atoi(start_sec));
  1267. }
  1268. t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
  1269. if (t_hr >= 24)
  1270. t_hr -= 24;
  1271. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime) == 0) {
  1272. ShowChargeTime(_Summary_end_time_hr, 0);
  1273. ShowChargeTime(_Summary_end_time_min, 0);
  1274. ShowChargeTime(_Summary_end_time_sec, 0);
  1275. } else {
  1276. ShowChargeTime(_Summary_end_time_hr, t_hr);
  1277. ShowChargeTime(_Summary_end_time_min, atoi(end_min));
  1278. ShowChargeTime(_Summary_end_time_sec, atoi(end_sec));
  1279. }
  1280. ChangeDisplay2Value(_Summary_cal_discount,88);
  1281. ChangeDisplay2Value(_Summary_max_power, 888);
  1282. ChangeDisplay2Value(_Summary_average_power, 888);
  1283. if (i < 100) {
  1284. ShowSummaryMoneyDash(_Summary_total_money);
  1285. ShowSummaryMoneyDash(_Summary_cal_Total_money);
  1286. ShowSummaryMoneyDash(_Summary_cal_discount);
  1287. } else {
  1288. ShowSummaryMoney(_Summary_total_money, i);
  1289. ShowSummaryMoney(_Summary_cal_Total_money, i);
  1290. ShowSummaryMoney(_Summary_cal_discount, i);
  1291. }
  1292. usleep(100000);
  1293. }
  1294. }
  1295. break;
  1296. case __START_AUTHORIZE_:
  1297. case __PRE_CHARGE_:
  1298. case __STOP_AUTHORIZE_:
  1299. for( i = 0 ; i <= 20 ; i++) {
  1300. //RefreshProgressAnimation(_ICON_ProgressBar_10);
  1301. usleep(100000);
  1302. }
  1303. for( i = 0 ; i <= 20 ; i++) {
  1304. //RefreshProgressAnimation(_ICON_ProgressBar_20);
  1305. usleep(100000);
  1306. }
  1307. break;
  1308. case 29:
  1309. break;
  1310. case 5:
  1311. pSysInfo->CurGunSelected = 0;
  1312. ChangeQrCode();
  1313. sleep(5);
  1314. break;
  1315. case 31:
  1316. pSysInfo->CurGunSelected = 1;
  1317. ChangeQrCode();
  1318. sleep(5);
  1319. break;
  1320. case 8:
  1321. case 16:
  1322. case 18:
  1323. case 19:
  1324. case 25:
  1325. case 26:
  1326. case 27:
  1327. case 30:
  1328. case 32:
  1329. case 33:
  1330. case 34:
  1331. sleep(5);
  1332. break;
  1333. }
  1334. }
  1335. void ShowCabientVersionDefaultText()
  1336. {
  1337. char value[16];
  1338. memset(value, 0x00, sizeof(value));
  1339. sprintf((char *)value,"%s","Cabient:");
  1340. DisplayValueToLcm(_Version_Cabient_Name_Text, (uint8_t *)value, sizeof(value));
  1341. sprintf((char *)value,"%s","BootLoader:");
  1342. DisplayValueToLcm(_Version_Cabient_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1343. sprintf((char *)value,"%s","Kernel Fw:");
  1344. DisplayValueToLcm(_Version_Cabient_Kernel_Text, (uint8_t *)value, sizeof(value));
  1345. sprintf((char *)value,"%s","CSU Fw:");
  1346. DisplayValueToLcm(_Version_Cabient_CSU_Text, (uint8_t *)value, sizeof(value));
  1347. sprintf((char *)value,"%s","Priamry Fw:");
  1348. DisplayValueToLcm(_Version_Cabient_Priamry_Text, (uint8_t *)value, sizeof(value));
  1349. sprintf((char *)value,"%s","Relay(0) Fw:");
  1350. DisplayValueToLcm(_Version_Cabient_Relay0_Text, (uint8_t *)value, sizeof(value));
  1351. sprintf((char *)value,"%s","Relay(1) Fw:");
  1352. DisplayValueToLcm(_Version_Cabient_Relay1_Text, (uint8_t *)value, sizeof(value));
  1353. sprintf((char *)value,"%s","Fan Fw:");
  1354. DisplayValueToLcm(_Version_Cabient_Fan_Text, (uint8_t *)value, sizeof(value));
  1355. sprintf((char *)value,"%s","IP Addr:");
  1356. DisplayValueToLcm(_Version_Cabient_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1357. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number <= 12) {
  1358. sprintf((char *)value,"%s","Primary");
  1359. DisplayValueToLcm(_Version_Cabient_Primary_Text, (uint8_t *)value, sizeof(value));
  1360. sprintf((char *)value,"%s","Secondary");
  1361. DisplayValueToLcm(_Version_Cabient_Secondary_Text, (uint8_t *)value, sizeof(value));
  1362. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1363. sprintf((char *)value,"PSU(%d):",i+1);
  1364. DisplayValueToLcm(_Version_Cabient_PSU1_Text+i*0x10, (uint8_t *)value, sizeof(value));
  1365. }
  1366. }
  1367. }
  1368. void ShowDispenserVersionDefautlText()
  1369. {
  1370. char value[16];
  1371. memset(value, 0x00, sizeof(value));
  1372. sprintf((char *)value,"%s","Dispenser:");
  1373. DisplayValueToLcm(_Version_Dispenser_Name_Text, (uint8_t *)value, sizeof(value));
  1374. sprintf((char *)value,"%s","BootLoader:");
  1375. DisplayValueToLcm(_Version_Dispenser_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1376. sprintf((char *)value,"%s","Kernel Fw:");
  1377. DisplayValueToLcm(_Version_Dispenser_Kernel_Text, (uint8_t *)value, sizeof(value));
  1378. sprintf((char *)value,"%s","CSU Fw:");
  1379. DisplayValueToLcm(_Version_Dispenser_CSU_Text, (uint8_t *)value, sizeof(value));
  1380. sprintf((char *)value,"%s","Relay Fw:");
  1381. DisplayValueToLcm(_Version_Dispenser_Relay_Text, (uint8_t *)value, sizeof(value));
  1382. sprintf((char *)value,"%s","Fan Fw:");
  1383. DisplayValueToLcm(_Version_Dispenser_Fan_Text, (uint8_t *)value, sizeof(value));
  1384. sprintf((char *)value,"%s","Prim Fw:");
  1385. DisplayValueToLcm(_Version_Dispenser_Priamry_Text, (uint8_t *)value, sizeof(value));
  1386. sprintf((char *)value,"%s","LCM Hw:");
  1387. DisplayValueToLcm(_Version_Dispenser_LCM_Text, (uint8_t *)value, sizeof(value));
  1388. sprintf((char *)value,"%s","LED Fw:");
  1389. DisplayValueToLcm(_Version_Dispenser_LED_Text, (uint8_t *)value, sizeof(value));
  1390. sprintf((char *)value,"%s","Connector(0):");
  1391. DisplayValueToLcm(_Version_Dispenser_Connector0_Text, (uint8_t *)value, sizeof(value));
  1392. sprintf((char *)value,"%s","Connector(1):");
  1393. DisplayValueToLcm(_Version_Dispenser_Connector1_Text, (uint8_t *)value, sizeof(value));
  1394. sprintf((char *)value,"%s","IP Addr:");
  1395. DisplayValueToLcm(_Version_Dispenser_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1396. }
  1397. void ShowCabientVersion()
  1398. {
  1399. char value[16];
  1400. memset(value, 0x00, sizeof(value));
  1401. sprintf((char *)value,"%s",ShmDcCommonData->CabinetModelName);
  1402. DisplayValueToLcm(_Version_Cabient_Model_value, (uint8_t *)value, sizeof(value));
  1403. sprintf((char *)value,"%s",ShmDcCommonData->CabinetBoolLoaderVersion);
  1404. DisplayValueToLcm(_Version_Cabient_BootLoader_value, (uint8_t *)value, sizeof(value));
  1405. sprintf((char *)value,"%s",ShmDcCommonData->CabinetKernelVersion);
  1406. DisplayValueToLcm(_Version_Cabient_Kernel_value, (uint8_t *)value, sizeof(value));
  1407. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRFSystemVersion);
  1408. DisplayValueToLcm(_Version_Cabient_CSU_value, (uint8_t *)value, sizeof(value));
  1409. sprintf((char *)value,"%s",ShmDcCommonData->CabinetPrimaryVersion);
  1410. DisplayValueToLcm(_Version_Cabient_Priamry_value, (uint8_t *)value, sizeof(value));
  1411. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay0Version);
  1412. DisplayValueToLcm(_Version_Cabient_Relay0_value, (uint8_t *)value, sizeof(value));
  1413. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay1Version);
  1414. DisplayValueToLcm(_Version_Cabient_Relay1_value, (uint8_t *)value, sizeof(value));
  1415. sprintf((char *)value,"%s",ShmDcCommonData->CabinetFanVersion);
  1416. DisplayValueToLcm(_Version_Cabient_Fan_value, (uint8_t *)value, sizeof(value));
  1417. sprintf((char *)value,"%s",ShmDcCommonData->CabinetIPAddr);
  1418. DisplayValueToLcm(_Version_Cabient_IPAddr_value, (uint8_t *)value, sizeof(value));
  1419. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number < 12) {
  1420. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1421. if (i>=6) {
  1422. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].DCVersion);
  1423. DisplayValueToLcm(_Version_Cabient_PSU_Prim7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1424. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].FPCVersion);
  1425. DisplayValueToLcm(_Version_Cabient_PSU_Sec7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1426. continue;
  1427. }
  1428. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].DCVersion);
  1429. DisplayValueToLcm(_Version_Cabient_PSU_Prim1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1430. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].FPCVersion);
  1431. DisplayValueToLcm(_Version_Cabient_PSU_Sec1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1432. }
  1433. }
  1434. }
  1435. void ShowDispenserVersion()
  1436. {
  1437. char value[32];
  1438. memset(value, 0x00, sizeof(value));
  1439. sprintf((char *)value,"%s",pSysConfig->ModelName);
  1440. DisplayValueToLcm(_Version_Dispenser_Model_value, (uint8_t *)value, sizeof(value));
  1441. sprintf((char *)value,"%s",pSysInfo->CsuBootLoadFwRev);
  1442. DisplayValueToLcm(_Version_Dispenser_BootLoader_value, (uint8_t *)value, sizeof(value));
  1443. sprintf((char *)value,"%s",pSysInfo->CsuKernelFwRev);
  1444. DisplayValueToLcm(_Version_Dispenser_Kernel_value, (uint8_t *)value, sizeof(value));
  1445. sprintf((char *)value,"%s",pSysInfo->CsuRootFsFwRev);
  1446. DisplayValueToLcm(_Version_Dispenser_CSU_value, (uint8_t *)value, sizeof(value));
  1447. sprintf((char *)value,"%s",pSysInfo->RelayModuleFwRev);
  1448. DisplayValueToLcm(_Version_Dispenser_Relay_value, (uint8_t *)value, sizeof(value));
  1449. sprintf((char *)value,"%s",pSysInfo->FanModuleFwRev);
  1450. DisplayValueToLcm(_Version_Dispenser_Fan_value, (uint8_t *)value, sizeof(value));
  1451. sprintf((char *)value,"%s",pSysInfo->CsuPrimFwRev);
  1452. DisplayValueToLcm(_Version_Dispenser_Priamry_value, (uint8_t *)value, sizeof(value));
  1453. sprintf((char *)value,"%s",pSysInfo->LcmHwRev);
  1454. DisplayValueToLcm(_Version_Dispenser_LCM_value, (uint8_t *)value, sizeof(value));
  1455. sprintf((char *)value,"%s",pSysInfo->LedModuleFwRev);
  1456. DisplayValueToLcm(_Version_Dispenser_LED_value, (uint8_t *)value, sizeof(value));
  1457. sprintf((char *)value,"%s",pSysInfo->Connector1FwRev);
  1458. DisplayValueToLcm(_Version_Dispenser_Connector0_value, (uint8_t *)value, sizeof(value));
  1459. sprintf((char *)value,"%s",pSysInfo->Connector2FwRev);
  1460. DisplayValueToLcm(_Version_Dispenser_Connector1_value, (uint8_t *)value, sizeof(value));
  1461. sprintf((char *)value,"%s",pSysConfig->Eth0Interface.EthIpAddress);
  1462. DisplayValueToLcm(_Version_Dispenser_IPAddr_value, (uint8_t *)value, sizeof(value));
  1463. }
  1464. void InformationShow()
  1465. {
  1466. is_show = true;
  1467. if (_showInformIndex == 0 ) {
  1468. pSysInfo->PageIndex = __SHOW_CABIENT_VERSION;
  1469. } else {
  1470. pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION;
  1471. ShowDispenserVersion();
  1472. }
  1473. }
  1474. void ChangeWarningFunc()
  1475. {
  1476. uint8_t cmd[7] = { 0 };
  1477. uint8_t i = 0;
  1478. //uint8_t j = 0;
  1479. //log_info("ChangeWarningFunc ");
  1480. // 最多一次五筆
  1481. //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
  1482. //log_info("WarningCount = %d ", pSysWarning->WarningCount);
  1483. //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  1484. for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
  1485. //log_info("Warming Code[%d]:%s", i, &pSysWarning->WarningCode[i][0]);
  1486. memset(cmd, 0x00, sizeof(cmd));
  1487. if ((i) >= 5) {
  1488. break;
  1489. }
  1490. //error code
  1491. string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
  1492. DisplayValueToLcm(_Text_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1493. //警告標示
  1494. memset(cmd, 0x00, sizeof(cmd));
  1495. cmd[0] = 0x00;
  1496. cmd[1] = 1;
  1497. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1498. }
  1499. memset(cmd, 0x00, sizeof(cmd));
  1500. for (; i < 5; i++) {
  1501. DisplayValueToLcm(_Text_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1502. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1503. }
  1504. }
  1505. void GetDeviceInfoStatus(short address, uint8_t len)
  1506. {
  1507. uint8_t cmd[8];
  1508. memset(cmd, 0x00, sizeof(cmd));
  1509. uint8_t msg[11];
  1510. memset(msg, 0x00, sizeof(msg));
  1511. cmd[0] = CMD_TITLE_1;
  1512. cmd[1] = CMD_TITLE_2;
  1513. cmd[2] = 0x04;
  1514. cmd[3] = CMD_MULTI_READ;
  1515. cmd[4] = (address >> 8) & 0xff;
  1516. cmd[5] = (address >> 0) & 0xff;
  1517. cmd[6] = len;
  1518. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  1519. usleep(5000);
  1520. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  1521. }
  1522. int main(void)
  1523. {
  1524. if (CreateAllCsuShareMemory() == FAIL) {
  1525. log_error("create share memory error");
  1526. return FAIL;
  1527. }
  1528. MappingGunChargingInfo("LCM Control Task");
  1529. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  1530. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  1531. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  1532. ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
  1533. ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  1534. ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  1535. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  1536. struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
  1537. struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  1538. struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1539. _port = CreateCommunicationLcmPort();
  1540. ChangeBackLight(true);
  1541. _totalCount = pSysConfig->TotalConnectorCount;
  1542. _everyPageRollChange = 0;
  1543. uint8_t curWarningCount = 255;
  1544. uint8_t changeWarningPriority = 0;
  1545. //Initialization();
  1546. //printf("_LCM_COMPLETE ");
  1547. //ChangeToOtherPage(_LCM_COMPLETE);
  1548. //return 0;
  1549. uint8_t index = 35;
  1550. ShmDcCommonData->PSU_Number = 12;
  1551. uint8_t _verShowCount = 5;
  1552. while (_port != -1) {
  1553. if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
  1554. GetDeviceInfoStatus(_LCM_VERSION, 3);
  1555. GetCurrentPage();
  1556. sleep(1);
  1557. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1558. if (_verShowCount > 0) {
  1559. log_info("LCM Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
  1560. _verShowCount--;
  1561. }
  1562. } else {
  1563. // Show Default Text
  1564. /*
  1565. if (!defaulttext) {
  1566. ShowCabientVersionDefaultText();
  1567. ShowDispenserVersionDefautlText();
  1568. defaulttext = true;
  1569. }
  1570. */
  1571. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
  1572. if(pSysConfig->TotalConnectorCount>=2) {
  1573. if (pDcChargingInfo_0->SystemStatus == S_IDLE) {
  1574. ChargeMaxPower_0 = 0;
  1575. } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING) {
  1576. if (pDcChargingInfo_0->PresentChargingPower > ChargeMaxPower_0 &&
  1577. pDcChargingInfo_0->PresentChargingPower >= 0 &&
  1578. pDcChargingInfo_0->PresentChargingPower <= POWER_MAX_KW)
  1579. ChargeMaxPower_0 = pDcChargingInfo_0->PresentChargingPower;
  1580. }
  1581. if (pDcChargingInfo_1->SystemStatus == S_IDLE) {
  1582. ChargeMaxPower_1 = 0;
  1583. } else if (pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  1584. if (pDcChargingInfo_1->PresentChargingPower > ChargeMaxPower_1 &&
  1585. pDcChargingInfo_1->PresentChargingPower >= 0 &&
  1586. pDcChargingInfo_1->PresentChargingPower <= POWER_MAX_KW)
  1587. ChargeMaxPower_1 = pDcChargingInfo_1->PresentChargingPower;
  1588. }
  1589. }
  1590. // Warming處理
  1591. if (curWarningCount != pSysWarning->WarningCount) {
  1592. changeWarningPriority = 0;
  1593. pSysWarning->PageIndex = 0;
  1594. curWarningCount = pSysWarning->WarningCount;
  1595. ChangeWarningFunc();
  1596. } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
  1597. // 當有兩頁 Warning 則每隔三秒改變一次
  1598. if (pSysWarning->PageIndex == 0) {
  1599. pSysWarning->PageIndex = 1;
  1600. } else {
  1601. pSysWarning->PageIndex = 0;
  1602. }
  1603. ChangeWarningFunc();
  1604. }
  1605. // 頁面資訊處理
  1606. ///*
  1607. ProcessPageInfo();
  1608. // 換頁處理
  1609. GetCurrentPage(); //DS60-120 add
  1610. ChangeCurPage();
  1611. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1612. //*/
  1613. /*
  1614. if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _LCM_VIEW) {
  1615. InformationShow();
  1616. ChangeToOtherPage(pSysInfo->PageIndex);
  1617. usleep(100000);
  1618. continue;
  1619. } else {
  1620. if (is_show)
  1621. _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
  1622. is_show = false;
  1623. }
  1624. */
  1625. /*
  1626. pSysInfo->PageIndex = DemoPage[ShmDcCommonData->DemoCount];
  1627. GetCurrentPage();
  1628. ChangeToOtherPage(DemoPage[ShmDcCommonData->DemoCount]);
  1629. GetCurrentPage();
  1630. DemoFunction();
  1631. ShmDcCommonData->DemoCount >= 1 ? ShmDcCommonData->DemoCount = 0 : ShmDcCommonData->DemoCount++;
  1632. //*/
  1633. usleep(100000);
  1634. }
  1635. } //while
  1636. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1637. log_info("Close LCM Uart Port");
  1638. CloseCommunicationLcmPort();
  1639. return FAIL;
  1640. }