Module_LcmControl.c 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520
  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 "../CSU/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 OCPP16Data *ShmOCPP16Data = NULL;
  27. static struct FanModuleData *ShmFanModuleData;
  28. static struct PrimaryMcuData *ShmPrimaryMcuData;
  29. static SelectGunInfo *ShmSelectGunInfo = NULL;
  30. static struct ChargingInfoData *pDcChargingInfo = NULL;
  31. static DcCommonInfo *ShmDcCommonData = NULL;
  32. //int CardReadFd = -1;
  33. short _currentPage = _PAGE_NONE;
  34. uint8_t _totalCount;
  35. uint8_t _showInformIndex = 0;
  36. float ChargeMaxPower_0 = 0;
  37. float ChargeMaxPower_1 = 0;
  38. bool _battery_display_ani = false;
  39. int _port;
  40. //char* pPortName = "/dev/ttyO2";
  41. char *pPortName = "/dev/ttyS3";
  42. char *moduleName = "DMT80480T070_09WT";
  43. bool is_show = false;
  44. bool is_stop = false;
  45. uint8_t _everyPageRollChange;
  46. uint8_t _btn_press = 0;
  47. short _btn_press_id = 0;
  48. uint8_t _btn_press_count = 0;
  49. int _Text_Running_Count = 1;
  50. int Battery_Test = 0;
  51. extern void UpdateLcmFunction(DcCommonInfo *ShmDcCommonData,int _lcmport);
  52. //==========================================
  53. // Open and Close RS232 and R/W
  54. //==========================================
  55. void AuthorizingStart(void)
  56. {
  57. ShmOCPP16Data->SpMsg.bits.AuthorizeReq = YES;
  58. pSysInfo->AuthorizeFlag = YES;
  59. }
  60. void GetClockTime(struct timespec *_now_time, void *null)
  61. {
  62. clock_gettime(CLOCK_MONOTONIC, _now_time);
  63. }
  64. void StartSystemTimeoutDet(uint8_t flag)
  65. {
  66. if (pSysInfo->SystemTimeoutFlag != flag) {
  67. GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
  68. }
  69. pSysInfo->SystemTimeoutFlag = flag;
  70. }
  71. void StopSystemTimeoutDet(void)
  72. {
  73. GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
  74. pSysInfo->SystemTimeoutFlag = Timeout_None;
  75. }
  76. void StartGunInfoTimeoutDet(uint8_t gunIndex, uint8_t flag)
  77. {
  78. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  79. if (gunIndex < pSysConfig->TotalConnectorCount) {
  80. if (pDcChargingInfo->TimeoutFlag != flag) {
  81. gettimeofday(&pDcChargingInfo->TimeoutTimer, NULL);
  82. }
  83. pDcChargingInfo->TimeoutFlag = flag;
  84. }
  85. }
  86. void StopGunInfoTimeoutDet(uint8_t gunIndex)
  87. {
  88. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  89. if (gunIndex < pSysConfig->TotalConnectorCount) {
  90. pDcChargingInfo->TimeoutFlag = Timeout_None;
  91. }
  92. }
  93. unsigned long GetClockTimeoutValue(struct timespec _start_time)
  94. {
  95. struct timespec ts_end;
  96. unsigned long ret = 0;
  97. clock_gettime(CLOCK_MONOTONIC, &ts_end);
  98. ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000)));
  99. return ret;
  100. }
  101. int CreateCommunicationLcmPort()
  102. {
  103. int fd;
  104. struct termios tios;
  105. fd = open(pPortName, O_RDWR);
  106. if (fd <= 0) {
  107. log_error("open /dev/ttyS3 NG ");
  108. return -1;
  109. }
  110. ioctl(fd, TCGETS, &tios);
  111. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  112. tios.c_lflag = 0;
  113. tios.c_iflag = 0;
  114. tios.c_oflag = 0;
  115. tios.c_cc[VMIN] = 0;
  116. tios.c_cc[VTIME] = (uint8_t) 5;
  117. tios.c_lflag = 0;
  118. tcflush(fd, TCIFLUSH);
  119. ioctl(fd, TCSETS, &tios);
  120. return fd;
  121. }
  122. void CloseCommunicationLcmPort()
  123. {
  124. close(_port);
  125. }
  126. void setSelGunWaitToAuthor(uint8_t curSel)
  127. {
  128. if (curSel == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
  129. ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
  130. log_info("setSelGunWaitToAuthor left");
  131. } else if (curSel == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
  132. ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
  133. log_info("setSelGunWaitToAuthor right");
  134. }
  135. }
  136. void confirmSelGun(uint8_t selGun)
  137. {
  138. if (selGun == LEFT_GUN_NUM) {
  139. ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
  140. //printf("confirmSelGun left");
  141. } else if (selGun == RIGHT_GUN_NUM) {
  142. ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
  143. //printf("confirmSelGun right");
  144. }
  145. //changeLcmPage(_PAGE_PLUGIN);
  146. //StartGunInfoTimeoutDet(selGun, Timeout_SelectGun);
  147. //StartSystemTimeoutDet(Timeout_ReturnViewPage);
  148. }
  149. void GetDeviceInfoStatus(short address, uint8_t len)
  150. {
  151. uint8_t cmd[8];
  152. memset(cmd, 0x00, sizeof(cmd));
  153. uint8_t msg[11];
  154. memset(msg, 0x00, sizeof(msg));
  155. cmd[0] = CMD_TITLE_1;
  156. cmd[1] = CMD_TITLE_2;
  157. cmd[2] = 0x04;
  158. cmd[3] = CMD_MULTI_READ;
  159. cmd[4] = (address >> 8) & 0xff;
  160. cmd[5] = (address >> 0) & 0xff;
  161. cmd[6] = len;
  162. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  163. usleep(1000);
  164. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  165. }
  166. void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
  167. {
  168. int len = write(_port, cmd, cmdLen);
  169. if (len < sizeof(cmd)) {
  170. log_error("Write cmd to LCM Failure. ");
  171. }
  172. }
  173. void CheckIdlePress()
  174. {
  175. pSysInfo->SystemPage = _PAGE_SELECT_GUN;
  176. log_info("IDLE Enter Select Gun Page");
  177. }
  178. void CheckReturnPress()
  179. {
  180. int i;
  181. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  182. //pDcChargingInfo->SystemStatus = S_IDLE;
  183. StopSystemTimeoutDet();
  184. if ( pDcChargingInfo->SystemStatus == S_AUTHORIZING ) {
  185. ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
  186. ShmDcCommonData->PreAuth_Result = 0;
  187. for(i=0;i<=30;i++) {
  188. if(ShmDcCommonData->PreAuth_Result != 0)
  189. break;
  190. sleep(1);
  191. }
  192. ShmDcCommonData->PreAuth_Result = 0;
  193. pDcChargingInfo->SystemStatus = S_IDLE;
  194. strcpy((char *)pSysConfig->UserId, "");
  195. return;
  196. }
  197. if ( pSysInfo->SystemPage == _PAGE_EXIT ) {
  198. pDcChargingInfo->SystemStatus = S_IDLE;
  199. pSysInfo->SystemPage = _PAGE_IDLE;
  200. return;
  201. }
  202. pSysInfo->SystemPage = _PAGE_SELECT_GUN;
  203. }
  204. void CheckStopPress()
  205. {
  206. is_stop = TRUE;
  207. //ChangeDisplay2Value(_ConfirmStopIcon,is_stop);
  208. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  209. pSysInfo->SystemPage = _PAGE_STOP_CONFIRM_LEFT;
  210. else
  211. pSysInfo->SystemPage = _PAGE_STOP_CONFIRM_RIGHT;
  212. }
  213. void CheckStopConfirmPress()
  214. {
  215. int result;
  216. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  217. pDcChargingInfo->SystemStatus = S_TERMINATING;
  218. pSysInfo->SystemPage = _PAGE_PAYING;
  219. is_stop = FALSE;
  220. StartGunInfoTimeoutDet(pSysInfo->CurGunSelected,Timeout_FinalCost);
  221. /*
  222. ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
  223. ShmDcCommonData->PreAuth_Result = 0;
  224. */
  225. }
  226. void CheckStopCancelPress()
  227. {
  228. is_stop = FALSE;
  229. //ChangeDisplay2Value(_ConfirmStopIcon,is_stop);
  230. pSysInfo->SystemPage = _PAGE_CHARGING;
  231. }
  232. void CheckConfirmGun(uint8_t gunIndex)
  233. {
  234. pSysInfo->CurGunSelected = gunIndex;
  235. pSysInfo->SystemPage = _PAGE_BILL;
  236. }
  237. void CheckDonateBill(uint8_t gunIndex)
  238. {
  239. if (gunIndex == LEFT_GUN_NUM) {
  240. pSysInfo->SystemPage = _PAGE_DONATE_LEFT;
  241. } else
  242. pSysInfo->SystemPage = _PAGE_DONATE_RIGHT;
  243. }
  244. void CheckDonateYes()
  245. {
  246. pSysInfo->SystemPage = _PAGE_SELECT_PAY;
  247. ShmDcCommonData->donate_flag[pSysInfo->CurGunSelected] = TRUE;
  248. }
  249. void CheckDonateNo()
  250. {
  251. pSysInfo->SystemPage = _PAGE_BILL;
  252. ShmDcCommonData->donate_flag[pSysInfo->CurGunSelected] = FALSE;
  253. }
  254. void CheckPayCreditCard()
  255. {
  256. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  257. if (pDcChargingInfo->SystemStatus == S_IDLE) {
  258. confirmSelGun(pSysInfo->CurGunSelected);
  259. setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
  260. pSysInfo->SystemPage = _PAGE_AUTHORIZE;
  261. //pDcChargingInfo->SystemStatus = S_AUTHORIZING;
  262. //
  263. AuthorizingStart();
  264. }
  265. }
  266. void CheckPayIcash()
  267. {
  268. }
  269. void CheckPayLinePay()
  270. {
  271. }
  272. void CheckTouchPress(short id)
  273. {
  274. GetDeviceInfoStatus(id,1);
  275. if (_btn_press >= 1 && _btn_press_id == id ) {
  276. _btn_press_count++;
  277. }
  278. if (_btn_press >= 1 && _btn_press_id == id && _btn_press_count >= 3) {
  279. ChangeDisplay2Value(id, 0);
  280. //log_info("Press id : 0x%04x",id);
  281. _btn_press_count = 0;
  282. switch (id) {
  283. case _Touch_Show_Left:
  284. if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_PLUGIN) {
  285. log_info("Authorize Process can't select gun");
  286. return;
  287. }
  288. // Show log
  289. if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
  290. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  291. pSysInfo->CurGunSelected = LEFT_GUN_NUM;
  292. if(pDcChargingInfo->SystemStatus == S_IDLE) {
  293. pSysInfo->SystemPage = _PAGE_SELECT_GUN;
  294. }
  295. log_info("LCM left Gun down...............................%x %x %x",
  296. pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
  297. }
  298. /*
  299. if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE) {
  300. StopSystemTimeoutDet();
  301. StartSystemTimeoutDet(Timeout_ReturnViewPage);
  302. }*/
  303. break;
  304. case _Touch_Show_Right:
  305. if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
  306. log_info("Authorize Page can't select gun");
  307. return;
  308. }
  309. // Show log
  310. if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
  311. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  312. pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
  313. if(pDcChargingInfo->SystemStatus == S_IDLE) {
  314. pSysInfo->SystemPage = _PAGE_SELECT_GUN;
  315. }
  316. log_info("LCM Right Gun down...............................%x %x %x",
  317. pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
  318. }
  319. /*
  320. if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE) {
  321. StopSystemTimeoutDet();
  322. StartSystemTimeoutDet(Timeout_ReturnViewPage);
  323. }
  324. */
  325. break;
  326. case _Touch_Return:
  327. CheckReturnPress();
  328. break;
  329. case _Touch_IDLE:
  330. CheckIdlePress();
  331. break;
  332. case _Touch_StopCharge:
  333. CheckStopPress();
  334. is_stop = TRUE;
  335. break;
  336. case _Touch_Stop_Confirm:
  337. CheckStopConfirmPress();
  338. is_stop = FALSE;
  339. break;
  340. case _Touch_Stop_Cancel:
  341. CheckStopCancelPress();
  342. is_stop = FALSE;
  343. break;
  344. case _Touch_Select_Left:
  345. CheckConfirmGun(LEFT_GUN_NUM);
  346. break;
  347. case _Touch_Select_Right:
  348. CheckConfirmGun(RIGHT_GUN_NUM);
  349. break;
  350. case _Touch_DonateBill:
  351. StopSystemTimeoutDet();
  352. CheckDonateBill(pSysInfo->CurGunSelected);
  353. break;
  354. case _Touch_DonateYes:
  355. CheckDonateYes();
  356. break;
  357. case _Touch_DonateNo:
  358. StartSystemTimeoutDet(Timeout_AddLine);
  359. CheckDonateNo();
  360. break;
  361. case _Touch_Pay_CreditCard:
  362. CheckPayCreditCard();
  363. break;
  364. case _Touch_Pay_Icash:
  365. CheckPayIcash();
  366. break;
  367. case _Touch_Pay_LinePay:
  368. CheckPayLinePay();
  369. break;
  370. } // switch
  371. } //if (_btn_press >= 3)
  372. }
  373. void CheckLCMPressed()
  374. {
  375. int i;
  376. pid_t Pid = fork();
  377. if ( Pid == 0 ) {
  378. while (1) {
  379. if (pSysInfo->SystemPage != _PAGE_SELECT_GUN) {
  380. CheckTouchPress(_Touch_Show_Left);
  381. CheckTouchPress(_Touch_Show_Right);
  382. }
  383. switch (pSysInfo->SystemPage) {
  384. case _PAGE_IDLE:
  385. CheckTouchPress(_Touch_IDLE);
  386. break;
  387. case _PAGE_SELECT_GUN:
  388. CheckTouchPress(_Touch_Select_Left);
  389. CheckTouchPress(_Touch_Select_Right);
  390. break;
  391. case _PAGE_BILL:
  392. CheckTouchPress(_Touch_Return);
  393. CheckTouchPress(_Touch_DonateBill);
  394. break;
  395. case _PAGE_ADD_FRIEND:
  396. CheckTouchPress(_Touch_Return);
  397. CheckTouchPress(_Touch_DonateBill);
  398. break;
  399. case _PAGE_DONATE_LEFT:
  400. case _PAGE_DONATE_RIGHT:
  401. CheckTouchPress(_Touch_Return);
  402. CheckTouchPress(_Touch_DonateYes);
  403. CheckTouchPress(_Touch_DonateNo);
  404. break;
  405. case _PAGE_SELECT_PAY:
  406. CheckTouchPress(_Touch_Return);
  407. CheckTouchPress(_Touch_Pay_CreditCard);
  408. break;
  409. case _PAGE_PLUGIN:
  410. CheckTouchPress(_Touch_Return);
  411. break;
  412. ///*
  413. case _PAGE_CHARGING:
  414. CheckTouchPress(_Touch_StopCharge);
  415. break;
  416. case _PAGE_AUTHORIZE:
  417. CheckTouchPress(_Touch_Return);
  418. break;
  419. case _PAGE_STOP_CONFIRM_LEFT:
  420. case _PAGE_STOP_CONFIRM_RIGHT:
  421. StopSystemTimeoutDet();
  422. CheckTouchPress(_Touch_Stop_Confirm);
  423. CheckTouchPress(_Touch_Stop_Cancel);
  424. break;
  425. case _PAGE_EXIT:
  426. CheckTouchPress(_Touch_Return);
  427. break;
  428. case _PAGE_AUTHORIZE_FAIL:
  429. CheckTouchPress(_Touch_Return);
  430. break;
  431. } // switch
  432. usleep(5000);
  433. } //while
  434. } // if pid
  435. log_info("Create LCM fork:%d",Pid);
  436. }
  437. void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
  438. {
  439. read(_port, msg, readLen);
  440. // 5a : CMD_TITLE_1
  441. // a5 : CMD_TITLE_2
  442. // 5
  443. // 81 : CMD_WRITE
  444. // 3 : CMD_REGISTER
  445. // 2 : Data length
  446. // 0 : High byte
  447. // 1 : Low byte
  448. // printf("-------------------------------------------- \n");
  449. // printf("msg = %x \n", *msg); // A5
  450. // printf("msg = %x \n", *(msg + 1)); // 5A
  451. // printf("msg = %x \n", *(msg + 2)); // Len : [3] ~ [6] + Data Len
  452. // printf("msg = %x \n", *(msg + 3)); // cmd : 0x83
  453. // printf("msg = %x \n", *(msg + 4)); // addr : H
  454. // printf("msg = %x \n", *(msg + 5)); // addr : L
  455. // printf("msg = %x \n", *(msg + 6)); // Data Len
  456. //
  457. // printf("msg = %x \n", *(msg + 7));
  458. // printf("msg = %x \n", *(msg + 8));
  459. // printf("msg = %x \n", *(msg + 9));
  460. // printf("msg = %x \n", *(msg + 10));
  461. // printf("msg = %x \n", *(msg + 11));
  462. // printf("msg = %x \n", *(msg + 12));
  463. // printf("msg = %x \n", *(msg + 13));
  464. // printf("msg = %x \n", *(msg + 14));
  465. /*
  466. for(uint8_t i = 0 ; i<readLen+3; i++) {
  467. log_info("Read data[%d]:0x%x",i,msg[i]);
  468. }*/
  469. if(*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2)
  470. {
  471. if(*(msg + 3) == CMD_WRITE)
  472. {
  473. switch (*(msg + 4))
  474. {
  475. case CMD_REGISTER:
  476. {
  477. // 頁面
  478. if(strcmp((char *)pSysInfo->LcmHwRev, "") != EQUAL)
  479. strcpy((char *)pSysInfo->LcmHwRev, moduleName);
  480. _currentPage = *(msg + 7);
  481. log_info("Current Page:%d",_currentPage);
  482. // if (_currentPage != 1 && _currentPage != 5 && _currentPage != 6 && _currentPage != 7 && _currentPage != 8)
  483. // printf("_currentPage = %d \n", _currentPage);
  484. }
  485. break;
  486. }
  487. }
  488. else if (*(msg + 3) == CMD_MULTI_READ)
  489. {
  490. short key = ((short)(*(msg + 4) << 8) + *(msg + 5));
  491. if(strcmp((char *)pSysInfo->LcmHwRev, "") != EQUAL)
  492. strcpy((char *)pSysInfo->LcmHwRev, moduleName);
  493. if (key == 0x0014)
  494. _currentPage = *(msg + 8);
  495. if ( key >= _Touch_IDLE && key <=_Touch_Pay_LinePay ) {
  496. _btn_press_id = key;
  497. _btn_press = *(msg + 8);
  498. }
  499. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  500. // {
  501. // case BUTTON_GUN_INDEX:
  502. // {
  503. // // 當前選的槍號
  504. // _curGunIndex = (*(msg + 8));
  505. // }
  506. // break;
  507. // }
  508. }
  509. }
  510. }
  511. void GetHrFormTimeString(char* time,char* hr)
  512. {
  513. //char tm[] = "2021-12-06 17:29:08:084";
  514. for(int i = 0 ; i < 2 ; i++) {
  515. hr[i] = time[i+11];
  516. }
  517. if( atoi(hr) == NULL ) {
  518. strcmp(hr,"");
  519. }
  520. }
  521. void GetMinFormTimeString(char* time,char* min)
  522. {
  523. //char tm[] = "2021-12-06 17:29:08:084";
  524. for(int i = 0 ; i < 2 ; i++) {
  525. min[i] = time[i+14];
  526. }
  527. if( atoi(min) == NULL || atoi(min) > 60) {
  528. strcmp(min,"");
  529. }
  530. }
  531. //================================================
  532. // Function
  533. //================================================
  534. void ChangeToOtherPage(short newPage)
  535. {
  536. uint8_t cmd[10];
  537. memset(cmd, 0x00, sizeof(cmd));
  538. uint8_t msg[9];
  539. memset(msg, 0x00, sizeof(msg));
  540. cmd[0] = CMD_TITLE_1;
  541. cmd[1] = CMD_TITLE_2;
  542. cmd[2] = 0x07;
  543. cmd[3] = 0x82;
  544. cmd[4] = 0x00;
  545. cmd[5] = 0x84;
  546. cmd[6] = 0x5A;
  547. cmd[7] = 0x01;
  548. cmd[8] = newPage >> 8;
  549. cmd[9] = newPage & 0x00FF;
  550. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  551. usleep(5000);
  552. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  553. }
  554. void ChangeBackLight(bool islight)
  555. {
  556. uint8_t value = 0x01;
  557. uint8_t msg[9];
  558. memset(msg, 0x00, sizeof(msg));
  559. // 0x00 ~ 0x40
  560. if (islight)
  561. {
  562. value = 0x20;
  563. }
  564. uint8_t cmd[7];
  565. memset(cmd, 0x00, sizeof(cmd));
  566. cmd[0] = CMD_TITLE_1;
  567. cmd[1] = CMD_TITLE_2;
  568. cmd[2] = 0x03;
  569. cmd[3] = CMD_READ;
  570. cmd[4] = CMD_BACKLIGHT;
  571. cmd[5] = value;
  572. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  573. usleep(10000);
  574. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  575. }
  576. void GetCurrentPage()
  577. {
  578. uint8_t cmd[7];
  579. memset(cmd, 0x00, sizeof(cmd));
  580. uint8_t msg[9];
  581. memset(msg, 0x00, sizeof(msg));
  582. cmd[0] = CMD_TITLE_1;
  583. cmd[1] = CMD_TITLE_2;
  584. cmd[2] = 0x04; // 底下總長度
  585. cmd[3] = 0x83;
  586. cmd[4] = 0x00;
  587. cmd[5] = 0x14;
  588. cmd[6] = 0x01;
  589. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  590. usleep(5000);
  591. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  592. }
  593. void DisplayValueToLcm(short address, uint8_t *data, uint8_t len)
  594. {
  595. uint8_t cmd[256];
  596. memset(cmd, 0x00, sizeof(cmd));
  597. uint8_t msg[9];
  598. memset(msg, 0x00, sizeof(msg));
  599. cmd[0] = CMD_TITLE_1;
  600. cmd[1] = CMD_TITLE_2;
  601. cmd[2] = 0x03 + len;
  602. cmd[3] = CMD_MULTI_WRITE;
  603. cmd[4] = address >> 8;
  604. cmd[5] = address & 0x00FF;
  605. for(uint8_t count = 0; count < len; count++)
  606. {
  607. cmd[6 + count] = *(data + count);
  608. }
  609. WriteCmdToLcm(cmd, cmd[2] + 3);
  610. usleep(10000);
  611. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  612. }
  613. void ChangeDisplay2Value(short address, short value)
  614. {
  615. uint8_t data[2];
  616. data[0] = value >> 8;
  617. data[1] = value & 0x00FF;
  618. //log_info("Addr:0x%x, value:%d",address,value);
  619. DisplayValueToLcm(address, data, sizeof(data));
  620. }
  621. //================================================
  622. // Warning process
  623. //================================================
  624. void string2ByteArray(uint8_t *input, uint8_t *output)
  625. {
  626. int loop;
  627. int i;
  628. loop = 0;
  629. i = 0;
  630. while (input[loop] != '\0') {
  631. output[i++] = input[loop++];
  632. }
  633. output[loop] = '\0';
  634. }
  635. void RefreshProgressAnimation()
  636. {
  637. _everyPageRollChange >= 20 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  638. }
  639. //================================================
  640. // Change current page
  641. //================================================
  642. void ChangeCurPage()
  643. {
  644. //log_info("cur = %d ,system = %d, lcm = %d ",_currentPage, pSysInfo->SystemPage, pSysInfo->PageIndex);
  645. pSysInfo->PageIndex = pSysInfo->SystemPage;
  646. if (_currentPage != pSysInfo->PageIndex) {
  647. switch (pSysInfo->SystemPage) {
  648. case _PAGE_AUTHORIZE:
  649. break;
  650. case _PAGE_PLUGIN:
  651. break;
  652. case _PAGE_PRECHARGE:
  653. break;
  654. case _PAGE_CHARGING:
  655. is_stop = false;
  656. break;
  657. case _PAGE_COMPLETE:
  658. break;
  659. }
  660. _currentPage = pSysInfo->PageIndex;
  661. //log_info("Chagne Page:%d",pSysInfo->PageIndex);
  662. ChangeToOtherPage(pSysInfo->PageIndex);
  663. }
  664. }
  665. /*
  666. * View Page
  667. *
  668. */
  669. unsigned long GetTimeoutValue(struct timeval _sour_time)
  670. {
  671. struct timeval _end_time;
  672. gettimeofday(&_end_time, NULL);
  673. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  674. }
  675. void showGunWorkingType()
  676. {
  677. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  678. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  679. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  680. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  681. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_On);
  682. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  683. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  684. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_On);
  685. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  686. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_On);
  687. }
  688. // Set Right Gun
  689. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  690. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  691. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  692. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_Off);
  693. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  694. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  695. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_Off);
  696. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  697. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off);
  698. }
  699. } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM){
  700. // Left Gun
  701. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  702. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  703. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  704. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_Off);
  705. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  706. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  707. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_Off);
  708. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  709. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_Off);
  710. }
  711. // Right Gun
  712. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  713. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  714. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  715. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_On);
  716. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  717. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  718. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_On);
  719. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  720. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_On);
  721. }
  722. }
  723. }
  724. void ClearQrCode()
  725. {
  726. char cmd[200];
  727. memset(cmd,0,200);
  728. DisplayValueToLcm(_QRCode_AddLine, cmd, 200);
  729. }
  730. void ChangeQrCode_Idle(char *input)
  731. {
  732. char cmd[256];
  733. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  734. // https://nhoatcc.lineapid.tw/web/tologin?sn=ABC123&cid=2
  735. memset(cmd,0,256);
  736. int len = sprintf(cmd,"https://nhoatcc.lineapid.tw/web/tologin?sn=%s&cid=%d",input,ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]);
  737. //log_info("QR Code:URL:%s",cmd);
  738. if (pSysInfo->SystemPage == _PAGE_BILL)
  739. DisplayValueToLcm(_QRCode_AddLine, cmd, len+1);
  740. }
  741. /*
  742. void ChangeRemainTime(int sec)
  743. {
  744. int h, m, s;
  745. uint8_t cmd[10];
  746. uint8_t value[10];
  747. memset(cmd, 0x00, sizeof(cmd));
  748. // srand(time(NULL));
  749. // int min = 0;
  750. // int max = 65536;
  751. // sec = rand() % (max - min + 1) + min;
  752. h = (sec / 3600);
  753. m = (sec - (3600 * h)) / 60;
  754. s = (sec - (3600 * h) - (m * 60));
  755. sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
  756. string2ByteArray(value, cmd);
  757. DisplayValueToLcm(_Text_Time, cmd, sizeof(cmd));
  758. }
  759. */
  760. void ChangeChargingPowerValue(float pow)
  761. {
  762. uint8_t cmd[10];
  763. uint8_t value[10];
  764. memset(cmd, 0x00, sizeof(cmd));
  765. sprintf((char *) value, "%d",(int)pow);
  766. string2ByteArray(value, cmd);
  767. DisplayValueToLcm(_String_ChargePower, cmd, sizeof(cmd));
  768. }
  769. void ChangeChargingFeeValue(float fee)
  770. {
  771. uint8_t cmd[10];
  772. uint8_t value[10];
  773. memset(cmd, 0x00, sizeof(cmd));
  774. sprintf((char *) value, "%d", (int)fee);
  775. string2ByteArray(value, cmd);
  776. DisplayValueToLcm(_String_Money, cmd, sizeof(cmd));
  777. }
  778. void ChangeCarBonValue(float data)
  779. {
  780. uint8_t cmd[10];
  781. uint8_t value[10];
  782. float _carbon = 0;
  783. memset(cmd, 0x00, sizeof(cmd));
  784. _carbon = (data*9)/10*2.36 - data*0.637;
  785. sprintf((char *) value, "%d", (int)_carbon);
  786. string2ByteArray(value, cmd);
  787. DisplayValueToLcm(_String_Carbon, cmd, sizeof(cmd));
  788. }
  789. void ChangeChargingEnergyValue(float energy)
  790. {
  791. uint8_t cmd[10];
  792. uint8_t value[10];
  793. memset(cmd, 0x00, sizeof(cmd));
  794. if (energy >= 0.05) {
  795. energy -= 0.05;
  796. }
  797. if (energy < 0 )
  798. ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0);
  799. else if (energy > 100)
  800. ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0+100);
  801. else
  802. ChangeDisplay2Value(_Icon_ChargeBar,(int)energy+_TCC_Charging_Bar0);
  803. sprintf((char *) value, "%.1f", energy);
  804. string2ByteArray(value, cmd);
  805. DisplayValueToLcm(_Strting_Energy, cmd, sizeof(cmd));
  806. }
  807. uint8_t _battery_display_count = 0;
  808. void ChangeBattMapAndValue(int soc)
  809. {
  810. int i = (soc*36)/100;
  811. uint8_t cmd[5];
  812. uint8_t value[5];
  813. _battery_display_count++;
  814. if (_battery_display_count == 3 ) {
  815. if (_battery_display_ani == 0)
  816. _battery_display_ani= TRUE;
  817. else
  818. _battery_display_ani= FALSE ;
  819. _battery_display_count = 0;
  820. }
  821. if (pSysInfo->SystemPage == _PAGE_CHARGING) {
  822. if (i>=36)
  823. ChangeDisplay2Value(_Icon_ChargeCircle,_TCC_Charging_Circle0+36);
  824. else {
  825. if (_battery_display_ani) {
  826. ChangeDisplay2Value(_Icon_ChargeCircle, _TCC_Charging_Circle0+i);
  827. } else {
  828. ChangeDisplay2Value(_Icon_ChargeCircle, _TCC_Charging_Circle0+i+1);
  829. }
  830. }
  831. } else if (pSysInfo->SystemPage == _PAGE_COMPLETE)
  832. ChangeDisplay2Value(_Icon_CompleteCircle, _TCC_CompleteCircle0+i);
  833. else
  834. ChangeDisplay2Value(_Icon_CompleteCircle, _TCC_CompleteCircle0+i);
  835. memset(cmd, 0x00, sizeof(cmd));
  836. memset(value, 0x00, sizeof(value));
  837. sprintf((char *)value, "%d", soc);
  838. string2ByteArray(value, cmd);
  839. DisplayValueToLcm(_String_Battery, cmd, sizeof(cmd));
  840. }
  841. unsigned long GetPreChargeTimeoutValue(struct timeval _sour_time)
  842. {
  843. struct timeval _end_time;
  844. gettimeofday(&_end_time, NULL);
  845. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  846. }
  847. void ChangeTimeValue(int time)
  848. {
  849. uint8_t cmd[6];
  850. uint8_t value[6];
  851. memset(cmd, 0x00, sizeof(cmd));
  852. sprintf((char *) value, "%d", time);
  853. string2ByteArray(value, cmd);
  854. DisplayValueToLcm(_String_ChargeTime, cmd, sizeof(cmd));
  855. }
  856. void changeWeatherValue(int _weather)
  857. {
  858. switch (_weather) {
  859. case _WEATHER_TYPE_SUN:
  860. ChangeDisplay2Value(_Icon_Weather,_TCC_Sun);
  861. break;
  862. case _WEATHER_TYPE_CLOUDY:
  863. ChangeDisplay2Value(_Icon_Weather,_TCC_Cloudy);
  864. break;
  865. case _WEATHER_TYPE_RAIN:
  866. ChangeDisplay2Value(_Icon_Weather,_TCC_Rain);
  867. break;
  868. case _WEATHER_TYPE_THUNDER:
  869. ChangeDisplay2Value(_Icon_Weather,_TCC_Thunder);
  870. break;
  871. case _WEATHER_TYPE_SNOW:
  872. ChangeDisplay2Value(_Icon_Weather,_TCC_Snow);
  873. break;
  874. case _WEATHER_TYPE_FOG:
  875. ChangeDisplay2Value(_Icon_Weather,_TCC_Fog);
  876. break;
  877. }
  878. }
  879. void changeWeekValue(int _week)
  880. {
  881. time_t t = time(NULL);
  882. struct tm *now = localtime(&t);
  883. _week = now->tm_wday;
  884. if (_week == 0 )
  885. _week = 7;
  886. ChangeDisplay2Value(_Icon_Week,_week);
  887. }
  888. void changeDegreeValue(int _degree)
  889. {
  890. char value[16];
  891. memset(value, 0x00, sizeof(value));
  892. sprintf((char *)value,"%d",_degree);
  893. DisplayValueToLcm(_String_Tempture, (uint8_t *)value, sizeof(value));
  894. }
  895. void changeDateValue(char* _date)
  896. {
  897. char value[16];
  898. memset(value, 0x00, sizeof(value));
  899. sprintf((char *)value,"%s",_date);
  900. DisplayValueToLcm(_String_Date, (uint8_t *)value, sizeof(value));
  901. }
  902. void changeLocationValue(int _location)
  903. {
  904. //_location+=1000;
  905. //log_info("location:%d",_location);
  906. ChangeDisplay2Value(_Icon_Location,(short)_location);
  907. }
  908. int old_money = 0;
  909. int ClearQR_flag[2];
  910. void ProcessPageInfo()
  911. {
  912. // Show Gun Working and Type
  913. if (pSysInfo->SystemPage == _PAGE_IDLE) {
  914. changeWeatherValue(ShmDcCommonData->WeatherID);
  915. changeWeekValue(0);
  916. changeDegreeValue((int)ShmDcCommonData->Temperature);
  917. changeDateValue(&ShmDcCommonData->PresentTime[0]);
  918. changeLocationValue(ShmDcCommonData->Location);
  919. return;
  920. }
  921. if (pSysInfo->SystemPage == _PAGE_MAINTAIN) {
  922. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  923. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  924. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  925. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_Off);
  926. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  927. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  928. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_Off);
  929. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  930. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_Off);
  931. }
  932. // Set Right Gun
  933. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  934. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  935. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  936. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_Off);
  937. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  938. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  939. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_Off);
  940. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  941. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off);
  942. }
  943. return;
  944. }
  945. showGunWorkingType();
  946. for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
  947. if (pSysInfo->CurGunSelected == i) {
  948. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  949. switch (pSysInfo->SystemPage) {
  950. case _PAGE_IDLE:
  951. break;
  952. case _PAGE_SELECT_PAY:
  953. if (ShmDcCommonData->donate_flag == TRUE) {
  954. ChangeDisplay2Value(_Icon_WordAddFriend,_ICON_Empty);
  955. } else
  956. ChangeDisplay2Value(_Icon_WordAddFriend,_TCC_SelectPayMode);
  957. StartSystemTimeoutDet(Timeout_SelectPayMode);
  958. break;
  959. case _PAGE_SELECT_GUN:
  960. ClearQR_flag[i] = FALSE;
  961. break;
  962. case _PAGE_BILL:
  963. if(ClearQR_flag[i] == FALSE) {
  964. ClearQrCode();
  965. ClearQR_flag[i] = TRUE;
  966. }
  967. ChangeQrCode_Idle((char *)pSysConfig->SystemId);
  968. break;
  969. case _PAGE_AUTHORIZE:
  970. /*
  971. int card_result = CreditCardPreAuth(CardReadFd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
  972. if (card_result > 0 ) {
  973. strcpy((char *)pSysConfig->UserId, (char *)ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo);
  974. } else if (card_result < 0) {
  975. pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  976. }*/
  977. //ChangeDisplay2Value(_Icon_Precharge,0);
  978. //ChangeDisplay2Value(_Icon_Precharge,1);
  979. _Text_Running_Count = 1;
  980. break;
  981. case _PAGE_PLUGIN:
  982. _everyPageRollChange = 0;
  983. break;
  984. case _PAGE_PRECHARGE:
  985. //ChangeDisplay2Value(_Icon_Precharge,1);
  986. RefreshProgressAnimation();
  987. if (_everyPageRollChange == 0) {
  988. ChangeDisplay2Value(_Icon_Precharge,_Text_Running_Count);
  989. _Text_Running_Count >= 24 ? _Text_Running_Count = 24 : _Text_Running_Count++;
  990. }
  991. break;
  992. case _PAGE_CHARGING:
  993. if (pDcChargingInfo->PresentChargingPower >= 0 &&
  994. pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  995. ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower);
  996. } else {
  997. ChangeChargingPowerValue(0);
  998. }
  999. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1000. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1001. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1002. } else {
  1003. ChangeChargingEnergyValue(0);
  1004. }
  1005. if ( pDcChargingInfo->ChargingFee >= 0) {
  1006. ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
  1007. }
  1008. if (pDcChargingInfo->RemainChargingDuration >= 0 &&
  1009. pDcChargingInfo->RemainChargingDuration <= TIME_MAX_SEC) {
  1010. ChangeTimeValue(pDcChargingInfo->RemainChargingDuration/60);
  1011. } else {
  1012. ChangeTimeValue(0);
  1013. }
  1014. ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
  1015. //StartSystemTimeoutDet(Timeout_ReturnViewPage);
  1016. break;
  1017. case _PAGE_COMPLETE:
  1018. case _PAGE_PAYFAIL:
  1019. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1020. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1021. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1022. } else {
  1023. ChangeChargingEnergyValue(0);
  1024. }
  1025. if ( ShmDcCommonData->finalcost[i] >= 0 && ShmDcCommonData->finalcost_flag[i] == TRUE) {
  1026. StopGunInfoTimeoutDet(i);
  1027. ChangeChargingFeeValue(ShmDcCommonData->finalcost[i]);
  1028. ShmDcCommonData->finalcost_flag[i] = FALSE;
  1029. }
  1030. ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy);
  1031. ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
  1032. //StartSystemTimeoutDet(Timeout_ReturnViewPage);
  1033. break;
  1034. case _PAGE_PLUGOUT:
  1035. /*
  1036. if (pSysConfig->isQRCode) {
  1037. if (pSysConfig->QRCodeMadeMode == NO) {
  1038. //uint8_t len = strlen((char *)pSysConfig->SystemId);
  1039. ChangeQrCode_Idle((char *)pSysConfig->SystemId);
  1040. } else {
  1041. //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
  1042. ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
  1043. }
  1044. //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
  1045. }*/
  1046. break;
  1047. case _PAGE_PAYING:
  1048. break;
  1049. }
  1050. }
  1051. }
  1052. }
  1053. void ChangeWarningFunc()
  1054. {
  1055. uint8_t cmd[7] = {0};
  1056. uint8_t i = 0;
  1057. //uint8_t j = 0;
  1058. //log_info("ChangeWarningFunc ");
  1059. // 最多一次五筆
  1060. //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
  1061. //log_info("WarningCount = %d ", pSysWarning->WarningCount);
  1062. //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  1063. for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
  1064. log_info("Warming Code[%d]:%s",i,&pSysWarning->WarningCode[i][0]);
  1065. memset(cmd, 0x00, sizeof(cmd));
  1066. if ((i) >= 5) {
  1067. break;
  1068. }
  1069. //error code
  1070. string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
  1071. DisplayValueToLcm(_Strting_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1072. //警告標示
  1073. memset(cmd, 0x00, sizeof(cmd));
  1074. cmd[0] = 0x00;
  1075. cmd[1] = 1;
  1076. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1077. }
  1078. memset(cmd, 0x00, sizeof(cmd));
  1079. for (; i < 5; i++) {
  1080. DisplayValueToLcm(_Strting_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1081. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1082. }
  1083. }
  1084. void ShowCabientVersionDefaultText()
  1085. {
  1086. char value[16];
  1087. memset(value, 0x00, sizeof(value));
  1088. sprintf((char *)value,"%s","Cabient:");
  1089. DisplayValueToLcm(_Version_Cabient_Name_Text, (uint8_t *)value, sizeof(value));
  1090. sprintf((char *)value,"%s","BootLoader:");
  1091. DisplayValueToLcm(_Version_Cabient_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1092. sprintf((char *)value,"%s","Kernel Fw:");
  1093. DisplayValueToLcm(_Version_Cabient_Kernel_Text, (uint8_t *)value, sizeof(value));
  1094. sprintf((char *)value,"%s","CSU Fw:");
  1095. DisplayValueToLcm(_Version_Cabient_CSU_Text, (uint8_t *)value, sizeof(value));
  1096. sprintf((char *)value,"%s","Priamry Fw:");
  1097. DisplayValueToLcm(_Version_Cabient_Priamry_Text, (uint8_t *)value, sizeof(value));
  1098. sprintf((char *)value,"%s","Relay(0) Fw:");
  1099. DisplayValueToLcm(_Version_Cabient_Relay0_Text, (uint8_t *)value, sizeof(value));
  1100. sprintf((char *)value,"%s","Relay(1) Fw:");
  1101. DisplayValueToLcm(_Version_Cabient_Relay1_Text, (uint8_t *)value, sizeof(value));
  1102. sprintf((char *)value,"%s","Fan Fw:");
  1103. DisplayValueToLcm(_Version_Cabient_Fan_Text, (uint8_t *)value, sizeof(value));
  1104. sprintf((char *)value,"%s","IP Addr:");
  1105. DisplayValueToLcm(_Version_Cabient_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1106. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number <= 12) {
  1107. sprintf((char *)value,"%s","Primary");
  1108. DisplayValueToLcm(_Version_Cabient_Primary_Text, (uint8_t *)value, sizeof(value));
  1109. sprintf((char *)value,"%s","Secondary");
  1110. DisplayValueToLcm(_Version_Cabient_Secondary_Text, (uint8_t *)value, sizeof(value));
  1111. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1112. sprintf((char *)value,"PSU(%d):",i+1);
  1113. DisplayValueToLcm(_Version_Cabient_PSU1_Text+i*0x10, (uint8_t *)value, sizeof(value));
  1114. }
  1115. }
  1116. }
  1117. void ShowDispenserVersionDefautlText()
  1118. {
  1119. char value[16];
  1120. memset(value, 0x00, sizeof(value));
  1121. sprintf((char *)value,"%s","Dispenser:");
  1122. DisplayValueToLcm(_Version_Dispenser_Name_Text, (uint8_t *)value, sizeof(value));
  1123. sprintf((char *)value,"%s","BootLoader:");
  1124. DisplayValueToLcm(_Version_Dispenser_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1125. sprintf((char *)value,"%s","Kernel Fw:");
  1126. DisplayValueToLcm(_Version_Dispenser_Kernel_Text, (uint8_t *)value, sizeof(value));
  1127. sprintf((char *)value,"%s","CSU Fw:");
  1128. DisplayValueToLcm(_Version_Dispenser_CSU_Text, (uint8_t *)value, sizeof(value));
  1129. sprintf((char *)value,"%s","Relay Fw:");
  1130. DisplayValueToLcm(_Version_Dispenser_Relay_Text, (uint8_t *)value, sizeof(value));
  1131. sprintf((char *)value,"%s","Fan Fw:");
  1132. DisplayValueToLcm(_Version_Dispenser_Fan_Text, (uint8_t *)value, sizeof(value));
  1133. sprintf((char *)value,"%s","Prim Fw:");
  1134. DisplayValueToLcm(_Version_Dispenser_Priamry_Text, (uint8_t *)value, sizeof(value));
  1135. sprintf((char *)value,"%s","LCM Hw:");
  1136. DisplayValueToLcm(_Version_Dispenser_LCM_Text, (uint8_t *)value, sizeof(value));
  1137. sprintf((char *)value,"%s","LED Fw:");
  1138. DisplayValueToLcm(_Version_Dispenser_LED_Text, (uint8_t *)value, sizeof(value));
  1139. sprintf((char *)value,"%s","Connector(0):");
  1140. DisplayValueToLcm(_Version_Dispenser_Connector0_Text, (uint8_t *)value, sizeof(value));
  1141. sprintf((char *)value,"%s","Connector(1):");
  1142. DisplayValueToLcm(_Version_Dispenser_Connector1_Text, (uint8_t *)value, sizeof(value));
  1143. sprintf((char *)value,"%s","IP Addr:");
  1144. DisplayValueToLcm(_Version_Dispenser_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1145. }
  1146. void ShowCabientVersion()
  1147. {
  1148. char value[16];
  1149. memset(value, 0x00, sizeof(value));
  1150. sprintf((char *)value,"%s",ShmDcCommonData->CabinetModelName);
  1151. DisplayValueToLcm(_Version_Cabient_Model_value, (uint8_t *)value, sizeof(value));
  1152. sprintf((char *)value,"%s",ShmDcCommonData->CabinetBoolLoaderVersion);
  1153. DisplayValueToLcm(_Version_Cabient_BootLoader_value, (uint8_t *)value, sizeof(value));
  1154. sprintf((char *)value,"%s",ShmDcCommonData->CabinetKernelVersion);
  1155. DisplayValueToLcm(_Version_Cabient_Kernel_value, (uint8_t *)value, sizeof(value));
  1156. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRFSystemVersion);
  1157. DisplayValueToLcm(_Version_Cabient_CSU_value, (uint8_t *)value, sizeof(value));
  1158. sprintf((char *)value,"%s",ShmDcCommonData->CabinetPrimaryVersion);
  1159. DisplayValueToLcm(_Version_Cabient_Priamry_value, (uint8_t *)value, sizeof(value));
  1160. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay0Version);
  1161. DisplayValueToLcm(_Version_Cabient_Relay0_value, (uint8_t *)value, sizeof(value));
  1162. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay1Version);
  1163. DisplayValueToLcm(_Version_Cabient_Relay1_value, (uint8_t *)value, sizeof(value));
  1164. sprintf((char *)value,"%s",ShmDcCommonData->CabinetFanVersion);
  1165. DisplayValueToLcm(_Version_Cabient_Fan_value, (uint8_t *)value, sizeof(value));
  1166. sprintf((char *)value,"%s",ShmDcCommonData->CabinetIPAddr);
  1167. DisplayValueToLcm(_Version_Cabient_IPAddr_value, (uint8_t *)value, sizeof(value));
  1168. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number < 12) {
  1169. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1170. if (i>=6) {
  1171. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].DCVersion);
  1172. DisplayValueToLcm(_Version_Cabient_PSU_Prim7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1173. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].FPCVersion);
  1174. DisplayValueToLcm(_Version_Cabient_PSU_Sec7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1175. continue;
  1176. }
  1177. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].DCVersion);
  1178. DisplayValueToLcm(_Version_Cabient_PSU_Prim1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1179. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].FPCVersion);
  1180. DisplayValueToLcm(_Version_Cabient_PSU_Sec1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1181. }
  1182. }
  1183. }
  1184. void ShowDispenserVersion()
  1185. {
  1186. char value[32];
  1187. memset(value, 0x00, sizeof(value));
  1188. sprintf((char *)value,"%s",pSysConfig->ModelName);
  1189. DisplayValueToLcm(_Version_Dispenser_Model_value, (uint8_t *)value, sizeof(value));
  1190. sprintf((char *)value,"%s",pSysInfo->CsuBootLoadFwRev);
  1191. DisplayValueToLcm(_Version_Dispenser_BootLoader_value, (uint8_t *)value, sizeof(value));
  1192. sprintf((char *)value,"%s",pSysInfo->CsuKernelFwRev);
  1193. DisplayValueToLcm(_Version_Dispenser_Kernel_value, (uint8_t *)value, sizeof(value));
  1194. sprintf((char *)value,"%s",pSysInfo->CsuRootFsFwRev);
  1195. DisplayValueToLcm(_Version_Dispenser_CSU_value, (uint8_t *)value, sizeof(value));
  1196. sprintf((char *)value,"%s",pSysInfo->RelayModuleFwRev);
  1197. DisplayValueToLcm(_Version_Dispenser_Relay_value, (uint8_t *)value, sizeof(value));
  1198. sprintf((char *)value,"%s",pSysInfo->FanModuleFwRev);
  1199. DisplayValueToLcm(_Version_Dispenser_Fan_value, (uint8_t *)value, sizeof(value));
  1200. sprintf((char *)value,"%s",pSysInfo->CsuPrimFwRev);
  1201. DisplayValueToLcm(_Version_Dispenser_Priamry_value, (uint8_t *)value, sizeof(value));
  1202. sprintf((char *)value,"%s",pSysInfo->LcmHwRev);
  1203. DisplayValueToLcm(_Version_Dispenser_LCM_value, (uint8_t *)value, sizeof(value));
  1204. sprintf((char *)value,"%s",pSysInfo->LedModuleFwRev);
  1205. DisplayValueToLcm(_Version_Dispenser_LED_value, (uint8_t *)value, sizeof(value));
  1206. sprintf((char *)value,"%s",pSysInfo->Connector1FwRev);
  1207. DisplayValueToLcm(_Version_Dispenser_Connector0_value, (uint8_t *)value, sizeof(value));
  1208. sprintf((char *)value,"%s",pSysInfo->Connector2FwRev);
  1209. DisplayValueToLcm(_Version_Dispenser_Connector1_value, (uint8_t *)value, sizeof(value));
  1210. sprintf((char *)value,"%s",pSysConfig->Eth0Interface.EthIpAddress);
  1211. DisplayValueToLcm(_Version_Dispenser_IPAddr_value, (uint8_t *)value, sizeof(value));
  1212. }
  1213. /*
  1214. void InformationShow()
  1215. {
  1216. is_show = true;
  1217. if (_showInformIndex == 0 ) {
  1218. pSysInfo->PageIndex = __SHOW_CABIENT_VERSION;
  1219. } else {
  1220. pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION;
  1221. ShowDispenserVersion();
  1222. }
  1223. }
  1224. */
  1225. void DefautLayOut()
  1226. {
  1227. int i;
  1228. for (i = 0 ; i <= 0x5C ; i+=2 ) {
  1229. ChangeDisplay2Value(0x1000+i,1);
  1230. if (i==0x28 || i ==0x2A)
  1231. continue;
  1232. }
  1233. ChangeDisplay2Value(_Icon_MobilePay,0);
  1234. ChangeDisplay2Value(_Icon_CardPay,0);
  1235. ChangeDisplay2Value(0x5000,1);
  1236. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  1237. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  1238. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  1239. ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS1);
  1240. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  1241. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  1242. ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS2);
  1243. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  1244. ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CHAdeMo);
  1245. }
  1246. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1247. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  1248. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  1249. ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS1);
  1250. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  1251. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  1252. ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS2);
  1253. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  1254. ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CHAdeMo);
  1255. }
  1256. }
  1257. /*
  1258. static int InitialRfidPort(void)
  1259. {
  1260. int fd = open(rfidPortName, O_RDWR);
  1261. struct termios tios;
  1262. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  1263. if (fd != FAIL) {
  1264. ioctl (fd, TCGETS, &tios);
  1265. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  1266. tios.c_lflag = 0;
  1267. tios.c_iflag = 0;
  1268. tios.c_oflag = 0;
  1269. tios.c_cc[VMIN] = 0;
  1270. tios.c_cc[VTIME] = (uint8_t) 1;
  1271. tios.c_lflag = 0;
  1272. tcflush(fd, TCIFLUSH);
  1273. ioctl(fd, TCSETS, &tios);
  1274. }
  1275. if (fd < 0) {
  1276. pAlarmCode->AlarmEvents.bits.RfidModuleCommFail = 1;
  1277. }
  1278. return fd;
  1279. }
  1280. */
  1281. int main(void)
  1282. {
  1283. bool defaulttext = false;
  1284. if (CreateAllCsuShareMemory() == FAIL) {
  1285. log_error("create share memory error");
  1286. return FAIL;
  1287. }
  1288. MappingGunChargingInfo("LCM Control Task");
  1289. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  1290. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  1291. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  1292. ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
  1293. ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  1294. ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  1295. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  1296. ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
  1297. struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
  1298. _port = CreateCommunicationLcmPort();
  1299. uint8_t changeWarningPriority = 0;
  1300. uint8_t curWarningCount = 255;
  1301. ChangeBackLight(true);
  1302. _totalCount = pSysConfig->TotalConnectorCount;
  1303. _everyPageRollChange = 0;
  1304. //Initialization();
  1305. //printf("_LCM_COMPLETE ");
  1306. //ChangeToOtherPage(_LCM_COMPLETE);
  1307. DefautLayOut();
  1308. //return 0;
  1309. //uint8_t index = 1;
  1310. int result = 0;
  1311. ShmDcCommonData->PSU_Number = 12;
  1312. /*
  1313. CardReadFd = InitialRfidPort();
  1314. if (CardReadFd <0) {
  1315. log_info("Card Read Port open fail!");
  1316. }*/
  1317. CheckLCMPressed();
  1318. while (_port != -1) {
  1319. if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
  1320. GetCurrentPage();
  1321. sleep(1);
  1322. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1323. } else {
  1324. UpdateLcmFunction(ShmDcCommonData,_port);
  1325. ///*
  1326. // Warning 處理
  1327. if (curWarningCount != pSysWarning->WarningCount) {
  1328. changeWarningPriority = 0;
  1329. pSysWarning->PageIndex = 0;
  1330. curWarningCount = pSysWarning->WarningCount;
  1331. ChangeWarningFunc();
  1332. } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
  1333. // 當有兩頁 Warning 則每隔三秒改變一次
  1334. if (pSysWarning->PageIndex == 0) {
  1335. pSysWarning->PageIndex = 1;
  1336. } else {
  1337. pSysWarning->PageIndex = 0;
  1338. }
  1339. ChangeWarningFunc();
  1340. }
  1341. ///*
  1342. // Show Default Text
  1343. if (!defaulttext) {
  1344. ShowCabientVersionDefaultText();
  1345. ShowDispenserVersionDefautlText();
  1346. defaulttext = true;
  1347. }
  1348. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
  1349. // 頁面資訊處理
  1350. ProcessPageInfo();
  1351. // 換頁處理
  1352. //GetCurrentPage(); //DS60-120 add
  1353. /*
  1354. if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
  1355. InformationShow();
  1356. ChangeToOtherPage(pSysInfo->PageIndex);
  1357. usleep(100000);
  1358. continue;
  1359. } else {
  1360. if (is_show)
  1361. _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
  1362. is_show = false;
  1363. }*/
  1364. GetCurrentPage(); //DS60-120 add
  1365. ChangeCurPage();
  1366. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1367. usleep(10000); //*/
  1368. /*
  1369. ProcessPageInfo();
  1370. GetCurrentPage();
  1371. ChangeCurPage();
  1372. usleep(10000);
  1373. //*/
  1374. }
  1375. } //while
  1376. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1377. log_info("Close LCM Uart Port");
  1378. CloseCommunicationLcmPort();
  1379. return FAIL;
  1380. }