Module_LcmControl.c 71 KB

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