Module_LcmControl.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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. #define uSEC_VAL (1000000)
  18. //------------------------------------------------------------------------------
  19. //struct SysConfigAndInfo *ShmSysConfigAndInfo;
  20. //struct StatusCodeData *ShmStatusCodeData;
  21. static struct SysConfigData *pSysConfig = NULL;
  22. static struct SysInfoData *pSysInfo = NULL;
  23. static struct WARNING_CODE_INFO *pSysWarning = NULL;
  24. static struct FanModuleData *ShmFanModuleData;
  25. static struct PrimaryMcuData *ShmPrimaryMcuData;
  26. static SelectGunInfo *ShmSelectGunInfo = NULL;
  27. static struct ChargingInfoData *pDcChargingInfo = NULL;
  28. short _currentPage = _LCM_NONE;
  29. uint8_t _totalCount;
  30. uint8_t _showInformIndex = 0;
  31. float ChargeMaxPower_0 = 0;
  32. float ChargeMaxPower_1 = 0;
  33. int _port;
  34. //char* pPortName = "/dev/ttyO2";
  35. char *pPortName = "/dev/ttyS3";
  36. char *moduleName = "DMT80480T070_09WT";
  37. bool is_show = false;
  38. uint8_t _everyPageRollChange;
  39. //==========================================
  40. // Open and Close RS232 and R/W
  41. //==========================================
  42. unsigned long GetClockTimeoutValue(struct timespec _start_time)
  43. {
  44. struct timespec ts_end;
  45. unsigned long ret = 0;
  46. clock_gettime(CLOCK_MONOTONIC, &ts_end);
  47. ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000)));
  48. return ret;
  49. }
  50. int CreateCommunicationLcmPort()
  51. {
  52. int fd;
  53. struct termios tios;
  54. fd = open(pPortName, O_RDWR);
  55. if (fd <= 0) {
  56. log_error("open /dev/ttyS3 NG ");
  57. return -1;
  58. }
  59. ioctl(fd, TCGETS, &tios);
  60. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  61. tios.c_lflag = 0;
  62. tios.c_iflag = 0;
  63. tios.c_oflag = 0;
  64. tios.c_cc[VMIN] = 0;
  65. tios.c_cc[VTIME] = (uint8_t) 5;
  66. tios.c_lflag = 0;
  67. tcflush(fd, TCIFLUSH);
  68. ioctl(fd, TCSETS, &tios);
  69. return fd;
  70. }
  71. void CloseCommunicationLcmPort()
  72. {
  73. close(_port);
  74. }
  75. void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
  76. {
  77. int len = write(_port, cmd, cmdLen);
  78. if (len < sizeof(cmd)) {
  79. log_error("Write cmd to LCM Failure. ");
  80. }
  81. }
  82. void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
  83. {
  84. read(_port, msg, readLen);
  85. if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2) {
  86. if (*(msg + 3) == CMD_WRITE) {
  87. switch (*(msg + 4)) {
  88. case CMD_REGISTER: {
  89. // 頁面
  90. strcpy((char *)pSysInfo->LcmHwRev, moduleName);
  91. }
  92. break;
  93. }
  94. } else if (*(msg + 3) == CMD_MULTI_READ) {
  95. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  96. // {
  97. // case BUTTON_GUN_INDEX:
  98. // {
  99. // // 當前選的槍號
  100. // _curGunIndex = (*(msg + 8));
  101. // }
  102. // break;
  103. // }
  104. }
  105. }
  106. }
  107. void GetHrFormTimeString(char* time,char* hr)
  108. {
  109. //char tm[] = "2021-12-06 17:29:08:084";
  110. for(int i = 0 ; i < 2 ; i++) {
  111. hr[i] = time[i+11];
  112. }
  113. if( atoi(hr) == NULL ) {
  114. strcmp(hr,"");
  115. }
  116. }
  117. void GetMinFormTimeString(char* time,char* min)
  118. {
  119. //char tm[] = "2021-12-06 17:29:08:084";
  120. for(int i = 0 ; i < 2 ; i++) {
  121. min[i] = time[i+14];
  122. }
  123. if( atoi(min) == NULL || atoi(min) > 60) {
  124. strcmp(min,"");
  125. }
  126. }
  127. //================================================
  128. // Function
  129. //================================================
  130. void ChangeToOtherPage(short newPage)
  131. {
  132. uint8_t cmd[7];
  133. memset(cmd, 0x00, sizeof(cmd));
  134. cmd[0] = CMD_TITLE_1;
  135. cmd[1] = CMD_TITLE_2;
  136. cmd[2] = 0x02 + sizeof(newPage);
  137. cmd[3] = CMD_READ;
  138. cmd[4] = CMD_REGISTER;
  139. cmd[5] = newPage >> 8;
  140. cmd[6] = newPage & 0x00FF;
  141. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  142. usleep(100000);
  143. }
  144. void ChangeBackLight(bool islight)
  145. {
  146. uint8_t value = 0x01;
  147. if (islight) {
  148. value = 0x20;
  149. }
  150. uint8_t cmd[7];
  151. memset(cmd, 0x00, sizeof(cmd));
  152. cmd[0] = CMD_TITLE_1;
  153. cmd[1] = CMD_TITLE_2;
  154. cmd[2] = 0x03;
  155. cmd[3] = CMD_READ;
  156. cmd[4] = CMD_BACKLIGHT;
  157. cmd[5] = value;
  158. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  159. usleep(100000);
  160. }
  161. void GetCurrentPage()
  162. {
  163. uint8_t cmd[6];
  164. memset(cmd, 0x00, sizeof(cmd));
  165. uint8_t msg[8];
  166. memset(msg, 0x00, sizeof(msg));
  167. cmd[0] = CMD_TITLE_1;
  168. cmd[1] = CMD_TITLE_2;
  169. cmd[2] = 0x03; // 底下總長度
  170. cmd[3] = CMD_WRITE;
  171. cmd[4] = CMD_REGISTER;
  172. cmd[5] = 0x02;
  173. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  174. usleep(5000);
  175. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  176. }
  177. void DisplayValueToLcm(short address, uint8_t *data, uint8_t len)
  178. {
  179. uint8_t cmd[256];
  180. memset(cmd, 0x00, sizeof(cmd));
  181. cmd[0] = CMD_TITLE_1;
  182. cmd[1] = CMD_TITLE_2;
  183. cmd[2] = 0x03 + len;
  184. cmd[3] = CMD_MULTI_WRITE;
  185. cmd[4] = address >> 8;
  186. cmd[5] = address & 0x00FF;
  187. for (uint8_t count = 0; count < len; count++) {
  188. cmd[6 + count] = *(data + count);
  189. }
  190. WriteCmdToLcm(cmd, cmd[2] + 3);
  191. }
  192. void ChangeDisplay2Value(short address, short value)
  193. {
  194. uint8_t data[2];
  195. data[0] = value >> 8;
  196. data[1] = value & 0x00FF;
  197. //log_info("Addr:0x%x, value:%d",address,value);
  198. DisplayValueToLcm(address, data, sizeof(data));
  199. }
  200. //================================================
  201. // Warning process
  202. //================================================
  203. void string2ByteArray(uint8_t *input, uint8_t *output)
  204. {
  205. int loop;
  206. int i;
  207. loop = 0;
  208. i = 0;
  209. while (input[loop] != '\0') {
  210. output[i++] = input[loop++];
  211. }
  212. output[loop] = '\0';
  213. }
  214. void RefreshProgressAnimation(uint8_t progress_index)
  215. {
  216. if(_everyPageRollChange % 2) {
  217. progress_index+=1;
  218. }
  219. ChangeDisplay2Value(_ProgressBar_LEVEL,progress_index);
  220. _everyPageRollChange++;
  221. }
  222. //================================================
  223. // Change current page
  224. //================================================
  225. void ChangeCurPage()
  226. {
  227. //log_info("cur = %d ,system = %d, lcm = %d ",_currentPage, pSysInfo->SystemPage, pSysInfo->PageIndex);
  228. struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  229. struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  230. if (_currentPage != pSysInfo->SystemPage) {
  231. switch (pSysInfo->SystemPage) {
  232. case _LCM_VIEW:
  233. if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_IDLE ) {
  234. pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
  235. } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus != S_CHARGING) {
  236. pSysInfo->PageIndex = __VIEW_LEFT_CHARGE_;
  237. } else if(pDcChargingInfo_0->SystemStatus != S_CHARGING && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  238. pSysInfo->PageIndex = __VIEW_RIGHT_CHARGE_;
  239. } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  240. pSysInfo->PageIndex = __VIEW_ALL_CHARGE_;
  241. } else
  242. pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
  243. break;
  244. case _LCM_START_SCAN:
  245. pSysInfo->PageIndex = __START_SCAN_;
  246. break;
  247. case _LCM_START_AUTHORIZING:
  248. pSysInfo->PageIndex = __START_AUTHORIZE_;
  249. break;
  250. case _LCM_START_AUTHORIZE_FAIL:
  251. pSysInfo->PageIndex = __START_AUTHORIZE_FAIL_;
  252. break;
  253. case _LCM_WAIT_PLUGIN:
  254. pSysInfo->PageIndex = __WAIT_PLUGIN_;
  255. break;
  256. case _LCM_PRECHARGE:
  257. pSysInfo->PageIndex =__PRE_CHARGE_;
  258. break;
  259. case _LCM_LINK_ERROR:
  260. pSysInfo->PageIndex =__LINKING_ERROR_;
  261. break;
  262. case _LCM_DETAIL_VIEW:
  263. pSysInfo->PageIndex =__DETAIL_VIEW_;
  264. break;
  265. case _LCM_STOP_RFID:
  266. pSysInfo->PageIndex =__STOP_SCAN_RFID_;
  267. break;
  268. case _LCM_STOP_APP:
  269. pSysInfo->PageIndex =__STOP_SCAN_APP_;
  270. break;
  271. case _LCM_STOP_RFID_FAIL:
  272. pSysInfo->PageIndex =__STOP_RFID_FAIL_;
  273. break;
  274. case _LCM_STOPPING:
  275. pSysInfo->PageIndex =__STOP_AUTHORIZE_;
  276. break;
  277. case _LCM_WAIT_PLUGOUT:
  278. pSysInfo->PageIndex =__WAIT_PLUGOUT_;
  279. break;
  280. case _LCM_SUMMARY:
  281. pSysInfo->PageIndex =__SUMMARY_;
  282. break;
  283. case _LCM_MAINTAIN:
  284. pSysInfo->PageIndex =__MAINTAIN_PAGE_;
  285. break;
  286. case _LCM_ERROR:
  287. pSysInfo->PageIndex =__ERROR_PAGE_;
  288. break;
  289. case _LCM_EMERGENCY:
  290. pSysInfo->PageIndex =__EMERGENCY_BUTTON_;
  291. break;
  292. }
  293. _currentPage = pSysInfo->SystemPage;
  294. ChangeToOtherPage(pSysInfo->PageIndex);
  295. }
  296. }
  297. /*
  298. * View Page
  299. *
  300. */
  301. void ShowViewChargingSoc(uint8_t gunIndex,int soc)
  302. {
  303. uint8_t digits = soc % 10;
  304. uint8_t tens = (soc / 10) %10;
  305. uint8_t hundreds = soc / 100;
  306. if (gunIndex == LEFT_GUN_NUM) {
  307. ChangeDisplay2Value(_LeftGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
  308. ChangeDisplay2Value(_LeftGun_Soc_Tens,(short)_ICON_Red_Num_0+tens);
  309. if (hundreds == 0 ) {
  310. ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Empty);
  311. if (tens == 0 )
  312. ChangeDisplay2Value(_LeftGun_Soc_Tens,(short)_ICON_Empty);
  313. }
  314. else
  315. ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Red_Num_1);
  316. } else {
  317. //log_info("%d %d %d",hundreds,tens,digits);
  318. ChangeDisplay2Value(_RightGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
  319. ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Red_Num_0+tens);
  320. if (hundreds == 0 ) {
  321. ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Empty);
  322. if (tens == 0)
  323. ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Empty);
  324. }
  325. else
  326. ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Red_Num_1);
  327. }
  328. }
  329. void ShowViewChargingTime(uint8_t gunIndex,int time)
  330. {
  331. uint8_t value[10] = {0};
  332. int min;
  333. min = time/60;
  334. sprintf((char *)value,"%d",min);
  335. if (gunIndex == LEFT_GUN_NUM) {
  336. DisplayValueToLcm(_LeftGun_info_time, (uint8_t *)value, sizeof(value));
  337. } else
  338. DisplayValueToLcm(_RightGun_info_time, (uint8_t *)value, sizeof(value));
  339. }
  340. void ShowViewCharingMoney(uint8_t gunIndex,float money)
  341. {
  342. uint8_t value[10] = {0};
  343. sprintf((char *)value,"%.1f",money);
  344. if (gunIndex == LEFT_GUN_NUM) {
  345. DisplayValueToLcm(_LeftGun_info_money, (uint8_t *)value, sizeof(value));
  346. } else
  347. DisplayValueToLcm(_RightGun_info_money, (uint8_t *)value, sizeof(value));
  348. }
  349. void ShowViewChargingPower(uint8_t gunIndex,float power)
  350. {
  351. uint8_t value[10] = {0};
  352. sprintf((char *)value,"%.1f",power);
  353. if (power >= 0 && power <= POWER_MAX_KW) {
  354. if (gunIndex == LEFT_GUN_NUM) {
  355. DisplayValueToLcm(_LeftGun_info_power_number, (uint8_t *)value, sizeof(value));
  356. } else
  357. DisplayValueToLcm(_RightGun_info_power_number, (uint8_t *)value, sizeof(value));
  358. }
  359. }
  360. void ShowViewLeftGunInfo()
  361. {
  362. char value[5];
  363. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  364. if (pDcChargingInfo->SystemStatus == S_IDLE ) {
  365. switch (pDcChargingInfo->CCSGunType) {
  366. case _TYPE_CCS1_Liquid:
  367. case _TYPE_CCS1_Natural:
  368. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS1_GUN_U);
  369. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS1_GUN_L);
  370. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS1_Name);
  371. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  372. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  373. } else {
  374. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  375. }
  376. break;
  377. case _TYPE_CCS2_Liquid:
  378. case _TYPE_CCS2_Natural:
  379. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS2_GUN_U);
  380. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS2_GUN_L);
  381. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS2_Name);
  382. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  383. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  384. } else {
  385. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  386. }
  387. break;
  388. default:
  389. log_error("CCS Gun Type Error! Not Show in LCM!!");
  390. }
  391. memset(value, 0x00, sizeof(value));
  392. sprintf((char *)value,"1A");
  393. DisplayValueToLcm(_LeftGun_location, (uint8_t *)value, sizeof(value));
  394. } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
  395. ShowViewChargingSoc(LEFT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
  396. ShowViewChargingTime(LEFT_GUN_NUM,pDcChargingInfo->PresentChargedDuration);
  397. ShowViewCharingMoney(LEFT_GUN_NUM,pDcChargingInfo->ChargingFee);
  398. ShowViewChargingPower(LEFT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
  399. }
  400. }
  401. void ShowViewRightGunInfo()
  402. {
  403. char value[5];
  404. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  405. if (pDcChargingInfo->SystemStatus == S_IDLE ) {
  406. switch (pDcChargingInfo->CCSGunType) {
  407. case _TYPE_CCS1_Liquid:
  408. case _TYPE_CCS1_Natural:
  409. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS1_GUN_U);
  410. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS1_GUN_L);
  411. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS1_Name);
  412. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
  413. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  414. } else {
  415. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  416. }
  417. break;
  418. case _TYPE_CCS2_Liquid:
  419. case _TYPE_CCS2_Natural:
  420. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS2_GUN_U);
  421. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS2_GUN_L);
  422. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS2_Name);
  423. if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
  424. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  425. } else {
  426. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  427. }
  428. break;
  429. default:
  430. log_error("CCS Gun Type Error! Not Show in LCM!!");
  431. }
  432. memset(value, 0x00, sizeof(value));
  433. sprintf((char *)value,"1B");
  434. DisplayValueToLcm(_RightGun_location, (uint8_t *)value, sizeof(value));
  435. } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
  436. ShowViewChargingSoc(RIGHT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
  437. ShowViewChargingTime(RIGHT_GUN_NUM,pDcChargingInfo->PresentChargedDuration);
  438. ShowViewCharingMoney(RIGHT_GUN_NUM,pDcChargingInfo->ChargingFee);
  439. ShowViewChargingPower(RIGHT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
  440. }
  441. }
  442. void SetViewPage()
  443. {
  444. // Set Background pic.
  445. if (pSysConfig->TotalConnectorCount == 1) {
  446. } else if (pSysConfig->TotalConnectorCount == 2) {
  447. ShowViewLeftGunInfo();
  448. ShowViewRightGunInfo();
  449. }
  450. }
  451. void ShowSelectGunIcon()
  452. {
  453. uint8_t value[5] = {0};
  454. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  455. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  456. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  457. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  458. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
  459. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  460. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  461. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS2_Symbol);
  462. }
  463. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
  464. sprintf((char *)value,"%s",LEFT_GUN_LOCAL_NAME);
  465. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  466. memset(value, 0x00, sizeof(value));
  467. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  468. } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
  469. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  470. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  471. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS1_Symbol);
  472. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  473. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  474. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
  475. }
  476. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
  477. sprintf((char *)value,"%s",RIGHT_GUN_LOCAL_NAME);
  478. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  479. memset(value, 0x00, sizeof(value));
  480. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  481. }
  482. }
  483. /*
  484. * Detail View Page
  485. */
  486. void SetDetailViewPage()
  487. {
  488. uint8_t data;
  489. float float_data;
  490. uint8_t value[10] = {0};
  491. ShowSelectGunIcon();
  492. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  493. uint8_t digits = pDcChargingInfo->EvBatterySoc % 10;
  494. uint8_t tens = (pDcChargingInfo->EvBatterySoc / 10) %10;
  495. uint8_t hundreds = pDcChargingInfo->EvBatterySoc / 100;
  496. // Show Numbers.
  497. ChangeDisplay2Value(_Percent_Number_Digits,_ICON_White_Num_0+digits);
  498. ChangeDisplay2Value(_Percent_Number_Tens,_ICON_White_Num_0+tens);
  499. if (hundreds == 0 ) {
  500. ChangeDisplay2Value(_Percent_Number_Hundreds,_ICON_Empty);
  501. if (tens == 0)
  502. ChangeDisplay2Value(_Percent_Number_Tens,_ICON_Empty);
  503. } else {
  504. ChangeDisplay2Value(_Percent_Number_Hundreds,_ICON_White_Num_1);
  505. }
  506. // Show Progress Bar
  507. ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+(pDcChargingInfo->EvBatterySoc/10)-1);
  508. // Show Power
  509. if (pDcChargingInfo->PresentChargingPower >= 0 &&
  510. pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  511. float_data = pDcChargingInfo->PresentChargingPower;
  512. } else {
  513. float_data = 0;
  514. }
  515. sprintf((char *)value,"%.1f",float_data);
  516. DisplayValueToLcm(_Detail_Power_Num,value, sizeof(value));
  517. // Show Time
  518. data = (pDcChargingInfo->PresentChargedDuration)/60;
  519. sprintf((char *)value,"%d",data);
  520. DisplayValueToLcm(_Detail_Time_Num,value, sizeof(value));
  521. // Show Energy
  522. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  523. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  524. data = pDcChargingInfo->PresentChargedEnergy;
  525. } else
  526. data = 0;
  527. sprintf((char *)value,"%d",data);
  528. DisplayValueToLcm(_Detail_Cap_Num,value, sizeof(value));
  529. // Show Money
  530. //data = pDcChargingInfo->ChargingFee;
  531. sprintf((char *)value,"%.1f",pDcChargingInfo->ChargingFee);
  532. DisplayValueToLcm(_Detail_Money_Num,value, sizeof(value));
  533. }
  534. void ShowCountDownTimer()
  535. {
  536. int min,sec;
  537. uint8_t value[10] = {0};
  538. int tm = 120 - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
  539. // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
  540. min = tm/60;
  541. sec = tm%60;
  542. sprintf((char *)value,"%02d:%02d",min,sec);
  543. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  544. }
  545. unsigned long GetTimeoutValue(struct timeval _sour_time)
  546. {
  547. struct timeval _end_time;
  548. gettimeofday(&_end_time, NULL);
  549. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  550. }
  551. void ShowGunCountDownTimer()
  552. {
  553. int min,sec;
  554. uint8_t value[10] = {0};
  555. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  556. int tm = 30 - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL);
  557. // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
  558. min = tm/60;
  559. sec = tm%60;
  560. sprintf((char *)value,"%02d:%02d",min,sec);
  561. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  562. }
  563. void ShowProgressBar()
  564. {
  565. for(int i = 0 ; i <= 19 ; i++) {
  566. ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+i);
  567. usleep(100000);
  568. }
  569. }
  570. void ShowSummaryPage()
  571. {
  572. float data;
  573. uint8_t value[10] = {0};
  574. char start_hr[3],start_min[3],end_hr[3],end_min[3];
  575. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  576. // Show Money
  577. data = pDcChargingInfo->ChargingFee;
  578. sprintf((char *)value,"%.1f",data);
  579. int discount,settlement = 0;
  580. DisplayValueToLcm(_Summary_total_money, (uint8_t *)value, sizeof(value));
  581. DisplayValueToLcm(_Summary_cal_Total_money, (uint8_t *)value, sizeof(value));
  582. /*
  583. log_info("start time:%s",pDcChargingInfo->StartDateTime);
  584. log_info("stop time:%s",pDcChargingInfo->StopDateTime);*/
  585. GetHrFormTimeString(pDcChargingInfo->StartDateTime,start_hr);
  586. GetMinFormTimeString(pDcChargingInfo->StartDateTime,start_min);
  587. GetHrFormTimeString(pDcChargingInfo->StopDateTime,end_hr);
  588. GetMinFormTimeString(pDcChargingInfo->StopDateTime,end_min);
  589. DisplayValueToLcm(_Summary_Start_time_hr, (uint8_t *)start_hr, sizeof(start_hr));
  590. DisplayValueToLcm(_Summary_Start_time_min, (uint8_t *)start_min, sizeof(start_min));
  591. DisplayValueToLcm(_Summary_end_time_hr, (uint8_t *)end_hr, sizeof(end_hr));
  592. DisplayValueToLcm(_Summary_end_time_min, (uint8_t *)end_min, sizeof(end_min));
  593. uint8_t min = (pDcChargingInfo->PresentChargedDuration)/60;
  594. sprintf((char *)value,"%d",min);
  595. DisplayValueToLcm(_Summary_duration_time, (uint8_t *)value, sizeof(value));
  596. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  597. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  598. data = pDcChargingInfo->PresentChargedEnergy;
  599. } else
  600. data = 0;
  601. sprintf((char *)value,"%d",data);
  602. DisplayValueToLcm(_Summary_cap, (uint8_t *)value, sizeof(value));
  603. sprintf((char *)value,"%.1f",discount);
  604. DisplayValueToLcm(_Summary_cal_discount, (uint8_t *)value, sizeof(value));
  605. settlement = pDcChargingInfo->ChargingFee - discount;
  606. sprintf((char *)value,"%.1f",settlement);
  607. DisplayValueToLcm(_Summary_cal_Settlement, (char *)value, sizeof(value));
  608. if(pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  609. sprintf((char *)value,"%.1f",ChargeMaxPower_0);
  610. } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
  611. sprintf((char *)value,"%.1f",ChargeMaxPower_1);
  612. }
  613. DisplayValueToLcm(_Summary_max_power, (uint8_t *)value, sizeof(value));
  614. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  615. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  616. data = pDcChargingInfo->PresentChargedEnergy * pDcChargingInfo->PresentChargedDuration /3600;
  617. } else
  618. data = 0;
  619. sprintf((char *)value,"%.1f",data);
  620. DisplayValueToLcm(_Summary_average_power, (uint8_t *)value, sizeof(value));
  621. }
  622. void ProcessPageInfo()
  623. {
  624. switch (pSysInfo->SystemPage) {
  625. case _LCM_VIEW:
  626. // Confirm Charging Gun Number.
  627. SetViewPage();
  628. break;
  629. case _LCM_DETAIL_VIEW:
  630. ShowGunCountDownTimer();
  631. SetDetailViewPage();
  632. break;
  633. case _LCM_START_SCAN:
  634. case _LCM_STOP_RFID:
  635. case _LCM_STOP_APP:
  636. ShowSelectGunIcon();
  637. ShowCountDownTimer();
  638. break;
  639. case _LCM_START_AUTHORIZING:
  640. case _LCM_PRECHARGE:
  641. case _LCM_STOPPING:
  642. ShowProgressBar();
  643. break;
  644. case _LCM_START_AUTHORIZE_FAIL:
  645. case _LCM_STOP_RFID_FAIL:
  646. case _LCM_LINK_ERROR:
  647. ShowCountDownTimer();
  648. break;
  649. case _LCM_SUMMARY:
  650. ShowCountDownTimer();
  651. ShowSummaryPage();
  652. break;
  653. case _LCM_ERROR:
  654. case _LCM_MAINTAIN:
  655. case _LCM_WAIT_PLUGIN:
  656. case _LCM_WAIT_PLUGOUT:
  657. break;
  658. case _LCM_EMERGENCY:
  659. break;
  660. }
  661. }
  662. void DemoFunction()
  663. {
  664. int i,j;
  665. uint8_t value[10];
  666. struct timeb SeqEndTime;
  667. struct tm *tm;
  668. switch (pSysInfo->PageIndex) {
  669. case __VIEW_ALL_IDLE_:
  670. memset(value, 0x00, sizeof(value));
  671. sprintf((char *)value,"1A");
  672. DisplayValueToLcm(_LeftGun_location, (uint8_t *)value, sizeof(value));
  673. sprintf((char *)value,"1B");
  674. DisplayValueToLcm(_RightGun_location, (uint8_t *)value, sizeof(value));
  675. sleep(1);
  676. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS2_GUN_U);
  677. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS2_GUN_L);
  678. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS2_Name);
  679. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
  680. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS2_GUN_U);
  681. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS2_GUN_L);
  682. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS2_Name);
  683. ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
  684. sleep(1);
  685. ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS1_GUN_U);
  686. ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS1_GUN_L);
  687. ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS1_Name);
  688. ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
  689. ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS1_GUN_U);
  690. ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS1_GUN_L);
  691. ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS1_Name);
  692. ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
  693. break;
  694. case __VIEW_LEFT_CHARGE_:
  695. for(i=0;i<=100;i++) {
  696. ShowViewChargingSoc(LEFT_GUN_NUM,i);
  697. ShowViewChargingTime(LEFT_GUN_NUM,i*60);
  698. ShowViewCharingMoney(LEFT_GUN_NUM,i);
  699. ShowViewChargingPower(LEFT_GUN_NUM,i);
  700. usleep(100000);
  701. }
  702. break;
  703. case __VIEW_RIGHT_CHARGE_:
  704. for(i=0;i<=100;i++) {
  705. ShowViewChargingSoc(RIGHT_GUN_NUM,i);
  706. ShowViewChargingTime(RIGHT_GUN_NUM,i*60);
  707. ShowViewCharingMoney(RIGHT_GUN_NUM,i);
  708. ShowViewChargingPower(RIGHT_GUN_NUM,i);
  709. usleep(100000);
  710. }
  711. break;
  712. case __VIEW_ALL_CHARGE_:
  713. for(i=0;i<=100;i++) {
  714. ShowViewChargingSoc(LEFT_GUN_NUM,i);
  715. ShowViewChargingTime(LEFT_GUN_NUM,i*60);
  716. ShowViewCharingMoney(LEFT_GUN_NUM,i);
  717. ShowViewChargingPower(LEFT_GUN_NUM,i);
  718. ShowViewChargingSoc(RIGHT_GUN_NUM,i);
  719. ShowViewChargingTime(RIGHT_GUN_NUM,i*60);
  720. ShowViewCharingMoney(RIGHT_GUN_NUM,i);
  721. ShowViewChargingPower(RIGHT_GUN_NUM,i);
  722. usleep(100000);
  723. }
  724. break;
  725. case __START_SCAN_:
  726. case 7:
  727. case 9:
  728. break;
  729. case 11:
  730. for(i = 0 ; i <= 100 ; i++) {
  731. RefreshProgressAnimation(_ICON_ProgressBar_10+((i/10)*2));
  732. uint8_t digits = i % 10;
  733. uint8_t tens = (i / 10) %10;
  734. uint8_t hundreds = i / 100;
  735. ChangeDisplay2Value(_Percent_Number_Digits,(short)_ICON_White_Num_0+digits);
  736. ChangeDisplay2Value(_Percent_Number_Tens,(short)_ICON_White_Num_0+tens);
  737. if (hundreds == 0 )
  738. ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_Empty);
  739. else
  740. ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_White_Num_1);
  741. sprintf((char *)value,"%03d",i);
  742. DisplayValueToLcm(_Detail_Power_Num, (uint8_t *)value, sizeof(value));
  743. DisplayValueToLcm(_Detail_Time_Num, (uint8_t *)value, sizeof(value));
  744. DisplayValueToLcm(_Detail_Cap_Num, (uint8_t *)value, sizeof(value));
  745. DisplayValueToLcm(_Detail_Money_Num, (uint8_t *)value, sizeof(value));
  746. if (i%2 == 0 ) {
  747. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
  748. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
  749. memset(value, 0x00, sizeof(value));
  750. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  751. sprintf((char *)value,"1A");
  752. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  753. } else {
  754. ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
  755. ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
  756. memset(value, 0x00, sizeof(value));
  757. DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
  758. sprintf((char *)value,"1B");
  759. DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
  760. }
  761. usleep(200000);
  762. }
  763. break;
  764. case 12:
  765. case 13:
  766. case 15:
  767. case 17:
  768. ftime(&SeqEndTime);
  769. SeqEndTime.time = time(NULL);
  770. tm = localtime(&SeqEndTime.time);
  771. memset(value, 0x00, sizeof(value));
  772. sprintf((char *)value,"%02d:%02d",tm->tm_hour,tm->tm_min);
  773. DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
  774. if (pSysInfo->PageIndex == 17 ) {
  775. }
  776. break;
  777. case __START_AUTHORIZE_:
  778. case __PRE_CHARGE_:
  779. case __STOP_AUTHORIZE_:
  780. for( i = 0 ; i <= 20 ; i++) {
  781. RefreshProgressAnimation(_ICON_ProgressBar_10);
  782. usleep(200000);
  783. }
  784. for( i = 0 ; i <= 20 ; i++) {
  785. RefreshProgressAnimation(_ICON_ProgressBar_20);
  786. usleep(200000);
  787. }
  788. break;
  789. case 8:
  790. case 16:
  791. case 18:
  792. case 19:
  793. case 20:
  794. break;
  795. case 21:
  796. break;
  797. case 22:
  798. ShowDispenserVersion();
  799. break;
  800. }
  801. }
  802. void ShowCabientVersionDefaultText()
  803. {
  804. char value[16];
  805. memset(value, 0x00, sizeof(value));
  806. sprintf((char *)value,"%s","Cabient:");
  807. DisplayValueToLcm(_Version_Cabient_Name_Text, (uint8_t *)value, sizeof(value));
  808. sprintf((char *)value,"%s","BootLoader:");
  809. DisplayValueToLcm(_Version_Cabient_BootLoader_Text, (uint8_t *)value, sizeof(value));
  810. sprintf((char *)value,"%s","Kernel Fw:");
  811. DisplayValueToLcm(_Version_Cabient_Kernel_Text, (uint8_t *)value, sizeof(value));
  812. sprintf((char *)value,"%s","CSU Fw:");
  813. DisplayValueToLcm(_Version_Cabient_CSU_Text, (uint8_t *)value, sizeof(value));
  814. sprintf((char *)value,"%s","Priamry Fw:");
  815. DisplayValueToLcm(_Version_Cabient_Priamry_Text, (uint8_t *)value, sizeof(value));
  816. sprintf((char *)value,"%s","Relay(0) Fw:");
  817. DisplayValueToLcm(_Version_Cabient_Relay0_Text, (uint8_t *)value, sizeof(value));
  818. sprintf((char *)value,"%s","Relay(1) Fw:");
  819. DisplayValueToLcm(_Version_Cabient_Relay1_Text, (uint8_t *)value, sizeof(value));
  820. sprintf((char *)value,"%s","Fan Fw:");
  821. DisplayValueToLcm(_Version_Cabient_Fan_Text, (uint8_t *)value, sizeof(value));
  822. sprintf((char *)value,"%s","IP Addr:");
  823. DisplayValueToLcm(_Version_Cabient_IPAddr_Text, (uint8_t *)value, sizeof(value));
  824. sprintf((char *)value,"%s","PSU Prim(1):");
  825. DisplayValueToLcm(_Version_Cabient_PSU_Prim1_Text, (uint8_t *)value, sizeof(value));
  826. sprintf((char *)value,"%s","PSU Prim(2):");
  827. DisplayValueToLcm(_Version_Cabient_PSU_Prim2_Text, (uint8_t *)value, sizeof(value));
  828. sprintf((char *)value,"%s","PSU Prim(3):");
  829. DisplayValueToLcm(_Version_Cabient_PSU_Prim3_Text, (uint8_t *)value, sizeof(value));
  830. sprintf((char *)value,"%s","PSU Prim(4):");
  831. DisplayValueToLcm(_Version_Cabient_PSU_Prim4_Text, (uint8_t *)value, sizeof(value));
  832. sprintf((char *)value,"%s","PSU Prim(5):");
  833. DisplayValueToLcm(_Version_Cabient_PSU_Prim5_Text, (uint8_t *)value, sizeof(value));
  834. sprintf((char *)value,"%s","PSU Prim(6):");
  835. DisplayValueToLcm(_Version_Cabient_PSU_Prim6_Text, (uint8_t *)value, sizeof(value));
  836. sprintf((char *)value,"%s","PSU Sec(1):");
  837. DisplayValueToLcm(_Version_Cabient_PSU_Sec1_Text, (uint8_t *)value, sizeof(value));
  838. sprintf((char *)value,"%s","PSU Sec(2):");
  839. DisplayValueToLcm(_Version_Cabient_PSU_Sec2_Text, (uint8_t *)value, sizeof(value));
  840. sprintf((char *)value,"%s","PSU Sec(3):");
  841. DisplayValueToLcm(_Version_Cabient_PSU_Sec3_Text, (uint8_t *)value, sizeof(value));
  842. sprintf((char *)value,"%s","PSU Sec(4):");
  843. DisplayValueToLcm(_Version_Cabient_PSU_Sec4_Text, (uint8_t *)value, sizeof(value));
  844. sprintf((char *)value,"%s","PSU Sec(5):");
  845. DisplayValueToLcm(_Version_Cabient_PSU_Sec5_Text, (uint8_t *)value, sizeof(value));
  846. sprintf((char *)value,"%s","PSU Sec(6):");
  847. DisplayValueToLcm(_Version_Cabient_PSU_Sec6_Text, (uint8_t *)value, sizeof(value));
  848. }
  849. void ShowDispenserVersionDefautlText()
  850. {
  851. char value[16];
  852. memset(value, 0x00, sizeof(value));
  853. sprintf((char *)value,"%s","Dispenser:");
  854. DisplayValueToLcm(_Version_Dispenser_Name_Text, (uint8_t *)value, sizeof(value));
  855. sprintf((char *)value,"%s","BootLoader:");
  856. DisplayValueToLcm(_Version_Dispenser_BootLoader_Text, (uint8_t *)value, sizeof(value));
  857. sprintf((char *)value,"%s","Kernel Fw:");
  858. DisplayValueToLcm(_Version_Dispenser_Kernel_Text, (uint8_t *)value, sizeof(value));
  859. sprintf((char *)value,"%s","CSU Fw:");
  860. DisplayValueToLcm(_Version_Dispenser_CSU_Text, (uint8_t *)value, sizeof(value));
  861. sprintf((char *)value,"%s","Relay Fw:");
  862. DisplayValueToLcm(_Version_Dispenser_Relay_Text, (uint8_t *)value, sizeof(value));
  863. sprintf((char *)value,"%s","Fan Fw:");
  864. DisplayValueToLcm(_Version_Dispenser_Fan_Text, (uint8_t *)value, sizeof(value));
  865. sprintf((char *)value,"%s","Prim Fw:");
  866. DisplayValueToLcm(_Version_Dispenser_Priamry_Text, (uint8_t *)value, sizeof(value));
  867. sprintf((char *)value,"%s","LCM Hw:");
  868. DisplayValueToLcm(_Version_Dispenser_LCM_Text, (uint8_t *)value, sizeof(value));
  869. sprintf((char *)value,"%s","LED Fw:");
  870. DisplayValueToLcm(_Version_Dispenser_LED_Text, (uint8_t *)value, sizeof(value));
  871. sprintf((char *)value,"%s","Connector(0):");
  872. DisplayValueToLcm(_Version_Dispenser_Connector0_Text, (uint8_t *)value, sizeof(value));
  873. sprintf((char *)value,"%s","Connector(1):");
  874. DisplayValueToLcm(_Version_Dispenser_Connector1_Text, (uint8_t *)value, sizeof(value));
  875. sprintf((char *)value,"%s","IP Addr:");
  876. DisplayValueToLcm(_Version_Dispenser_IPAddr_Text, (uint8_t *)value, sizeof(value));
  877. }
  878. void ShowCabientVersion()
  879. {
  880. }
  881. void ShowDispenserVersion()
  882. {
  883. char value[32];
  884. memset(value, 0x00, sizeof(value));
  885. sprintf((char *)value,"%s",pSysConfig->ModelName);
  886. DisplayValueToLcm(_Version_Dispenser_Model_value, (uint8_t *)value, sizeof(value));
  887. sprintf((char *)value,"%s",pSysInfo->CsuBootLoadFwRev);
  888. DisplayValueToLcm(_Version_Dispenser_BootLoader_value, (uint8_t *)value, sizeof(value));
  889. sprintf((char *)value,"%s",pSysInfo->CsuKernelFwRev);
  890. DisplayValueToLcm(_Version_Dispenser_Kernel_value, (uint8_t *)value, sizeof(value));
  891. sprintf((char *)value,"%s",pSysInfo->CsuRootFsFwRev);
  892. DisplayValueToLcm(_Version_Dispenser_CSU_value, (uint8_t *)value, sizeof(value));
  893. sprintf((char *)value,"%s",pSysInfo->RelayModuleFwRev);
  894. DisplayValueToLcm(_Version_Dispenser_Relay_value, (uint8_t *)value, sizeof(value));
  895. sprintf((char *)value,"%s",pSysInfo->FanModuleFwRev);
  896. DisplayValueToLcm(_Version_Dispenser_Fan_value, (uint8_t *)value, sizeof(value));
  897. sprintf((char *)value,"%s",pSysInfo->CsuPrimFwRev);
  898. DisplayValueToLcm(_Version_Dispenser_Priamry_value, (uint8_t *)value, sizeof(value));
  899. sprintf((char *)value,"%s",pSysInfo->LcmHwRev);
  900. DisplayValueToLcm(_Version_Dispenser_LCM_value, (uint8_t *)value, sizeof(value));
  901. sprintf((char *)value,"%s",pSysInfo->LedModuleFwRev);
  902. DisplayValueToLcm(_Version_Dispenser_LED_value, (uint8_t *)value, sizeof(value));
  903. sprintf((char *)value,"%s",pSysInfo->Connector1FwRev);
  904. DisplayValueToLcm(_Version_Dispenser_Connector0_value, (uint8_t *)value, sizeof(value));
  905. sprintf((char *)value,"%s",pSysInfo->Connector2FwRev);
  906. DisplayValueToLcm(_Version_Dispenser_Connector1_value, (uint8_t *)value, sizeof(value));
  907. sprintf((char *)value,"%s",pSysConfig->Eth0Interface.EthIpAddress);
  908. DisplayValueToLcm(_Version_Dispenser_IPAddr_value, (uint8_t *)value, sizeof(value));
  909. }
  910. void InformationShow()
  911. {
  912. is_show = true;
  913. if (_showInformIndex == 0 ) {
  914. pSysInfo->PageIndex = __SHOW_CABIENT_VERSION;
  915. } else {
  916. pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION;
  917. ShowDispenserVersion();
  918. }
  919. }
  920. int main(void)
  921. {
  922. bool defaulttext = false;
  923. if (CreateAllCsuShareMemory() == FAIL) {
  924. log_error("create share memory error");
  925. return FAIL;
  926. }
  927. MappingGunChargingInfo("LCM Control Task");
  928. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  929. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  930. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  931. ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
  932. ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  933. ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  934. struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
  935. struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  936. struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  937. _port = CreateCommunicationLcmPort();
  938. uint8_t changeWarningPriority = 0;
  939. uint8_t curWarningCount = 255;
  940. ChangeBackLight(true);
  941. _totalCount = pSysConfig->TotalConnectorCount;
  942. _everyPageRollChange = 0;
  943. //Initialization();
  944. //printf("_LCM_COMPLETE ");
  945. //ChangeToOtherPage(_LCM_COMPLETE);
  946. //return 0;
  947. //uint8_t index = 5;
  948. while (_port != -1) {
  949. if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
  950. GetCurrentPage();
  951. sleep(1);
  952. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  953. } else {
  954. // Show Default Text
  955. if (!defaulttext) {
  956. ShowCabientVersionDefaultText();
  957. ShowDispenserVersionDefautlText();
  958. defaulttext = true;
  959. }
  960. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
  961. //pSysInfo->PageIndex = index;
  962. if(pSysConfig->TotalConnectorCount>=2) {
  963. if (pDcChargingInfo_0->SystemStatus == S_IDLE) {
  964. ChargeMaxPower_0 = 0;
  965. } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING) {
  966. if (pDcChargingInfo_0->PresentChargingPower > ChargeMaxPower_0 &&
  967. pDcChargingInfo_0->PresentChargingPower >= 0 &&
  968. pDcChargingInfo_0->PresentChargingPower <= POWER_MAX_KW)
  969. ChargeMaxPower_0 = pDcChargingInfo_0->PresentChargingPower;
  970. }
  971. if (pDcChargingInfo_1->SystemStatus == S_IDLE) {
  972. ChargeMaxPower_1 = 0;
  973. } else if (pDcChargingInfo_1->SystemStatus == S_CHARGING) {
  974. if (pDcChargingInfo_1->PresentChargingPower > ChargeMaxPower_1 &&
  975. pDcChargingInfo_1->PresentChargingPower >= 0 &&
  976. pDcChargingInfo_1->PresentChargingPower <= POWER_MAX_KW)
  977. ChargeMaxPower_1 = pDcChargingInfo_1->PresentChargingPower;
  978. }
  979. }
  980. // 頁面資訊處理
  981. ProcessPageInfo();
  982. // 換頁處理
  983. //GetCurrentPage(); //DS60-120 add
  984. if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _LCM_VIEW) {
  985. InformationShow();
  986. ChangeToOtherPage(pSysInfo->PageIndex);
  987. usleep(100000);
  988. continue;
  989. } else {
  990. if (is_show)
  991. _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
  992. is_show = false;
  993. }
  994. //GetCurrentPage(); //DS60-120 add
  995. //ChangeCurPage();
  996. /*
  997. GetCurrentPage();
  998. ChangeToOtherPage(index);
  999. GetCurrentPage();
  1000. DemoFunction();
  1001. index >= 22 ? index = 1 : index++;
  1002. */
  1003. //usleep(100000);
  1004. usleep(100000);
  1005. }
  1006. } //while
  1007. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1008. log_info("Close LCM Uart Port");
  1009. CloseCommunicationLcmPort();
  1010. return FAIL;
  1011. }