Module_LcmControl.c 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  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. }
  565. else
  566. ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Red_Num_1);
  567. } else {
  568. ChangeDisplay2Value(_RightGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
  569. if (hundreds == 0 ) {
  570. ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Empty);
  571. if (tens == 0)
  572. ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Empty);
  573. else
  574. ChangeDisplay2Value(_RightGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
  575. }
  576. else
  577. ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Red_Num_1);
  578. }
  579. }
  580. void ShowViewChargingTime(uint8_t gunIndex,int time)
  581. {
  582. int min,sec;
  583. int ShowTime;
  584. min = time/60;
  585. sec = time % 60;
  586. ShowTime = min * 100 + sec;
  587. //sprintf((char *)value,"%d:%02d",min,sec);
  588. if (gunIndex == LEFT_GUN_NUM) {
  589. ChangeDisplay2Value(_LeftGun_info_time, (short)ShowTime);
  590. } else {
  591. ChangeDisplay2Value(_RightGun_info_time, (short)ShowTime);
  592. }
  593. }
  594. void ShowViewChargingEngery(uint8_t gunIndex, float energy)
  595. {
  596. float data = energy * 10;
  597. if (energy < 0)
  598. data = fabs(energy);
  599. if (gunIndex == LEFT_GUN_NUM) {
  600. ChangeDisplay2Value(_LeftGun_info_cap, data);
  601. } else
  602. ChangeDisplay2Value(_RightGun_info_cap, data);
  603. /*
  604. if(energy < 100)
  605. sprintf((char*)value, "%.1f", energy);
  606. else
  607. sprintf((char*)value, "%d", (int)energy);
  608. //log_info("gun[%d] energy:%.1f", gunIndex, energy);
  609. if (gunIndex == LEFT_GUN_NUM) {
  610. DisplayValueToLcm(_LeftGun_info_cap, (uint8_t*)value, sizeof(value));
  611. }
  612. else
  613. DisplayValueToLcm(_RightGun_info_cap, (uint8_t*)value, sizeof(value));
  614. */
  615. }
  616. void ShowViewCharingMoney(uint8_t gunIndex,float money)
  617. {
  618. float data = money;
  619. if (money < 0)
  620. data = fabs(money);
  621. if (gunIndex == LEFT_GUN_NUM) {
  622. ChangeDisplay2Value(_LeftGun_info_money, data);
  623. } else
  624. ChangeDisplay2Value(_RightGun_info_money, data);
  625. /*
  626. uint8_t value[10] = {0};
  627. sprintf((char *)value,"%d",(int)money);
  628. //log_info("gun[%d] money:%.1f", gunIndex, money);
  629. if (gunIndex == LEFT_GUN_NUM) {
  630. DisplayValueToLcm(_LeftGun_info_money, (uint8_t *)value, sizeof(value));
  631. } else
  632. DisplayValueToLcm(_RightGun_info_money, (uint8_t *)value, sizeof(value));
  633. */
  634. }
  635. void ShowViewChargingPower(uint8_t gunIndex,float power)
  636. {
  637. uint8_t value[10] = {0};
  638. float _data = power * 10;
  639. sprintf((char *)value,"%.1f",power);
  640. //log_info("gun[%d] power:%.1f",gunIndex,power);
  641. if (power >= 0 && power <= POWER_MAX_KW) {
  642. if (gunIndex == LEFT_GUN_NUM) {
  643. ChangeDisplay2Value(_LeftGun_info_power_number, _data);
  644. //DisplayValueToLcm(_LeftGun_info_power_number, (uint8_t *)value, sizeof(value));
  645. } else {
  646. //DisplayValueToLcm(_RightGun_info_power_number, (uint8_t*)value, sizeof(value));
  647. ChangeDisplay2Value(_RightGun_info_power_number, _data);
  648. }
  649. }
  650. }
  651. void ShowConnectId()
  652. {
  653. int id = atoi(pSysConfig->SystemId);
  654. if (id == 0)
  655. id = 1;
  656. ChangeDisplay2Value(_Text_SystemID, id);
  657. if (ShmDcCommonData->ConnectorId[0] <= 2) {
  658. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
  659. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
  660. } else {
  661. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_C);
  662. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_D);
  663. }
  664. }
  665. void ShowViewLeftGunInfo()
  666. {
  667. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  668. if (pDcChargingInfo->SystemStatus == S_IDLE ) {
  669. switch (pDcChargingInfo->CCSGunType) {
  670. case _TYPE_CCS1_Liquid:
  671. case _TYPE_CCS1_Natural:
  672. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS1_GUN_U);
  673. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS1_GUN_L);
  674. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS1_Name);
  675. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  676. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  677. } else {
  678. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  679. }
  680. break;
  681. case _TYPE_CCS2_Liquid:
  682. case _TYPE_CCS2_Natural:
  683. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS2_GUN_U);
  684. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS2_GUN_L);
  685. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS2_Name);
  686. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  687. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  688. } else {
  689. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  690. }
  691. break;
  692. default:
  693. log_error("CCS Gun Type Error! Not Show in LCM!!");
  694. }
  695. } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
  696. ShowViewChargingSoc(LEFT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
  697. if (strlen(ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeStartTime) > 1) {
  698. int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeStartTime,
  699. ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeDuration);
  700. ShowViewChargingTime(LEFT_GUN_NUM, duration);
  701. } else {
  702. ShowViewChargingTime(LEFT_GUN_NUM, 0);
  703. }
  704. ShowViewCharingMoney(LEFT_GUN_NUM,pDcChargingInfo->ChargingFee);
  705. ShowViewChargingPower(LEFT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
  706. ShowViewChargingEngery(LEFT_GUN_NUM, pDcChargingInfo->PresentChargedEnergy);
  707. switch (pDcChargingInfo->CCSGunType) {
  708. case _TYPE_CCS1_Liquid:
  709. case _TYPE_CCS1_Natural:
  710. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS1_Name);
  711. break;
  712. case _TYPE_CCS2_Liquid:
  713. case _TYPE_CCS2_Natural:
  714. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS2_Name);
  715. break;
  716. }
  717. }
  718. }
  719. void ShowViewRightGunInfo()
  720. {
  721. char value[5];
  722. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  723. if (pDcChargingInfo->SystemStatus == S_IDLE ) {
  724. switch (pDcChargingInfo->CCSGunType) {
  725. case _TYPE_CCS1_Liquid:
  726. case _TYPE_CCS1_Natural:
  727. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS1_GUN_U);
  728. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS1_GUN_L);
  729. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS1_Name);
  730. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  731. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  732. } else {
  733. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  734. }
  735. break;
  736. case _TYPE_CCS2_Liquid:
  737. case _TYPE_CCS2_Natural:
  738. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS2_GUN_U);
  739. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS2_GUN_L);
  740. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS2_Name);
  741. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  742. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  743. } else {
  744. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  745. }
  746. break;
  747. default:
  748. log_error("CCS Gun Type Error! Not Show in LCM!!");
  749. }
  750. memset(value, 0x00, sizeof(value));
  751. sprintf((char *)value,"1 B");
  752. DisplayValueToLcm(_RightGun_location, (uint8_t *)value, sizeof(value));
  753. } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
  754. ShowViewChargingSoc(RIGHT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
  755. if (strlen(ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeStartTime) > 1) {
  756. int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeStartTime,
  757. ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeDuration);
  758. ShowViewChargingTime(RIGHT_GUN_NUM, duration);
  759. } else {
  760. ShowViewChargingTime(RIGHT_GUN_NUM, 0);
  761. }
  762. ShowViewCharingMoney(RIGHT_GUN_NUM,pDcChargingInfo->ChargingFee);
  763. ShowViewChargingPower(RIGHT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
  764. ShowViewChargingEngery(RIGHT_GUN_NUM, pDcChargingInfo->PresentChargedEnergy);
  765. switch (pDcChargingInfo->CCSGunType) {
  766. case _TYPE_CCS1_Liquid:
  767. case _TYPE_CCS1_Natural:
  768. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS1_Name);
  769. break;
  770. case _TYPE_CCS2_Liquid:
  771. case _TYPE_CCS2_Natural:
  772. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS2_Name);
  773. break;
  774. }
  775. }
  776. }
  777. void SetViewPage()
  778. {
  779. // Set Background pic.
  780. if (pSysConfig->TotalConnectorCount == 1) {
  781. } else if (pSysConfig->TotalConnectorCount == 2) {
  782. ShowConnectId();
  783. ShowViewLeftGunInfo();
  784. ShowViewRightGunInfo();
  785. }
  786. }
  787. void ShowSelectGunIcon()
  788. {
  789. uint8_t value[5] = {0};
  790. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  791. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  792. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  793. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  794. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
  795. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  796. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  797. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS2_Symbol);
  798. }
  799. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
  800. sprintf((char *)value,"%s",LEFT_GUN_LOCAL_NAME);
  801. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  802. memset(value, 0x00, sizeof(value));
  803. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  804. } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
  805. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  806. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  807. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS1_Symbol);
  808. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  809. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  810. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
  811. }
  812. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
  813. sprintf((char *)value,"%s",RIGHT_GUN_LOCAL_NAME);
  814. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  815. memset(value, 0x00, sizeof(value));
  816. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  817. }
  818. }
  819. void ShowCountDownTimer()
  820. {
  821. int min,sec;
  822. uint8_t value[10] = {0};
  823. int tm = 120 - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
  824. // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
  825. min = tm/60;
  826. sec = tm%60;
  827. sprintf((char *)value,"%02d:%02d",min,sec);
  828. if (pSysInfo->SystemPage == _LCM_SUMMARY) {
  829. sprintf((char*)value, "");
  830. DisplayValueToLcm(_Count_Down_Time, (uint8_t*)value, sizeof(value));
  831. }
  832. else
  833. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  834. }
  835. unsigned long GetTimeoutValue(struct timeval _sour_time)
  836. {
  837. struct timeval _end_time;
  838. gettimeofday(&_end_time, NULL);
  839. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  840. }
  841. void ShowGunCountDownTimer()
  842. {
  843. int min,sec;
  844. uint8_t value[10] = {0};
  845. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  846. int tm = 30 - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL);
  847. // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
  848. min = tm/60;
  849. sec = tm%60;
  850. sprintf((char *)value,"%02d:%02d",min,sec);
  851. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  852. }
  853. void ClearQrCode()
  854. {
  855. char cmd[200];
  856. memset(cmd, 0, 200);
  857. DisplayValueToLcm(_QR_CODE_AUTHORIZE, (uint8_t *)cmd, 200);
  858. }
  859. void ChangeQrCode()
  860. {
  861. char cmd[200];
  862. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  863. memset(cmd, 0 , 200);
  864. int len = sprintf(cmd, "https://qrcode.u-power.app/connector?chargebox=%s&connectorno=%d", ShmDcCommonData->QRCodeString, ShmDcCommonData->ConnectorId[pSysInfo->CurGunSelected]);
  865. //int len = sprintf(cmd, "http://www.u-power.com.tw/");
  866. if (len > 200) {
  867. log_info("QR Code URL length too long");
  868. }
  869. DisplayValueToLcm(_QR_CODE_AUTHORIZE, cmd, 200);
  870. }
  871. void ShowProgressBar()
  872. {
  873. /*
  874. for(int i = 0 ; i <= 19 ; i++) {
  875. ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+i);
  876. usleep(100000);
  877. }*/
  878. }
  879. void ShowChargeTime(int addr,int _time)
  880. {
  881. int tens, digits;
  882. tens = _time / 10;
  883. digits = _time % 10;
  884. ChangeDisplay2Value(addr, tens);
  885. ChangeDisplay2Value(addr+2, digits);
  886. }
  887. void ShowSummaryMoney(int addr, int money)
  888. {
  889. int dig, tens, hund, thou,shift;
  890. if (addr == _Summary_total_money) {
  891. shift = 42;
  892. } else {
  893. shift = 100;
  894. }
  895. if (money > 9999) {
  896. money = 9999;
  897. }
  898. thou = money / 1000;
  899. hund = (money / 100) % 10;
  900. tens = (money / 10) % 10;
  901. dig = money % 10;
  902. ChangeDisplay2Value(addr + 6, thou == 0 ? _ICON_Empty : thou+shift);
  903. if (thou == 0) {
  904. ChangeDisplay2Value(addr + 4, hund == 0 ? _ICON_Empty : hund + shift);
  905. if (addr == _Summary_cal_discount)
  906. ChangeDisplay2Value(addr + 8, _ICON_Empty);
  907. if (hund == 0) {
  908. ChangeDisplay2Value(addr + 2, tens == 0 ? _ICON_Empty : tens + shift);
  909. } else {
  910. ChangeDisplay2Value(addr + 2, tens + shift);
  911. }
  912. } else {
  913. ChangeDisplay2Value(addr + 4, hund + shift);
  914. ChangeDisplay2Value(addr + 2, tens + shift);
  915. }
  916. ChangeDisplay2Value(addr, dig + shift);
  917. // 給UPOINT負號
  918. if (addr == _Summary_cal_discount) {
  919. if (thou == 0) {
  920. if (hund == 0) {
  921. if (tens == 0) {
  922. ChangeDisplay2Value(addr + 2, _ICON_negative);
  923. } else {
  924. ChangeDisplay2Value(addr + 4, _ICON_negative);
  925. }
  926. } else {
  927. ChangeDisplay2Value(addr + 6, _ICON_negative);
  928. }
  929. } else {
  930. ChangeDisplay2Value(addr + 8, _ICON_negative);
  931. }
  932. }
  933. }
  934. void ShowSummaryMoneyDash(int addr)
  935. {
  936. if (addr == _Summary_total_money) {
  937. ChangeDisplay2Value(addr , _ICON_DASH_SINGLE);
  938. ChangeDisplay2Value(addr + 2, _ICON_DASH_SINGLE);
  939. ChangeDisplay2Value(addr + 4, _ICON_Empty);
  940. ChangeDisplay2Value(addr + 6, _ICON_Empty);
  941. } else {
  942. ChangeDisplay2Value(addr, _ICON_DASH_SINGLE);
  943. ChangeDisplay2Value(addr + 2, _ICON_DASH_SINGLE);
  944. ChangeDisplay2Value(addr + 4, _ICON_Empty);
  945. ChangeDisplay2Value(addr + 6, _ICON_Empty);
  946. ChangeDisplay2Value(addr + 8, _ICON_Empty);
  947. }
  948. }
  949. void ShowSummaryPage()
  950. {
  951. float data;
  952. char start_hr[3],start_min[3],start_sec[3],end_hr[3],end_min[3],end_sec[3];
  953. int t_hr;
  954. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  955. // Show Money
  956. if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].finalcost_flag) {
  957. ShowSummaryMoney(_Summary_total_money, (int)ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].RemainAmount);
  958. ShowSummaryMoney(_Summary_cal_Total_money, (int)pDcChargingInfo->ChargingFee);
  959. ShowSummaryMoney(_Summary_cal_discount, (int)ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Discount);
  960. } else {
  961. // 未收到Final cost
  962. ShowSummaryMoneyDash(_Summary_total_money);
  963. ShowSummaryMoneyDash(_Summary_cal_Total_money);
  964. ShowSummaryMoneyDash(_Summary_cal_discount);
  965. }
  966. /*
  967. log_info("start time:%s",pDcChargingInfo->StartDateTime);
  968. log_info("stop time:%s",pDcChargingInfo->StopDateTime);*/
  969. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_hr);
  970. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime,start_min);
  971. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_sec);
  972. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime,end_hr);
  973. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime,end_min);
  974. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_sec);
  975. t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
  976. if (t_hr >= 24)
  977. t_hr -= 24;
  978. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime) == 0) {
  979. ShowChargeTime(_Summary_Start_time_hr,0);
  980. ShowChargeTime(_Summary_Start_time_min, 0);
  981. ShowChargeTime(_Summary_Start_time_sec, 0);
  982. } else {
  983. ShowChargeTime(_Summary_Start_time_hr, t_hr);
  984. ShowChargeTime(_Summary_Start_time_min, atoi(start_min));
  985. ShowChargeTime(_Summary_Start_time_sec, atoi(start_sec));
  986. }
  987. t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
  988. if (t_hr >= 24)
  989. t_hr -= 24;
  990. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime) == 0) {
  991. ShowChargeTime(_Summary_end_time_hr, 0);
  992. ShowChargeTime(_Summary_end_time_min, 0);
  993. ShowChargeTime(_Summary_end_time_sec, 0);
  994. } else {
  995. ShowChargeTime(_Summary_end_time_hr, t_hr);
  996. ShowChargeTime(_Summary_end_time_min, atoi(end_min));
  997. ShowChargeTime(_Summary_end_time_sec, atoi(end_sec));
  998. }
  999. /*
  1000. DisplayValueToLcm(_Summary_Start_time_hr, (uint8_t *)start_hr, sizeof(start_hr));
  1001. DisplayValueToLcm(_Summary_Start_time_min, (uint8_t *)start_min, sizeof(start_min));
  1002. DisplayValueToLcm(_Summary_end_time_hr, (uint8_t *)end_hr, sizeof(end_hr));
  1003. DisplayValueToLcm(_Summary_end_time_min, (uint8_t *)end_min, sizeof(end_min));
  1004. */
  1005. int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime,
  1006. ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime);
  1007. //uint8_t _min = (pDcChargingInfo->PresentChargedDuration)/60;
  1008. //uint8_t _sec = (pDcChargingInfo->PresentChargedDuration) % 60;
  1009. /*
  1010. sprintf((char *)value,"%d",min);
  1011. DisplayValueToLcm(_Summary_duration_time, (uint8_t *)value, sizeof(value));
  1012. */
  1013. ChangeDisplay2Value(_Summary_duration_min, (int)duration/60);
  1014. ChangeDisplay2Value(_Summary_duration_sec, (int)duration%60);
  1015. if (pDcChargingInfo->PresentChargedEnergy > 0.001 &&
  1016. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1017. data = pDcChargingInfo->PresentChargedEnergy*1000;
  1018. } else
  1019. data = 0;
  1020. //sprintf((char *)value,"%.1f",data);
  1021. ChangeDisplay2LongValue(_Summary_cap, data);
  1022. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  1023. ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_0);
  1024. }
  1025. else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
  1026. ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_1);
  1027. }
  1028. if (pDcChargingInfo->PowerConsumption >= 0.1 ) {
  1029. data = pDcChargingInfo->PowerConsumption / pDcChargingInfo->PresentChargedDuration;
  1030. } else
  1031. data = 0;
  1032. //sprintf((char *)value,"%.1f",data);
  1033. ChangeDisplay2Value(_Summary_average_power, (int)data);
  1034. //DisplayValueToLcm(_Summary_average_power, (uint8_t *)value, sizeof(value));
  1035. }
  1036. void ProcessPageInfo()
  1037. {
  1038. switch (pSysInfo->SystemPage) {
  1039. case _LCM_VIEW:
  1040. // Confirm Charging Gun Number.
  1041. SetViewPage();
  1042. break;
  1043. case _LCM_START_SCAN:
  1044. ChangeQrCode();
  1045. ShowSelectGunIcon();
  1046. ShowCountDownTimer();
  1047. break;
  1048. case _LCM_START_AUTHORIZING:
  1049. case _LCM_PRECHARGE:
  1050. case _LCM_STOPPING:
  1051. ChangeDisplay2Value(_Animation_Running, 1);
  1052. break;
  1053. case _LCM_START_AUTHORIZE_FAIL:
  1054. case _LCM_LINK_ERROR:
  1055. ShowCountDownTimer();
  1056. break;
  1057. case _LCM_SUMMARY:
  1058. StartSystemTimeoutDet(Timeout_ReturnViewPage);
  1059. ShowCountDownTimer();
  1060. ShowSummaryPage();
  1061. break;
  1062. case _LCM_ERROR:
  1063. break;
  1064. case _LCM_MAINTAIN:
  1065. break;
  1066. case _LCM_WAIT_PLUGIN:
  1067. case _LCM_WAIT_PLUGOUT:
  1068. break;
  1069. case _LCM_EMERGENCY:
  1070. break;
  1071. case _LCM_COMMUNICATION:
  1072. ChangeDisplay2Value(_Animation_Communcation, 1);
  1073. break;
  1074. case _LCM_CHARGING_DETECT:
  1075. ChangeDisplay2Value(_Animation_GFD, 1);
  1076. break;
  1077. case _LCM_PREPARECHARE:
  1078. ChangeDisplay2Value(_Animation_Precharge, 1);
  1079. break;
  1080. }
  1081. }
  1082. void DemoFunction()
  1083. {
  1084. int i;
  1085. uint8_t value[10];
  1086. struct timeb SeqEndTime;
  1087. struct tm *tm;
  1088. int t_hr;
  1089. char start_hr[3], start_min[3], start_sec[3], end_hr[3], end_min[3], end_sec[3];
  1090. ChangeDisplay2Value(_Animation_Running, 1);
  1091. ChangeDisplay2Value(_Animation_Communcation, 1);
  1092. ChangeDisplay2Value(_Animation_GFD, 1);
  1093. ChangeDisplay2Value(_Animation_Precharge, 1);
  1094. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
  1095. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
  1096. ChangeDisplay2Value(_LeftGun_ConnectorId, _ICON_CONNECTOR_1);
  1097. ChangeDisplay2Value(_RightGun_ConnectorId, _ICON_CONNECTOR_1);
  1098. switch (pSysInfo->PageIndex) {
  1099. case __VIEW_ALL_IDLE_:
  1100. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
  1101. switch (pDcChargingInfo->CCSGunType) {
  1102. case _TYPE_CCS1_Liquid:
  1103. case _TYPE_CCS1_Natural:
  1104. ChangeDisplay2Value(_LeftGun_type_pic_U, _ICON_CCS1_GUN_U);
  1105. ChangeDisplay2Value(_LeftGun_type_pic_L, _ICON_CCS1_GUN_L);
  1106. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS1_Name);
  1107. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  1108. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_High_Speed);
  1109. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_B);
  1110. } else {
  1111. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
  1112. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_Speed);
  1113. }
  1114. break;
  1115. case _TYPE_CCS2_Liquid:
  1116. case _TYPE_CCS2_Natural:
  1117. ChangeDisplay2Value(_LeftGun_type_pic_U, _ICON_CCS2_GUN_U);
  1118. ChangeDisplay2Value(_LeftGun_type_pic_L, _ICON_CCS2_GUN_L);
  1119. ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS2_Name);
  1120. ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_C);
  1121. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  1122. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_High_Speed);
  1123. } else {
  1124. ChangeDisplay2Value(_LeftGun_type_speed, _ICON_Speed);
  1125. }
  1126. break;
  1127. }
  1128. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1129. switch (pDcChargingInfo->CCSGunType) {
  1130. case _TYPE_CCS1_Liquid:
  1131. case _TYPE_CCS1_Natural:
  1132. ChangeDisplay2Value(_RightGun_type_pic_U, _ICON_CCS1_GUN_U);
  1133. ChangeDisplay2Value(_RightGun_type_pic_L, _ICON_CCS1_GUN_L);
  1134. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS1_Name);
  1135. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  1136. ChangeDisplay2Value(_RightGun_type_speed, _ICON_High_Speed);
  1137. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
  1138. } else {
  1139. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_A);
  1140. ChangeDisplay2Value(_RightGun_type_speed, _ICON_Speed);
  1141. }
  1142. break;
  1143. case _TYPE_CCS2_Liquid:
  1144. case _TYPE_CCS2_Natural:
  1145. ChangeDisplay2Value(_RightGun_type_pic_U, _ICON_CCS2_GUN_U);
  1146. ChangeDisplay2Value(_RightGun_type_pic_L, _ICON_CCS2_GUN_L);
  1147. ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS2_Name);
  1148. ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_D);
  1149. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  1150. ChangeDisplay2Value(_RightGun_type_speed, _ICON_High_Speed);
  1151. } else {
  1152. ChangeDisplay2Value(_RightGun_type_speed, _ICON_Speed);
  1153. }
  1154. break;
  1155. }
  1156. sleep(5);
  1157. break;
  1158. case __VIEW_LEFT_CHARGE_:
  1159. for (i = 0; i <= 100; i++) {
  1160. ShowViewChargingSoc(LEFT_GUN_NUM,66+i/20);
  1161. ShowViewChargingTime(LEFT_GUN_NUM,i);
  1162. ShowViewCharingMoney(LEFT_GUN_NUM,i);
  1163. ShowViewChargingPower(LEFT_GUN_NUM, (float)(66 + i *0.1));
  1164. ShowViewChargingEngery(LEFT_GUN_NUM,50+i/30);
  1165. usleep(100000);
  1166. }
  1167. break;
  1168. case __VIEW_RIGHT_CHARGE_:
  1169. for (i = 0; i <= 100; i++) {
  1170. ShowViewChargingSoc(RIGHT_GUN_NUM,88+i/25);
  1171. ShowViewChargingTime(RIGHT_GUN_NUM,i);
  1172. ShowViewCharingMoney(RIGHT_GUN_NUM,i);
  1173. ShowViewChargingPower(RIGHT_GUN_NUM, (float)(88 + i*0.1));
  1174. ShowViewChargingEngery(RIGHT_GUN_NUM, 30+i/30);
  1175. usleep(100000);
  1176. }
  1177. break;
  1178. case __VIEW_ALL_CHARGE_:
  1179. for(i=0;i<=100;i++) {
  1180. ShowViewChargingSoc(LEFT_GUN_NUM, 66 + i / 20);
  1181. ShowViewChargingTime(LEFT_GUN_NUM, i);
  1182. ShowViewCharingMoney(LEFT_GUN_NUM, i);
  1183. ShowViewChargingPower(LEFT_GUN_NUM, (float)(66 + i*0.1));
  1184. ShowViewChargingEngery(LEFT_GUN_NUM, 50 + i / 30);
  1185. ShowViewChargingSoc(RIGHT_GUN_NUM, 88 + i / 25);
  1186. ShowViewChargingTime(RIGHT_GUN_NUM, i);
  1187. ShowViewCharingMoney(RIGHT_GUN_NUM, i);
  1188. ShowViewChargingPower(RIGHT_GUN_NUM, (float)(88 + i *0.1));
  1189. ShowViewChargingEngery(RIGHT_GUN_NUM, 30 + i / 30);
  1190. usleep(100000);
  1191. }
  1192. break;
  1193. case 7:
  1194. case 9:
  1195. case 23:
  1196. case 24:
  1197. break;
  1198. case 11:
  1199. for(i = 0 ; i <= 100 ; i++) {
  1200. // RefreshProgressAnimation(_ICON_ProgressBar_10+((i/10)*2));
  1201. uint8_t digits = i % 10;
  1202. uint8_t tens = (i / 10) %10;
  1203. uint8_t hundreds = i / 100;
  1204. ChangeDisplay2Value(_Percent_Number_Digits,(short)_ICON_White_Num_0+digits);
  1205. ChangeDisplay2Value(_Percent_Number_Tens,(short)_ICON_White_Num_0+tens);
  1206. if (hundreds == 0 )
  1207. ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_Empty);
  1208. else
  1209. ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_White_Num_1);
  1210. sprintf((char *)value,"%03d",i);
  1211. DisplayValueToLcm(_Detail_Power_Num, (uint8_t *)value, sizeof(value));
  1212. DisplayValueToLcm(_Detail_Time_Num, (uint8_t *)value, sizeof(value));
  1213. DisplayValueToLcm(_Detail_Cap_Num, (uint8_t *)value, sizeof(value));
  1214. DisplayValueToLcm(_Detail_Money_Num, (uint8_t *)value, sizeof(value));
  1215. if (i%2 == 0 ) {
  1216. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
  1217. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
  1218. memset(value, 0x00, sizeof(value));
  1219. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  1220. sprintf((char *)value,"1 A");
  1221. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  1222. } else {
  1223. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
  1224. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
  1225. memset(value, 0x00, sizeof(value));
  1226. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  1227. sprintf((char *)value,"1 B");
  1228. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  1229. }
  1230. usleep(100000);
  1231. }
  1232. break;
  1233. case 12:
  1234. case 13:
  1235. case 15:
  1236. case 17:
  1237. case 28:
  1238. ftime(&SeqEndTime);
  1239. SeqEndTime.time = time(NULL);
  1240. tm = localtime(&SeqEndTime.time);
  1241. memset(value, 0x00, sizeof(value));
  1242. sprintf((char *)value,"%02d:%02d",tm->tm_hour,tm->tm_min);
  1243. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  1244. if (pSysInfo->PageIndex == 17 || pSysInfo->PageIndex == 28) {
  1245. for (i = 0; i <= 9999; i++) {
  1246. strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, "2022-05-15 16:42:11");
  1247. strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, "2022-05-15 16:47:44");
  1248. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_hr);
  1249. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_min);
  1250. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_sec);
  1251. GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_hr);
  1252. GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_min);
  1253. GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_sec);
  1254. t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
  1255. if (t_hr >= 24)
  1256. t_hr -= 24;
  1257. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime) == 0) {
  1258. ShowChargeTime(_Summary_Start_time_hr, 0);
  1259. ShowChargeTime(_Summary_Start_time_min, 0);
  1260. ShowChargeTime(_Summary_Start_time_sec, 0);
  1261. } else {
  1262. ShowChargeTime(_Summary_Start_time_hr, t_hr);
  1263. ShowChargeTime(_Summary_Start_time_min, atoi(start_min));
  1264. ShowChargeTime(_Summary_Start_time_sec, atoi(start_sec));
  1265. }
  1266. t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
  1267. if (t_hr >= 24)
  1268. t_hr -= 24;
  1269. if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime) == 0) {
  1270. ShowChargeTime(_Summary_end_time_hr, 0);
  1271. ShowChargeTime(_Summary_end_time_min, 0);
  1272. ShowChargeTime(_Summary_end_time_sec, 0);
  1273. } else {
  1274. ShowChargeTime(_Summary_end_time_hr, t_hr);
  1275. ShowChargeTime(_Summary_end_time_min, atoi(end_min));
  1276. ShowChargeTime(_Summary_end_time_sec, atoi(end_sec));
  1277. }
  1278. ChangeDisplay2Value(_Summary_cal_discount,88);
  1279. ChangeDisplay2Value(_Summary_max_power, 888);
  1280. ChangeDisplay2Value(_Summary_average_power, 888);
  1281. if (i < 100) {
  1282. ShowSummaryMoneyDash(_Summary_total_money);
  1283. ShowSummaryMoneyDash(_Summary_cal_Total_money);
  1284. ShowSummaryMoneyDash(_Summary_cal_discount);
  1285. } else {
  1286. ShowSummaryMoney(_Summary_total_money, i);
  1287. ShowSummaryMoney(_Summary_cal_Total_money, i);
  1288. ShowSummaryMoney(_Summary_cal_discount, i);
  1289. }
  1290. usleep(100000);
  1291. }
  1292. }
  1293. break;
  1294. case __START_AUTHORIZE_:
  1295. case __PRE_CHARGE_:
  1296. case __STOP_AUTHORIZE_:
  1297. for( i = 0 ; i <= 20 ; i++) {
  1298. //RefreshProgressAnimation(_ICON_ProgressBar_10);
  1299. usleep(100000);
  1300. }
  1301. for( i = 0 ; i <= 20 ; i++) {
  1302. //RefreshProgressAnimation(_ICON_ProgressBar_20);
  1303. usleep(100000);
  1304. }
  1305. break;
  1306. case 29:
  1307. break;
  1308. case 5:
  1309. pSysInfo->CurGunSelected = 0;
  1310. ChangeQrCode();
  1311. sleep(5);
  1312. break;
  1313. case 31:
  1314. pSysInfo->CurGunSelected = 1;
  1315. ChangeQrCode();
  1316. sleep(5);
  1317. break;
  1318. case 8:
  1319. case 16:
  1320. case 18:
  1321. case 19:
  1322. case 25:
  1323. case 26:
  1324. case 27:
  1325. case 30:
  1326. case 32:
  1327. case 33:
  1328. case 34:
  1329. sleep(5);
  1330. break;
  1331. }
  1332. }
  1333. void ShowCabientVersionDefaultText()
  1334. {
  1335. char value[16];
  1336. memset(value, 0x00, sizeof(value));
  1337. sprintf((char *)value,"%s","Cabient:");
  1338. DisplayValueToLcm(_Version_Cabient_Name_Text, (uint8_t *)value, sizeof(value));
  1339. sprintf((char *)value,"%s","BootLoader:");
  1340. DisplayValueToLcm(_Version_Cabient_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1341. sprintf((char *)value,"%s","Kernel Fw:");
  1342. DisplayValueToLcm(_Version_Cabient_Kernel_Text, (uint8_t *)value, sizeof(value));
  1343. sprintf((char *)value,"%s","CSU Fw:");
  1344. DisplayValueToLcm(_Version_Cabient_CSU_Text, (uint8_t *)value, sizeof(value));
  1345. sprintf((char *)value,"%s","Priamry Fw:");
  1346. DisplayValueToLcm(_Version_Cabient_Priamry_Text, (uint8_t *)value, sizeof(value));
  1347. sprintf((char *)value,"%s","Relay(0) Fw:");
  1348. DisplayValueToLcm(_Version_Cabient_Relay0_Text, (uint8_t *)value, sizeof(value));
  1349. sprintf((char *)value,"%s","Relay(1) Fw:");
  1350. DisplayValueToLcm(_Version_Cabient_Relay1_Text, (uint8_t *)value, sizeof(value));
  1351. sprintf((char *)value,"%s","Fan Fw:");
  1352. DisplayValueToLcm(_Version_Cabient_Fan_Text, (uint8_t *)value, sizeof(value));
  1353. sprintf((char *)value,"%s","IP Addr:");
  1354. DisplayValueToLcm(_Version_Cabient_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1355. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number <= 12) {
  1356. sprintf((char *)value,"%s","Primary");
  1357. DisplayValueToLcm(_Version_Cabient_Primary_Text, (uint8_t *)value, sizeof(value));
  1358. sprintf((char *)value,"%s","Secondary");
  1359. DisplayValueToLcm(_Version_Cabient_Secondary_Text, (uint8_t *)value, sizeof(value));
  1360. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1361. sprintf((char *)value,"PSU(%d):",i+1);
  1362. DisplayValueToLcm(_Version_Cabient_PSU1_Text+i*0x10, (uint8_t *)value, sizeof(value));
  1363. }
  1364. }
  1365. }
  1366. void ShowDispenserVersionDefautlText()
  1367. {
  1368. char value[16];
  1369. memset(value, 0x00, sizeof(value));
  1370. sprintf((char *)value,"%s","Dispenser:");
  1371. DisplayValueToLcm(_Version_Dispenser_Name_Text, (uint8_t *)value, sizeof(value));
  1372. sprintf((char *)value,"%s","BootLoader:");
  1373. DisplayValueToLcm(_Version_Dispenser_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1374. sprintf((char *)value,"%s","Kernel Fw:");
  1375. DisplayValueToLcm(_Version_Dispenser_Kernel_Text, (uint8_t *)value, sizeof(value));
  1376. sprintf((char *)value,"%s","CSU Fw:");
  1377. DisplayValueToLcm(_Version_Dispenser_CSU_Text, (uint8_t *)value, sizeof(value));
  1378. sprintf((char *)value,"%s","Relay Fw:");
  1379. DisplayValueToLcm(_Version_Dispenser_Relay_Text, (uint8_t *)value, sizeof(value));
  1380. sprintf((char *)value,"%s","Fan Fw:");
  1381. DisplayValueToLcm(_Version_Dispenser_Fan_Text, (uint8_t *)value, sizeof(value));
  1382. sprintf((char *)value,"%s","Prim Fw:");
  1383. DisplayValueToLcm(_Version_Dispenser_Priamry_Text, (uint8_t *)value, sizeof(value));
  1384. sprintf((char *)value,"%s","LCM Hw:");
  1385. DisplayValueToLcm(_Version_Dispenser_LCM_Text, (uint8_t *)value, sizeof(value));
  1386. sprintf((char *)value,"%s","LED Fw:");
  1387. DisplayValueToLcm(_Version_Dispenser_LED_Text, (uint8_t *)value, sizeof(value));
  1388. sprintf((char *)value,"%s","Connector(0):");
  1389. DisplayValueToLcm(_Version_Dispenser_Connector0_Text, (uint8_t *)value, sizeof(value));
  1390. sprintf((char *)value,"%s","Connector(1):");
  1391. DisplayValueToLcm(_Version_Dispenser_Connector1_Text, (uint8_t *)value, sizeof(value));
  1392. sprintf((char *)value,"%s","IP Addr:");
  1393. DisplayValueToLcm(_Version_Dispenser_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1394. }
  1395. void ShowCabientVersion()
  1396. {
  1397. char value[16];
  1398. memset(value, 0x00, sizeof(value));
  1399. sprintf((char *)value,"%s",ShmDcCommonData->CabinetModelName);
  1400. DisplayValueToLcm(_Version_Cabient_Model_value, (uint8_t *)value, sizeof(value));
  1401. sprintf((char *)value,"%s",ShmDcCommonData->CabinetBoolLoaderVersion);
  1402. DisplayValueToLcm(_Version_Cabient_BootLoader_value, (uint8_t *)value, sizeof(value));
  1403. sprintf((char *)value,"%s",ShmDcCommonData->CabinetKernelVersion);
  1404. DisplayValueToLcm(_Version_Cabient_Kernel_value, (uint8_t *)value, sizeof(value));
  1405. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRFSystemVersion);
  1406. DisplayValueToLcm(_Version_Cabient_CSU_value, (uint8_t *)value, sizeof(value));
  1407. sprintf((char *)value,"%s",ShmDcCommonData->CabinetPrimaryVersion);
  1408. DisplayValueToLcm(_Version_Cabient_Priamry_value, (uint8_t *)value, sizeof(value));
  1409. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay0Version);
  1410. DisplayValueToLcm(_Version_Cabient_Relay0_value, (uint8_t *)value, sizeof(value));
  1411. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay1Version);
  1412. DisplayValueToLcm(_Version_Cabient_Relay1_value, (uint8_t *)value, sizeof(value));
  1413. sprintf((char *)value,"%s",ShmDcCommonData->CabinetFanVersion);
  1414. DisplayValueToLcm(_Version_Cabient_Fan_value, (uint8_t *)value, sizeof(value));
  1415. sprintf((char *)value,"%s",ShmDcCommonData->CabinetIPAddr);
  1416. DisplayValueToLcm(_Version_Cabient_IPAddr_value, (uint8_t *)value, sizeof(value));
  1417. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number < 12) {
  1418. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1419. if (i>=6) {
  1420. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].DCVersion);
  1421. DisplayValueToLcm(_Version_Cabient_PSU_Prim7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1422. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].FPCVersion);
  1423. DisplayValueToLcm(_Version_Cabient_PSU_Sec7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1424. continue;
  1425. }
  1426. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].DCVersion);
  1427. DisplayValueToLcm(_Version_Cabient_PSU_Prim1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1428. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].FPCVersion);
  1429. DisplayValueToLcm(_Version_Cabient_PSU_Sec1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1430. }
  1431. }
  1432. }
  1433. void ShowDispenserVersion()
  1434. {
  1435. char value[32];
  1436. memset(value, 0x00, sizeof(value));
  1437. sprintf((char *)value,"%s",pSysConfig->ModelName);
  1438. DisplayValueToLcm(_Version_Dispenser_Model_value, (uint8_t *)value, sizeof(value));
  1439. sprintf((char *)value,"%s",pSysInfo->CsuBootLoadFwRev);
  1440. DisplayValueToLcm(_Version_Dispenser_BootLoader_value, (uint8_t *)value, sizeof(value));
  1441. sprintf((char *)value,"%s",pSysInfo->CsuKernelFwRev);
  1442. DisplayValueToLcm(_Version_Dispenser_Kernel_value, (uint8_t *)value, sizeof(value));
  1443. sprintf((char *)value,"%s",pSysInfo->CsuRootFsFwRev);
  1444. DisplayValueToLcm(_Version_Dispenser_CSU_value, (uint8_t *)value, sizeof(value));
  1445. sprintf((char *)value,"%s",pSysInfo->RelayModuleFwRev);
  1446. DisplayValueToLcm(_Version_Dispenser_Relay_value, (uint8_t *)value, sizeof(value));
  1447. sprintf((char *)value,"%s",pSysInfo->FanModuleFwRev);
  1448. DisplayValueToLcm(_Version_Dispenser_Fan_value, (uint8_t *)value, sizeof(value));
  1449. sprintf((char *)value,"%s",pSysInfo->CsuPrimFwRev);
  1450. DisplayValueToLcm(_Version_Dispenser_Priamry_value, (uint8_t *)value, sizeof(value));
  1451. sprintf((char *)value,"%s",pSysInfo->LcmHwRev);
  1452. DisplayValueToLcm(_Version_Dispenser_LCM_value, (uint8_t *)value, sizeof(value));
  1453. sprintf((char *)value,"%s",pSysInfo->LedModuleFwRev);
  1454. DisplayValueToLcm(_Version_Dispenser_LED_value, (uint8_t *)value, sizeof(value));
  1455. sprintf((char *)value,"%s",pSysInfo->Connector1FwRev);
  1456. DisplayValueToLcm(_Version_Dispenser_Connector0_value, (uint8_t *)value, sizeof(value));
  1457. sprintf((char *)value,"%s",pSysInfo->Connector2FwRev);
  1458. DisplayValueToLcm(_Version_Dispenser_Connector1_value, (uint8_t *)value, sizeof(value));
  1459. sprintf((char *)value,"%s",pSysConfig->Eth0Interface.EthIpAddress);
  1460. DisplayValueToLcm(_Version_Dispenser_IPAddr_value, (uint8_t *)value, sizeof(value));
  1461. }
  1462. void InformationShow()
  1463. {
  1464. is_show = true;
  1465. if (_showInformIndex == 0 ) {
  1466. pSysInfo->PageIndex = __SHOW_CABIENT_VERSION;
  1467. } else {
  1468. pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION;
  1469. ShowDispenserVersion();
  1470. }
  1471. }
  1472. void ChangeWarningFunc()
  1473. {
  1474. uint8_t cmd[7] = { 0 };
  1475. uint8_t i = 0;
  1476. //uint8_t j = 0;
  1477. //log_info("ChangeWarningFunc ");
  1478. // 最多一次五筆
  1479. //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
  1480. //log_info("WarningCount = %d ", pSysWarning->WarningCount);
  1481. //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  1482. for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
  1483. //log_info("Warming Code[%d]:%s", i, &pSysWarning->WarningCode[i][0]);
  1484. memset(cmd, 0x00, sizeof(cmd));
  1485. if ((i) >= 5) {
  1486. break;
  1487. }
  1488. //error code
  1489. string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
  1490. DisplayValueToLcm(_Text_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1491. //警告標示
  1492. memset(cmd, 0x00, sizeof(cmd));
  1493. cmd[0] = 0x00;
  1494. cmd[1] = 1;
  1495. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1496. }
  1497. memset(cmd, 0x00, sizeof(cmd));
  1498. for (; i < 5; i++) {
  1499. DisplayValueToLcm(_Text_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1500. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1501. }
  1502. }
  1503. void GetDeviceInfoStatus(short address, uint8_t len)
  1504. {
  1505. uint8_t cmd[8];
  1506. memset(cmd, 0x00, sizeof(cmd));
  1507. uint8_t msg[11];
  1508. memset(msg, 0x00, sizeof(msg));
  1509. cmd[0] = CMD_TITLE_1;
  1510. cmd[1] = CMD_TITLE_2;
  1511. cmd[2] = 0x04;
  1512. cmd[3] = CMD_MULTI_READ;
  1513. cmd[4] = (address >> 8) & 0xff;
  1514. cmd[5] = (address >> 0) & 0xff;
  1515. cmd[6] = len;
  1516. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  1517. usleep(5000);
  1518. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  1519. }
  1520. int main(void)
  1521. {
  1522. if (CreateAllCsuShareMemory() == FAIL) {
  1523. log_error("create share memory error");
  1524. return FAIL;
  1525. }
  1526. MappingGunChargingInfo("LCM Control Task");
  1527. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  1528. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  1529. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  1530. ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
  1531. ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  1532. ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  1533. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  1534. struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
  1535. struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  1536. struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1537. _port = CreateCommunicationLcmPort();
  1538. ChangeBackLight(true);
  1539. _totalCount = pSysConfig->TotalConnectorCount;
  1540. _everyPageRollChange = 0;
  1541. uint8_t curWarningCount = 255;
  1542. uint8_t changeWarningPriority = 0;
  1543. //Initialization();
  1544. //printf("_LCM_COMPLETE ");
  1545. //ChangeToOtherPage(_LCM_COMPLETE);
  1546. //return 0;
  1547. uint8_t index = 35;
  1548. ShmDcCommonData->PSU_Number = 12;
  1549. uint8_t _verShowCount = 5;
  1550. while (_port != -1) {
  1551. if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
  1552. GetDeviceInfoStatus(_LCM_VERSION, 3);
  1553. GetCurrentPage();
  1554. sleep(1);
  1555. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1556. if (_verShowCount > 0) {
  1557. log_info("LCM Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
  1558. _verShowCount--;
  1559. }
  1560. } else {
  1561. // Show Default Text
  1562. /*
  1563. if (!defaulttext) {
  1564. ShowCabientVersionDefaultText();
  1565. ShowDispenserVersionDefautlText();
  1566. defaulttext = true;
  1567. }
  1568. */
  1569. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
  1570. if(pSysConfig->TotalConnectorCount>=2) {
  1571. if (pDcChargingInfo_0->SystemStatus == S_IDLE) {
  1572. ChargeMaxPower_0 = 0;
  1573. } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING) {
  1574. if (pDcChargingInfo_0->PresentChargingPower > ChargeMaxPower_0 &&
  1575. pDcChargingInfo_0->PresentChargingPower >= 0 &&
  1576. pDcChargingInfo_0->PresentChargingPower <= POWER_MAX_KW)
  1577. ChargeMaxPower_0 = pDcChargingInfo_0->PresentChargingPower;
  1578. }
  1579. if (pDcChargingInfo_1->SystemStatus == S_IDLE) {
  1580. ChargeMaxPower_1 = 0;
  1581. } else if (pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  1582. if (pDcChargingInfo_1->PresentChargingPower > ChargeMaxPower_1 &&
  1583. pDcChargingInfo_1->PresentChargingPower >= 0 &&
  1584. pDcChargingInfo_1->PresentChargingPower <= POWER_MAX_KW)
  1585. ChargeMaxPower_1 = pDcChargingInfo_1->PresentChargingPower;
  1586. }
  1587. }
  1588. // Warming處理
  1589. if (curWarningCount != pSysWarning->WarningCount) {
  1590. changeWarningPriority = 0;
  1591. pSysWarning->PageIndex = 0;
  1592. curWarningCount = pSysWarning->WarningCount;
  1593. ChangeWarningFunc();
  1594. } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
  1595. // 當有兩頁 Warning 則每隔三秒改變一次
  1596. if (pSysWarning->PageIndex == 0) {
  1597. pSysWarning->PageIndex = 1;
  1598. } else {
  1599. pSysWarning->PageIndex = 0;
  1600. }
  1601. ChangeWarningFunc();
  1602. }
  1603. // 頁面資訊處理
  1604. ///*
  1605. ProcessPageInfo();
  1606. // 換頁處理
  1607. GetCurrentPage(); //DS60-120 add
  1608. ChangeCurPage();
  1609. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1610. //*/
  1611. /*
  1612. if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _LCM_VIEW) {
  1613. InformationShow();
  1614. ChangeToOtherPage(pSysInfo->PageIndex);
  1615. usleep(100000);
  1616. continue;
  1617. } else {
  1618. if (is_show)
  1619. _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
  1620. is_show = false;
  1621. }
  1622. */
  1623. /*
  1624. pSysInfo->PageIndex = DemoPage[ShmDcCommonData->DemoCount];
  1625. GetCurrentPage();
  1626. ChangeToOtherPage(DemoPage[ShmDcCommonData->DemoCount]);
  1627. GetCurrentPage();
  1628. DemoFunction();
  1629. ShmDcCommonData->DemoCount >= 1 ? ShmDcCommonData->DemoCount = 0 : ShmDcCommonData->DemoCount++;
  1630. //*/
  1631. usleep(100000);
  1632. }
  1633. } //while
  1634. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1635. log_info("Close LCM Uart Port");
  1636. CloseCommunicationLcmPort();
  1637. return FAIL;
  1638. }