Module_LcmControl.c 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
  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. GetClockTime(&pDcChargingInfo->ConnectorTimeout, 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 WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
  150. {
  151. int len = write(_port, cmd, cmdLen);
  152. if (len < sizeof(cmd)) {
  153. log_error("Write cmd to LCM Failure. ");
  154. }
  155. }
  156. void ReadMsgFromLcm(uint8_t* msg, uint8_t readLen)
  157. {
  158. read(_port, msg, readLen);
  159. // 5a : CMD_TITLE_1
  160. // a5 : CMD_TITLE_2
  161. // 5
  162. // 81 : CMD_WRITE
  163. // 3 : CMD_REGISTER
  164. // 2 : Data length
  165. // 0 : High byte
  166. // 1 : Low byte
  167. // printf("-------------------------------------------- \n");
  168. // printf("msg = %x \n", *msg); // A5
  169. // printf("msg = %x \n", *(msg + 1)); // 5A
  170. // printf("msg = %x \n", *(msg + 2)); // Len : [3] ~ [6] + Data Len
  171. // printf("msg = %x \n", *(msg + 3)); // cmd : 0x83
  172. // printf("msg = %x \n", *(msg + 4)); // addr : H
  173. // printf("msg = %x \n", *(msg + 5)); // addr : L
  174. // printf("msg = %x \n", *(msg + 6)); // Data Len
  175. //
  176. // printf("msg = %x \n", *(msg + 7));
  177. // printf("msg = %x \n", *(msg + 8));
  178. // printf("msg = %x \n", *(msg + 9));
  179. // printf("msg = %x \n", *(msg + 10));
  180. // printf("msg = %x \n", *(msg + 11));
  181. // printf("msg = %x \n", *(msg + 12));
  182. // printf("msg = %x \n", *(msg + 13));
  183. // printf("msg = %x \n", *(msg + 14));
  184. /*
  185. for(uint8_t i = 0 ; i<readLen+3; i++) {
  186. log_info("Read data[%d]:0x%x",i,msg[i]);
  187. }*/
  188. if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2)
  189. {
  190. if (*(msg + 3) == CMD_WRITE)
  191. {
  192. switch (*(msg + 4))
  193. {
  194. case CMD_REGISTER:
  195. {
  196. // 頁面
  197. if (strcmp((char*)pSysInfo->LcmHwRev, "") != EQUAL)
  198. strcpy((char*)pSysInfo->LcmHwRev, moduleName);
  199. _currentPage = *(msg + 7);
  200. log_info("Current Page:%d", _currentPage);
  201. // if (_currentPage != 1 && _currentPage != 5 && _currentPage != 6 && _currentPage != 7 && _currentPage != 8)
  202. // printf("_currentPage = %d \n", _currentPage);
  203. }
  204. break;
  205. }
  206. } else if (*(msg + 3) == CMD_MULTI_READ)
  207. {
  208. short key = ((short)(*(msg + 4) << 8) + *(msg + 5));
  209. if (strcmp((char*)pSysInfo->LcmHwRev, "") != EQUAL)
  210. strcpy((char*)pSysInfo->LcmHwRev, moduleName);
  211. if (key == 0x0014)
  212. _currentPage = *(msg + 8);
  213. if (key == 0x0031) {
  214. log_info("Get LCM Backlight change to 0x%x", *(msg + 8));
  215. }
  216. if (key >= _Touch_IDLE && key <= _Touch_Pay_LinePay) {
  217. _btn_press_id = key;
  218. _btn_press = *(msg + 8);
  219. }
  220. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  221. // {
  222. // case BUTTON_GUN_INDEX:
  223. // {
  224. // // 當前選的槍號
  225. // _curGunIndex = (*(msg + 8));
  226. // }
  227. // break;
  228. // }
  229. }
  230. }
  231. }
  232. void GetDeviceInfoStatus(short address, uint8_t len)
  233. {
  234. uint8_t cmd[8];
  235. memset(cmd, 0x00, sizeof(cmd));
  236. uint8_t msg[11];
  237. memset(msg, 0x00, sizeof(msg));
  238. cmd[0] = CMD_TITLE_1;
  239. cmd[1] = CMD_TITLE_2;
  240. cmd[2] = 0x04;
  241. cmd[3] = CMD_MULTI_READ;
  242. cmd[4] = (address >> 8) & 0xff;
  243. cmd[5] = (address >> 0) & 0xff;
  244. cmd[6] = len;
  245. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  246. usleep(1000);
  247. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  248. }
  249. void DisplayValueToLcm(short address, uint8_t* data, uint8_t len)
  250. {
  251. uint8_t cmd[256];
  252. memset(cmd, 0x00, sizeof(cmd));
  253. uint8_t msg[9];
  254. memset(msg, 0x00, sizeof(msg));
  255. cmd[0] = CMD_TITLE_1;
  256. cmd[1] = CMD_TITLE_2;
  257. cmd[2] = 0x03 + len;
  258. cmd[3] = CMD_MULTI_WRITE;
  259. cmd[4] = address >> 8;
  260. cmd[5] = address & 0x00FF;
  261. for (uint8_t count = 0; count < len; count++)
  262. {
  263. cmd[6 + count] = *(data + count);
  264. }
  265. WriteCmdToLcm(cmd, cmd[2] + 3);
  266. usleep(10000);
  267. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  268. }
  269. void ChangeDisplay2Value(short address, short value)
  270. {
  271. uint8_t data[2];
  272. data[0] = value >> 8;
  273. data[1] = value & 0x00FF;
  274. //log_info("Addr:0x%x, value:%d",address,value);
  275. DisplayValueToLcm(address, data, sizeof(data));
  276. }
  277. void TradeRunning(uint8_t _run)
  278. {
  279. if (_run == TRUE) {
  280. ChangeDisplay2Value(_Icon_PreAuth, 1);
  281. ChangeDisplay2Value(_Icon_Ani_Dot, 1);
  282. ChangeDisplay2Value(_Icon_CountDownBG, 0);
  283. ChangeDisplay2Value(_Icon_CancelCntDownTen, 0);
  284. ChangeDisplay2Value(_Icon_CancelCntDownDigits, 0);
  285. ChangeDisplay2Value(_Icon_PreAuthWord, _TCC_PreAuthWord);
  286. }
  287. else {
  288. ChangeDisplay2Value(_Icon_PreAuth, _TCC_TradeCancelString);
  289. ChangeDisplay2Value(_Icon_Ani_Dot, 0);
  290. ChangeDisplay2Value(_Icon_PreAuthWord, 0);
  291. ChangeDisplay2Value(_Icon_CountDownBG, _TCC_TradeCancelFrame);
  292. if (pSysInfo->SystemTimeoutFlag == Timeout_TradeCancel) {
  293. unsigned long _time = TCC_TRADECANCEL_TIMEOUT-(GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
  294. ChangeDisplay2Value(_Icon_CancelCntDownTen, (short)(_TCC_CancelNum_0 + (_time / 10)));
  295. ChangeDisplay2Value(_Icon_CancelCntDownDigits, (short)(_TCC_CancelNum_0 + (_time % 10)));
  296. }
  297. }
  298. }
  299. static void systemPageRestoreInit(void)
  300. {
  301. int is_idle = TRUE;
  302. int gunIndex;
  303. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  304. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
  305. // 檢查電樁狀態是否為idle狀態
  306. if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
  307. pDcChargingInfo->SystemStatus <= S_RESERVATION) ||
  308. (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
  309. pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST0)) {
  310. is_idle = FALSE;
  311. }
  312. }
  313. if (is_idle)
  314. pSysInfo->SystemPage = _PAGE_IDLE;
  315. else
  316. pSysInfo->SystemPage = _PAGE_SELECT_GUN;
  317. }
  318. void CheckIdlePress()
  319. {
  320. systemPageRestoreInit();
  321. log_info("IDLE Enter Select Gun Page");
  322. }
  323. void CheckReturnPress()
  324. {
  325. int i;
  326. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  327. //pDcChargingInfo->SystemStatus = S_IDLE;
  328. if (pSysInfo->SystemPage >= _PAGE_BILL && pSysInfo->SystemPage <= _PAGE_PLUGIN ||
  329. pSysInfo->SystemPage == _PAGE_AUTHORIZE_FAIL || pSysInfo->SystemPage == _PAGE_DONATE_RIGHT) {
  330. ShmDcCommonData->OperateIDLE[pSysInfo->CurGunSelected] = 1;
  331. log_info("Operate return to IDLE");
  332. }
  333. // Cancel Trade
  334. if ( pDcChargingInfo->SystemStatus == S_AUTHORIZING ||
  335. ((pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION ) &&
  336. pSysInfo->SystemPage == _PAGE_AUTHORIZE)) {
  337. log_info("Press Return button cancel PreAuth");
  338. ShmDcCommonData->TradeCancel = TRUE;
  339. pSysInfo->SystemPage = _PAGE_SENSING;
  340. StopGunInfoTimeoutDet(pSysInfo->CurGunSelected);
  341. StartSystemTimeoutDet(Timeout_TradeCancel);
  342. for (i = 0; i <= 30; i++) {
  343. if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE)
  344. break;
  345. sleep(1);
  346. }
  347. ShmDcCommonData->PreAuth_Result = 0;
  348. ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
  349. if (strcmp(ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard.VemData, "") != 0) {
  350. ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
  351. ShmDcCommonData->PreAuth_Result = 0;
  352. for (i = 0; i <= 30; i++) {
  353. if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE)
  354. break;
  355. sleep(1);
  356. }
  357. ShmDcCommonData->PreAuth_Result = 0;
  358. }
  359. StopSystemTimeoutDet();
  360. pDcChargingInfo->SystemStatus = S_IDLE;
  361. systemPageRestoreInit();
  362. strcpy((char *)pSysConfig->UserId, "");
  363. return;
  364. }
  365. if ( pSysInfo->SystemPage == _PAGE_EXIT ) {
  366. StopGunInfoTimeoutDet(pSysInfo->CurGunSelected);
  367. pDcChargingInfo->SystemStatus = S_IDLE;
  368. return;
  369. }
  370. if (pSysInfo->SystemPage == _PAGE_AUTHORIZE)
  371. pSysInfo->SystemPage = _PAGE_SELECT_PAY;
  372. else
  373. systemPageRestoreInit();
  374. }
  375. void CheckStopPress()
  376. {
  377. is_stop = TRUE;
  378. //ChangeDisplay2Value(_ConfirmStopIcon,is_stop);
  379. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
  380. pSysInfo->SystemPage = _PAGE_STOP_CONFIRM_LEFT;
  381. else
  382. pSysInfo->SystemPage = _PAGE_STOP_CONFIRM_RIGHT;
  383. }
  384. void CheckStopConfirmPress()
  385. {
  386. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  387. pDcChargingInfo->SystemStatus = S_TERMINATING;
  388. pSysInfo->SystemPage = _PAGE_PAYING;
  389. is_stop = FALSE;
  390. /*
  391. //ShmDcCommonData->StopCharge[pSysInfo->CurGunSelected] = TRUE;
  392. if (ShmDcCommonData->is_AutoStart[pSysInfo->CurGunSelected] ||
  393. ShmDcCommonData->is_RemoteStart[pSysInfo->CurGunSelected]) {
  394. pSysInfo->SystemPage = _PAGE_COMPLETE;
  395. return;
  396. }
  397. */
  398. }
  399. void CheckStopCancelPress()
  400. {
  401. is_stop = FALSE;
  402. //ChangeDisplay2Value(_ConfirmStopIcon,is_stop);
  403. pSysInfo->SystemPage = _PAGE_CHARGING;
  404. }
  405. void CheckConfirmGun(uint8_t gunIndex)
  406. {
  407. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
  408. if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
  409. log_info("Reservation can't select");
  410. return;
  411. }
  412. //log_info("Confirm Gun%d",gunIndex);
  413. pSysInfo->CurGunSelected = gunIndex;
  414. pSysInfo->SystemPage = _PAGE_BILL;
  415. }
  416. void CheckDonateBill(uint8_t gunIndex)
  417. {
  418. if (gunIndex == LEFT_GUN_NUM) {
  419. pSysInfo->SystemPage = _PAGE_DONATE_LEFT;
  420. } else
  421. pSysInfo->SystemPage = _PAGE_DONATE_RIGHT;
  422. }
  423. void CheckDonateYes()
  424. {
  425. pSysInfo->SystemPage = _PAGE_SELECT_PAY;
  426. ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsDonateInvoice = TRUE;
  427. }
  428. void CheckDonateNo()
  429. {
  430. pSysInfo->SystemPage = _PAGE_BILL;
  431. ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsDonateInvoice = FALSE;
  432. }
  433. void CheckPayCreditCard()
  434. {
  435. //ShmDcCommonData->LineStatus[pSysInfo->CurGunSelected] = 0;
  436. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  437. // 使用者進入線上支付,禁止使用者使用刷卡機
  438. if (ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].LineStatus == _LINE_PAY_OPERATE ||
  439. pDcChargingInfo->SystemStatus == S_RESERVATION ) {
  440. pSysInfo->SystemPage = _PAGE_LINEPAYING;
  441. StartSystemTimeoutDet(Timeout_LINEPAYING);
  442. log_info("Some one online operate");
  443. return;
  444. }
  445. ShmDcCommonData->TradeCancel = FALSE;
  446. if ((pDcChargingInfo->SystemStatus == S_IDLE ) &&
  447. pSysInfo->SystemPage == _PAGE_SELECT_PAY &&
  448. ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE) {
  449. ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH;
  450. ShmDcCommonData->PreAuth_Result = 0;
  451. pSysInfo->SystemPage = _PAGE_AUTHORIZE;
  452. //log_info("Press Credit card pay status:%d Page:%d Config:%d", pDcChargingInfo->SystemStatus,
  453. // pSysInfo->SystemPage, ShmDcCommonData->PreAuth_Config);
  454. }
  455. }
  456. void CheckPayIcash()
  457. {
  458. }
  459. void CheckPayLinePay()
  460. {
  461. }
  462. void CheckTouchPress(short id)
  463. {
  464. GetDeviceInfoStatus(id,1);
  465. if (_btn_press >= 1 && _btn_press_id == id ) {
  466. _btn_press_count++;
  467. }
  468. if (_btn_press >= 1 && _btn_press_id == id && _btn_press_count >= 3) {
  469. ChangeDisplay2Value(id, 0);
  470. //log_info("Press id : 0x%04x",id);
  471. _btn_press_count = 0;
  472. switch (id) {
  473. case _Touch_Show_Left:
  474. if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_SENSING) {
  475. log_info("Authorize Process can't select gun");
  476. return;
  477. }
  478. // Show log
  479. if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
  480. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  481. /*
  482. if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
  483. systemPageRestoreInit();
  484. log_info("Can't select Reservation Gun");
  485. break;
  486. }
  487. */
  488. pSysInfo->CurGunSelected = LEFT_GUN_NUM;
  489. if(pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION) {
  490. systemPageRestoreInit();
  491. }
  492. log_info("LCM left Gun down...............................%x %x %x",
  493. pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
  494. }
  495. if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
  496. pSysInfo->SystemPage == _PAGE_PAYFAIL) {
  497. StopSystemTimeoutDet();
  498. }
  499. break;
  500. case _Touch_Show_Right:
  501. if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_SENSING) {
  502. log_info("Authorize Process can't select gun");
  503. return;
  504. }
  505. // Show log
  506. if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
  507. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  508. /*
  509. if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
  510. systemPageRestoreInit();
  511. log_info("Can't select Reservation Gun");
  512. break;
  513. }
  514. */
  515. pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
  516. if (pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION) {
  517. systemPageRestoreInit();
  518. }
  519. log_info("LCM Right Gun down...............................%x %x %x",
  520. pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
  521. }
  522. if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
  523. pSysInfo->SystemPage == _PAGE_PAYFAIL) {
  524. StopSystemTimeoutDet();
  525. }
  526. break;
  527. case _Touch_Return:
  528. CheckReturnPress();
  529. break;
  530. case _Touch_IDLE:
  531. CheckIdlePress();
  532. break;
  533. case _Touch_StopCharge:
  534. CheckStopPress();
  535. is_stop = TRUE;
  536. break;
  537. case _Touch_Stop_Confirm:
  538. CheckStopConfirmPress();
  539. is_stop = FALSE;
  540. break;
  541. case _Touch_Stop_Cancel:
  542. CheckStopCancelPress();
  543. is_stop = FALSE;
  544. break;
  545. case _Touch_Select_Left:
  546. CheckConfirmGun(LEFT_GUN_NUM);
  547. break;
  548. case _Touch_Select_Right:
  549. CheckConfirmGun(RIGHT_GUN_NUM);
  550. break;
  551. case _Touch_DonateBill:
  552. StopSystemTimeoutDet();
  553. CheckDonateBill(pSysInfo->CurGunSelected);
  554. break;
  555. case _Touch_DonateYes:
  556. CheckDonateYes();
  557. break;
  558. case _Touch_DonateNo:
  559. StartSystemTimeoutDet(Timeout_AddLine);
  560. CheckDonateNo();
  561. break;
  562. case _Touch_Pay_CreditCard:
  563. CheckPayCreditCard();
  564. break;
  565. case _Touch_Pay_Icash:
  566. CheckPayIcash();
  567. break;
  568. case _Touch_Pay_LinePay:
  569. CheckPayLinePay();
  570. break;
  571. } // switch
  572. } //if (_btn_press >= 3)
  573. }
  574. void CheckLCMPressed()
  575. {
  576. pid_t Pid = fork();
  577. if ( Pid == 0 ) {
  578. while (1) {
  579. if (pSysInfo->SystemPage != _PAGE_SELECT_GUN && pSysInfo->SystemPage != _PAGE_IDLE) {
  580. CheckTouchPress(_Touch_Show_Left);
  581. CheckTouchPress(_Touch_Show_Right);
  582. }
  583. switch (pSysInfo->SystemPage) {
  584. case _PAGE_IDLE:
  585. //CheckTouchPress(_Touch_IDLE);
  586. CheckTouchPress(_Touch_Select_Left);
  587. CheckTouchPress(_Touch_Select_Right);
  588. break;
  589. case _PAGE_SELECT_GUN:
  590. CheckTouchPress(_Touch_Select_Left);
  591. CheckTouchPress(_Touch_Select_Right);
  592. break;
  593. case _PAGE_BILL:
  594. CheckTouchPress(_Touch_Return);
  595. CheckTouchPress(_Touch_DonateBill);
  596. break;
  597. case _PAGE_ADD_FRIEND:
  598. CheckTouchPress(_Touch_Return);
  599. CheckTouchPress(_Touch_DonateBill);
  600. break;
  601. case _PAGE_DONATE_LEFT:
  602. case _PAGE_DONATE_RIGHT:
  603. CheckTouchPress(_Touch_Return);
  604. CheckTouchPress(_Touch_DonateYes);
  605. CheckTouchPress(_Touch_DonateNo);
  606. break;
  607. case _PAGE_SELECT_PAY:
  608. CheckTouchPress(_Touch_Return);
  609. CheckTouchPress(_Touch_Pay_CreditCard);
  610. break;
  611. case _PAGE_PLUGIN:
  612. CheckTouchPress(_Touch_Return);
  613. break;
  614. ///*
  615. case _PAGE_CHARGING:
  616. CheckTouchPress(_Touch_StopCharge);
  617. break;
  618. case _PAGE_AUTHORIZE:
  619. CheckTouchPress(_Touch_Return);
  620. break;
  621. case _PAGE_STOP_CONFIRM_LEFT:
  622. case _PAGE_STOP_CONFIRM_RIGHT:
  623. StopSystemTimeoutDet();
  624. CheckTouchPress(_Touch_Stop_Confirm);
  625. CheckTouchPress(_Touch_Stop_Cancel);
  626. break;
  627. case _PAGE_EXIT:
  628. CheckTouchPress(_Touch_Return);
  629. break;
  630. case _PAGE_AUTHORIZE_FAIL:
  631. CheckTouchPress(_Touch_Return);
  632. break;
  633. } // switch
  634. usleep(5000);
  635. } //while
  636. } // if pid
  637. log_info("Create LCM fork:%d\n\n",Pid);
  638. }
  639. void GetHrFormTimeString(char* time,char* hr)
  640. {
  641. //char tm[] = "2021-12-06 17:29:08:084";
  642. for(int i = 0 ; i < 2 ; i++) {
  643. hr[i] = time[i+11];
  644. }
  645. if( atoi(hr) < 0 || atoi(hr) > 24) {
  646. strcmp(hr,"");
  647. }
  648. }
  649. void GetMinFormTimeString(char* time,char* min)
  650. {
  651. //char tm[] = "2021-12-06 17:29:08:084";
  652. for(int i = 0 ; i < 2 ; i++) {
  653. min[i] = time[i+14];
  654. }
  655. if( atoi(min) < 0 || atoi(min) > 60) {
  656. strcmp(min,"");
  657. }
  658. }
  659. //================================================
  660. // Function
  661. //================================================
  662. void ChangeToOtherPage(short newPage)
  663. {
  664. uint8_t cmd[10];
  665. memset(cmd, 0x00, sizeof(cmd));
  666. uint8_t msg[9];
  667. memset(msg, 0x00, sizeof(msg));
  668. cmd[0] = CMD_TITLE_1;
  669. cmd[1] = CMD_TITLE_2;
  670. cmd[2] = 0x07;
  671. cmd[3] = 0x82;
  672. cmd[4] = 0x00;
  673. cmd[5] = 0x84;
  674. cmd[6] = 0x5A;
  675. cmd[7] = 0x01;
  676. cmd[8] = newPage >> 8;
  677. cmd[9] = newPage & 0x00FF;
  678. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  679. usleep(5000);
  680. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  681. }
  682. void ChangeBackLight(uint8_t value)
  683. {
  684. //uint8_t value = 0x01;
  685. uint8_t msg[9];
  686. memset(msg, 0x00, sizeof(msg));
  687. uint8_t cmd[7];
  688. memset(cmd, 0x00, sizeof(cmd));
  689. cmd[0] = CMD_TITLE_1;
  690. cmd[1] = CMD_TITLE_2;
  691. cmd[2] = 0x05;
  692. cmd[3] = CMD_MULTI_WRITE;
  693. cmd[4] = 0x00;
  694. cmd[5] = 0x82;
  695. cmd[6] = value;
  696. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  697. usleep(10000);
  698. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  699. }
  700. void GetCurrentPage()
  701. {
  702. uint8_t cmd[7];
  703. memset(cmd, 0x00, sizeof(cmd));
  704. uint8_t msg[9];
  705. memset(msg, 0x00, sizeof(msg));
  706. cmd[0] = CMD_TITLE_1;
  707. cmd[1] = CMD_TITLE_2;
  708. cmd[2] = 0x04; // 底下總長度
  709. cmd[3] = 0x83;
  710. cmd[4] = 0x00;
  711. cmd[5] = 0x14;
  712. cmd[6] = 0x01;
  713. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  714. usleep(5000);
  715. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  716. }
  717. //================================================
  718. // Warning process
  719. //================================================
  720. void string2ByteArray(uint8_t *input, uint8_t *output)
  721. {
  722. int loop;
  723. int i;
  724. loop = 0;
  725. i = 0;
  726. while (input[loop] != '\0') {
  727. output[i++] = input[loop++];
  728. }
  729. output[loop] = '\0';
  730. }
  731. void RefreshProgressAnimation()
  732. {
  733. _everyPageRollChange >= 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  734. }
  735. //================================================
  736. // Change current page
  737. //================================================
  738. void ChangeCurPage()
  739. {
  740. //log_info("cur = %d ,system = %d, lcm = %d ",_currentPage, pSysInfo->SystemPage, pSysInfo->PageIndex);
  741. pSysInfo->PageIndex = pSysInfo->SystemPage;
  742. if (_currentPage != pSysInfo->PageIndex) {
  743. switch (pSysInfo->SystemPage) {
  744. case _PAGE_AUTHORIZE:
  745. break;
  746. case _PAGE_PLUGIN:
  747. break;
  748. case _PAGE_PRECHARGE:
  749. break;
  750. case _PAGE_CHARGING:
  751. is_stop = false;
  752. break;
  753. case _PAGE_COMPLETE:
  754. break;
  755. case _PAGE_MAINTAIN:
  756. break;
  757. }
  758. _currentPage = pSysInfo->PageIndex;
  759. //if (pSysInfo->PageIndex != _PAGE_IDLE)
  760. //log_info("Gun[%d] Chagne LCM Page:%d",pSysInfo->CurGunSelected, pSysInfo->PageIndex);
  761. ChangeToOtherPage(pSysInfo->PageIndex);
  762. }
  763. }
  764. /*
  765. * View Page
  766. *
  767. */
  768. unsigned long GetTimeoutValue(struct timeval _sour_time)
  769. {
  770. struct timeval _end_time;
  771. gettimeofday(&_end_time, NULL);
  772. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  773. }
  774. void showGunWorkingType()
  775. {
  776. if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
  777. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  778. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  779. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  780. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_On);
  781. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  782. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  783. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_On);
  784. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  785. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_On);
  786. }
  787. // Set Right Gun
  788. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  789. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  790. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  791. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_Off);
  792. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  793. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  794. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_Off);
  795. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  796. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off);
  797. }
  798. } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM){
  799. // Left Gun
  800. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  801. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  802. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  803. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_Off);
  804. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  805. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  806. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_Off);
  807. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  808. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_Off);
  809. }
  810. // Right Gun
  811. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  812. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  813. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  814. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_On);
  815. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  816. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  817. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_On);
  818. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  819. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_On);
  820. }
  821. }
  822. }
  823. void ClearQrCode_Idle()
  824. {
  825. char cmd[200];
  826. memset(cmd,0,200);
  827. DisplayValueToLcm(_QRCode_AddLine, cmd, 200);
  828. }
  829. void ChangeQrCode_Idle(char *input)
  830. {
  831. char cmd[256];
  832. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  833. int len = 0;
  834. memset(cmd,0,256);
  835. if (!ShmDcCommonData->tccdev)
  836. len = sprintf(cmd, "https://nhoatcc.lineapid.tw/web/tologin?sn=%s&cid=%d", input, ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]);
  837. else
  838. len = sprintf(cmd, "https://nhoatcctest.lineapid.tw/web/tologin?sn=%s&cid=%d", input, ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]);
  839. //log_info("QR Code:URL:%s",cmd);
  840. if (pSysInfo->SystemPage == _PAGE_BILL)
  841. DisplayValueToLcm(_QRCode_AddLine, cmd, len+1);
  842. }
  843. void ClearQrCode_Error()
  844. {
  845. char cmd[200];
  846. memset(cmd, 0, 200);
  847. DisplayValueToLcm(_QRCode_Service, cmd, 200);
  848. }
  849. void ChangeQrCode_Error()
  850. {
  851. char cmd[200];
  852. memset(cmd, 0, 200);
  853. sprintf(cmd, "https://line.me/R/ti/p/@217tcevc");
  854. //log_info("QR Code:URL:%s",cmd);
  855. DisplayValueToLcm(_QRCode_Service, cmd, 200);
  856. }
  857. /*
  858. void ChangeRemainTime(int sec)
  859. {
  860. int h, m, s;
  861. uint8_t cmd[10];
  862. uint8_t value[10];
  863. memset(cmd, 0x00, sizeof(cmd));
  864. // srand(time(NULL));
  865. // int min = 0;
  866. // int max = 65536;
  867. // sec = rand() % (max - min + 1) + min;
  868. h = (sec / 3600);
  869. m = (sec - (3600 * h)) / 60;
  870. s = (sec - (3600 * h) - (m * 60));
  871. sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
  872. string2ByteArray(value, cmd);
  873. DisplayValueToLcm(_Text_Time, cmd, sizeof(cmd));
  874. }
  875. */
  876. void ShowSelectGun()
  877. {
  878. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  879. if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
  880. pDcChargingInfo->SystemStatus <= S_ALARM) ||
  881. pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 ||
  882. pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) {
  883. // 使用中
  884. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  885. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  886. ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunCharging_CCS1);
  887. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  888. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  889. ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunCharging_CCS2);
  890. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  891. ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunCharging_CHAdeMo);
  892. }
  893. } else if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
  894. // 預約中
  895. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  896. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  897. ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunReservation_CCS1);
  898. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  899. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  900. ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunReservation_CCS2);
  901. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  902. ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunReservation_CHAdeMo);
  903. }
  904. } else {
  905. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  906. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  907. ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS1);
  908. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  909. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  910. ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS2);
  911. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  912. ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CHAdeMo);
  913. }
  914. }
  915. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  916. if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
  917. pDcChargingInfo->SystemStatus <= S_ALARM) ||
  918. pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 ||
  919. pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) {
  920. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  921. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  922. ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunCharging_CCS1);
  923. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  924. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  925. ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunCharging_CCS2);
  926. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  927. ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunCharging_CHAdeMo);
  928. }
  929. } else if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
  930. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  931. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  932. ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunReservation_CCS1);
  933. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  934. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  935. ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunReservation_CCS2);
  936. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  937. ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunReservation_CHAdeMo);
  938. }
  939. } else {
  940. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  941. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  942. ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS1);
  943. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  944. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  945. ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS2);
  946. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  947. ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CHAdeMo);
  948. }
  949. }
  950. }
  951. void ChangeChargingPowerValue(float pow)
  952. {
  953. uint8_t cmd[10];
  954. uint8_t value[10];
  955. memset(cmd, 0x00, sizeof(cmd));
  956. sprintf((char *) value, "%d",(int)pow);
  957. string2ByteArray(value, cmd);
  958. DisplayValueToLcm(_String_ChargePower, cmd, sizeof(cmd));
  959. }
  960. void ChangeChargingRateValue(float rate)
  961. {
  962. uint8_t cmd[10];
  963. uint8_t value[10];
  964. memset(cmd, 0x00, sizeof(cmd));
  965. sprintf((char *) value, "%.1f",rate);
  966. string2ByteArray(value, cmd);
  967. DisplayValueToLcm(_String_ChargeRate, cmd, sizeof(cmd));
  968. }
  969. void ChangeChargingFeeValue(float fee)
  970. {
  971. uint8_t cmd[10];
  972. uint8_t value[10];
  973. memset(cmd, 0x00, sizeof(cmd));
  974. sprintf((char *) value, "%d", (int)fee);
  975. string2ByteArray(value, cmd);
  976. DisplayValueToLcm(_String_Money, cmd, sizeof(cmd));
  977. }
  978. void ChangeCarBonValue(float data)
  979. {
  980. uint8_t cmd[10];
  981. uint8_t value[10];
  982. float _carbon = 0;
  983. memset(cmd, 0x00, sizeof(cmd));
  984. _carbon = data * 0.577;
  985. //log_info("Carbon:%d",(int)_carbon);
  986. sprintf((char *) value, "%.1f", _carbon);
  987. string2ByteArray(value, cmd);
  988. DisplayValueToLcm(_String_Carbon, cmd, sizeof(cmd));
  989. }
  990. void ChangeChargingEnergyValue(float energy)
  991. {
  992. uint8_t cmd[10];
  993. uint8_t value[10];
  994. memset(cmd, 0x00, sizeof(cmd));
  995. if (energy >= 0.05) {
  996. energy -= 0.05;
  997. }
  998. if (energy < 0 )
  999. ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0);
  1000. else if (energy > 100)
  1001. ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0+100);
  1002. else
  1003. ChangeDisplay2Value(_Icon_ChargeBar,(int)energy+_TCC_Charging_Bar0);
  1004. if (energy < 10)
  1005. sprintf((char *) value, "%.1f", energy);
  1006. else
  1007. sprintf((char *) value, "%d", (int)energy);
  1008. string2ByteArray(value, cmd);
  1009. DisplayValueToLcm(_Strting_Energy, cmd, sizeof(cmd));
  1010. }
  1011. uint8_t _battery_display_count = 0;
  1012. void ChangeBattMapAndValue(int soc)
  1013. {
  1014. int i = (soc*36)/100;
  1015. uint8_t cmd[5];
  1016. uint8_t value[5];
  1017. _battery_display_count++;
  1018. if (_battery_display_count == 3 ) {
  1019. if (_battery_display_ani == 0)
  1020. _battery_display_ani= TRUE;
  1021. else
  1022. _battery_display_ani= FALSE ;
  1023. _battery_display_count = 0;
  1024. }
  1025. if (pSysInfo->SystemPage == _PAGE_CHARGING) {
  1026. if (i>=36)
  1027. ChangeDisplay2Value(_Icon_ChargeCircle,_TCC_Charging_Circle0+36);
  1028. else {
  1029. if (_battery_display_ani) {
  1030. ChangeDisplay2Value(_Icon_ChargeCircle, _TCC_Charging_Circle0+i);
  1031. } else {
  1032. ChangeDisplay2Value(_Icon_ChargeCircle, _TCC_Charging_Circle0+i+1);
  1033. }
  1034. }
  1035. } else if (pSysInfo->SystemPage == _PAGE_COMPLETE)
  1036. ChangeDisplay2Value(_Icon_CompleteCircle, _TCC_CompleteCircle0+i);
  1037. else
  1038. ChangeDisplay2Value(_Icon_CompleteCircle, _TCC_FAILCircle0 +i);
  1039. memset(cmd, 0x00, sizeof(cmd));
  1040. memset(value, 0x00, sizeof(value));
  1041. sprintf((char *)value, "%d", soc);
  1042. string2ByteArray(value, cmd);
  1043. DisplayValueToLcm(_String_Battery, cmd, sizeof(cmd));
  1044. }
  1045. unsigned long GetPreChargeTimeoutValue(struct timeval _sour_time)
  1046. {
  1047. struct timeval _end_time;
  1048. gettimeofday(&_end_time, NULL);
  1049. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  1050. }
  1051. void ChangeTimeValue(int time)
  1052. {
  1053. uint8_t cmd[6];
  1054. uint8_t value[6];
  1055. memset(cmd, 0x00, sizeof(cmd));
  1056. sprintf((char *) value, "%d", time);
  1057. string2ByteArray(value, cmd);
  1058. DisplayValueToLcm(_String_ChargeTime, cmd, sizeof(cmd));
  1059. }
  1060. void changeWeatherValue(int _weather)
  1061. {
  1062. switch (_weather) {
  1063. case _WEATHER_TYPE_SUN:
  1064. ChangeDisplay2Value(_Icon_Weather,_TCC_Sun);
  1065. break;
  1066. case _WEATHER_TYPE_CLOUDY:
  1067. ChangeDisplay2Value(_Icon_Weather,_TCC_Cloudy);
  1068. break;
  1069. case _WEATHER_TYPE_RAIN:
  1070. ChangeDisplay2Value(_Icon_Weather,_TCC_Rain);
  1071. break;
  1072. case _WEATHER_TYPE_THUNDER:
  1073. ChangeDisplay2Value(_Icon_Weather,_TCC_Thunder);
  1074. break;
  1075. case _WEATHER_TYPE_SNOW:
  1076. ChangeDisplay2Value(_Icon_Weather,_TCC_Snow);
  1077. break;
  1078. case _WEATHER_TYPE_FOG:
  1079. ChangeDisplay2Value(_Icon_Weather,_TCC_Fog);
  1080. break;
  1081. }
  1082. }
  1083. void changeWeekValue(int _week)
  1084. {
  1085. time_t timep;
  1086. struct tm* tm;
  1087. time(&timep);
  1088. timep += (ShmDcCommonData->TZOffset * 60);
  1089. tm = localtime(&timep);
  1090. _week = tm->tm_wday;
  1091. if (_week == 0 )
  1092. _week = 7;
  1093. ChangeDisplay2Value(_Icon_Week,_week);
  1094. }
  1095. void changeDegreeValue(int _degree)
  1096. {
  1097. char value[16];
  1098. memset(value, 0x00, sizeof(value));
  1099. sprintf((char *)value,"%d",_degree);
  1100. DisplayValueToLcm(_String_Tempture, (uint8_t *)value, sizeof(value));
  1101. }
  1102. void changeDateValue(char* _date)
  1103. {
  1104. time_t timep;
  1105. struct tm* tm;
  1106. time(&timep);
  1107. timep += (ShmDcCommonData->TZOffset * 60);
  1108. tm = localtime(&timep);
  1109. sprintf(_date, "%04d/%02d/%02d",
  1110. tm->tm_year + 1900,
  1111. tm->tm_mon + 1,
  1112. tm->tm_mday);
  1113. char value[16];
  1114. memset(value, 0x00, sizeof(value));
  1115. sprintf((char *)value,"%s",_date);
  1116. DisplayValueToLcm(_String_Date, (uint8_t *)value, sizeof(value));
  1117. }
  1118. void changeLocationValue(int _location)
  1119. {
  1120. //_location+=1000;
  1121. //log_info("location:%d",_location);
  1122. ChangeDisplay2Value(_Icon_Location,(short)_location);
  1123. }
  1124. void ShowLineRegisterCountDown()
  1125. {
  1126. int _ten, _digits;
  1127. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  1128. if (pDcChargingInfo->TimeoutFlag == Timeout_LineReigster) {
  1129. _ten = (TCC_LINEREGISTER_TIMEOUT - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) / 10;
  1130. _digits = (TCC_LINEREGISTER_TIMEOUT - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) % 10;
  1131. ChangeDisplay2Value(_Icon_ScanCntDownTen, (short)_TCC_CntDownNumber0+_ten);
  1132. ChangeDisplay2Value(_Icon_ScanCntDownDigits, (short)_TCC_CntDownNumber0+ _digits);
  1133. } else {
  1134. log_info("Not get Line Register Count Down");
  1135. }
  1136. }
  1137. void ShowAuthorizeCountDown()
  1138. {
  1139. int _ten, _digits;
  1140. if (pSysInfo->SystemTimeoutFlag == Timeout_ScanCard) {
  1141. _ten = (TCC_SCANCARD_TIMEOUT - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL)) / 10;
  1142. _digits = (TCC_SCANCARD_TIMEOUT - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL)) % 10;
  1143. ChangeDisplay2Value(_Icon_AuthCntDownTen, (short)_TCC_CntDownNumber0 + _ten);
  1144. ChangeDisplay2Value(_Icon_AuthCntDownDigits, (short)_TCC_CntDownNumber0 + _digits);
  1145. }
  1146. else {
  1147. log_info("Not get Line Register Count Down");
  1148. }
  1149. }
  1150. void changeGunType()
  1151. {
  1152. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
  1153. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  1154. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  1155. ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CCS1);
  1156. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  1157. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  1158. ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CCS2);
  1159. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  1160. ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CHAdeMo);
  1161. }
  1162. // Set Right Gun
  1163. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1164. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  1165. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  1166. ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CCS1);
  1167. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  1168. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  1169. ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CCS2);
  1170. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  1171. ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CHAdeMo);
  1172. }
  1173. }
  1174. int old_money = 0;
  1175. int ClearQR_flag[2];
  1176. void ProcessPageInfo()
  1177. {
  1178. if (ShmDcCommonData->CreditCardUpload) {
  1179. pSysInfo->SystemPage = _PAGE_PAYING;
  1180. }
  1181. // Show Gun Working and Type
  1182. if (pSysInfo->SystemPage == _PAGE_IDLE) {
  1183. changeWeatherValue(ShmDcCommonData->WeatherID);
  1184. changeWeekValue(0);
  1185. changeDegreeValue((int)ShmDcCommonData->Temperature);
  1186. changeDateValue(&ShmDcCommonData->PresentTime[0]);
  1187. changeLocationValue(1000);
  1188. changeGunType();
  1189. ClearQR_flag[pSysInfo->CurGunSelected] = FALSE;
  1190. return;
  1191. }
  1192. if (pSysInfo->SystemPage == _PAGE_MAINTAIN) {
  1193. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
  1194. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  1195. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  1196. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_Off);
  1197. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  1198. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  1199. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_Off);
  1200. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  1201. ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_Off);
  1202. }
  1203. // Set Right Gun
  1204. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
  1205. if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
  1206. pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
  1207. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_Off);
  1208. } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
  1209. pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
  1210. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_Off);
  1211. } else if (pDcChargingInfo->Type == _Type_Chademo) {
  1212. ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off);
  1213. }
  1214. ChangeQrCode_Error();
  1215. return;
  1216. }
  1217. showGunWorkingType();
  1218. for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
  1219. if (pSysInfo->CurGunSelected == i) {
  1220. pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
  1221. if (pDcChargingInfo->SystemStatus == S_IDLE) {
  1222. _everyPageRollChange = 0;
  1223. _Text_Running_Count = 1;
  1224. }
  1225. switch (pSysInfo->SystemPage) {
  1226. case _PAGE_IDLE:
  1227. ShowSelectGun();
  1228. ClearQR_flag[i] = FALSE;
  1229. break;
  1230. case _PAGE_SELECT_PAY:
  1231. if (ShmDcCommonData->TransactionInfo[i].IsDonateInvoice == TRUE) {
  1232. ChangeDisplay2Value(_Icon_WordAddFriend,_ICON_Empty);
  1233. } else
  1234. ChangeDisplay2Value(_Icon_WordAddFriend,_TCC_SelectPayMode);
  1235. StartSystemTimeoutDet(Timeout_SelectPayMode);
  1236. break;
  1237. case _PAGE_SELECT_GUN:
  1238. ShowSelectGun();
  1239. ClearQR_flag[i] = FALSE;
  1240. break;
  1241. case _PAGE_BILL:
  1242. if(ClearQR_flag[i] == FALSE) {
  1243. ClearQrCode_Idle();
  1244. ClearQR_flag[i] = TRUE;
  1245. }
  1246. ChangeQrCode_Idle((char *)pSysConfig->SystemId);
  1247. break;
  1248. case _PAGE_AUTHORIZE:
  1249. StartSystemTimeoutDet(Timeout_ScanCard);
  1250. ChangeChargingRateValue(ShmDcCommonData->ChargingRate);
  1251. ShowAuthorizeCountDown();
  1252. break;
  1253. case _PAGE_SENSING:
  1254. if (ShmDcCommonData->TradeCancel == TRUE) {
  1255. TradeRunning(FALSE);
  1256. }
  1257. else
  1258. TradeRunning(TRUE);
  1259. break;
  1260. case _PAGE_PLUGIN:
  1261. _everyPageRollChange = 0;
  1262. break;
  1263. case _PAGE_ADD_FRIEND:
  1264. ShowLineRegisterCountDown();
  1265. break;
  1266. case _PAGE_PRECHARGE:
  1267. RefreshProgressAnimation();
  1268. if (_everyPageRollChange == 0) {
  1269. ChangeDisplay2Value(_Icon_Precharge,_Text_Running_Count);
  1270. _Text_Running_Count >= 24 ? _Text_Running_Count = 24 : _Text_Running_Count++;
  1271. }
  1272. break;
  1273. case _PAGE_CHARGING:
  1274. if (pDcChargingInfo->PresentChargingPower >= 0 &&
  1275. pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  1276. ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower);
  1277. } else {
  1278. ChangeChargingPowerValue(0);
  1279. }
  1280. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1281. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1282. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1283. } else {
  1284. ChangeChargingEnergyValue(0);
  1285. }
  1286. if ( pDcChargingInfo->ChargingFee >= 0) {
  1287. ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
  1288. }
  1289. if (pDcChargingInfo->RemainChargingDuration >= 0 &&
  1290. pDcChargingInfo->RemainChargingDuration <= TIME_MAX_SEC) {
  1291. ChangeTimeValue(pDcChargingInfo->RemainChargingDuration/60);
  1292. } else {
  1293. ChangeTimeValue(0);
  1294. }
  1295. ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
  1296. StartSystemTimeoutDet(Timeout_ReturnViewPage);
  1297. break;
  1298. case _PAGE_COMPLETE:
  1299. case _PAGE_PAYFAIL:
  1300. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1301. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1302. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1303. } else {
  1304. ChangeChargingEnergyValue(0);
  1305. }
  1306. ChangeChargingFeeValue(ShmDcCommonData->TransactionInfo[i].Amount);
  1307. ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy);
  1308. ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
  1309. //StartSystemTimeoutDet(Timeout_ReturnViewPage);
  1310. break;
  1311. case _PAGE_PLUGOUT:
  1312. break;
  1313. case _PAGE_PAYING:
  1314. ChangeDisplay2Value(_Icon_Ani_Dot, 1);
  1315. if (ShmDcCommonData->CreditCardUpload) {
  1316. ChangeDisplay2Value(_Icon_Uploading, _TCC_Uploading);
  1317. ChangeDisplay2Value(_Icon_Paying, _ICON_Empty);
  1318. } else {
  1319. ChangeDisplay2Value(_Icon_Uploading, _ICON_Empty);
  1320. ChangeDisplay2Value(_Icon_Paying, _TCC_Paying);
  1321. }
  1322. break;
  1323. case _PAGE_EXIT:
  1324. break;
  1325. case _PAGE_MAINTAIN:
  1326. ChangeQrCode_Error();
  1327. break;
  1328. }
  1329. }
  1330. }
  1331. }
  1332. void ChangeWarningFunc()
  1333. {
  1334. uint8_t cmd[7] = {0};
  1335. uint8_t i = 0;
  1336. //uint8_t j = 0;
  1337. //log_info("ChangeWarningFunc ");
  1338. // 最多一次五筆
  1339. //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
  1340. //log_info("WarningCount = %d ", pSysWarning->WarningCount);
  1341. //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  1342. for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
  1343. log_info("Warming Code[%d]:%s",i,&pSysWarning->WarningCode[i][0]);
  1344. memset(cmd, 0x00, sizeof(cmd));
  1345. if ((i) >= 5) {
  1346. break;
  1347. }
  1348. //error code
  1349. string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
  1350. DisplayValueToLcm(_Strting_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1351. //警告標示
  1352. memset(cmd, 0x00, sizeof(cmd));
  1353. cmd[0] = 0x00;
  1354. cmd[1] = 1;
  1355. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1356. }
  1357. memset(cmd, 0x00, sizeof(cmd));
  1358. for (; i < 5; i++) {
  1359. DisplayValueToLcm(_Strting_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
  1360. DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
  1361. }
  1362. }
  1363. void ShowCabientVersionDefaultText()
  1364. {
  1365. char value[16];
  1366. memset(value, 0x00, sizeof(value));
  1367. sprintf((char *)value,"%s","Cabient:");
  1368. DisplayValueToLcm(_Version_Cabient_Name_Text, (uint8_t *)value, sizeof(value));
  1369. sprintf((char *)value,"%s","BootLoader:");
  1370. DisplayValueToLcm(_Version_Cabient_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1371. sprintf((char *)value,"%s","Kernel Fw:");
  1372. DisplayValueToLcm(_Version_Cabient_Kernel_Text, (uint8_t *)value, sizeof(value));
  1373. sprintf((char *)value,"%s","CSU Fw:");
  1374. DisplayValueToLcm(_Version_Cabient_CSU_Text, (uint8_t *)value, sizeof(value));
  1375. sprintf((char *)value,"%s","Priamry Fw:");
  1376. DisplayValueToLcm(_Version_Cabient_Priamry_Text, (uint8_t *)value, sizeof(value));
  1377. sprintf((char *)value,"%s","Relay(0) Fw:");
  1378. DisplayValueToLcm(_Version_Cabient_Relay0_Text, (uint8_t *)value, sizeof(value));
  1379. sprintf((char *)value,"%s","Relay(1) Fw:");
  1380. DisplayValueToLcm(_Version_Cabient_Relay1_Text, (uint8_t *)value, sizeof(value));
  1381. sprintf((char *)value,"%s","Fan Fw:");
  1382. DisplayValueToLcm(_Version_Cabient_Fan_Text, (uint8_t *)value, sizeof(value));
  1383. sprintf((char *)value,"%s","IP Addr:");
  1384. DisplayValueToLcm(_Version_Cabient_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1385. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number <= 12) {
  1386. sprintf((char *)value,"%s","Primary");
  1387. DisplayValueToLcm(_Version_Cabient_Primary_Text, (uint8_t *)value, sizeof(value));
  1388. sprintf((char *)value,"%s","Secondary");
  1389. DisplayValueToLcm(_Version_Cabient_Secondary_Text, (uint8_t *)value, sizeof(value));
  1390. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1391. sprintf((char *)value,"PSU(%d):",i+1);
  1392. DisplayValueToLcm(_Version_Cabient_PSU1_Text+i*0x10, (uint8_t *)value, sizeof(value));
  1393. }
  1394. }
  1395. }
  1396. void ShowDispenserVersionDefautlText()
  1397. {
  1398. char value[16];
  1399. memset(value, 0x00, sizeof(value));
  1400. sprintf((char *)value,"%s","Dispenser:");
  1401. DisplayValueToLcm(_Version_Dispenser_Name_Text, (uint8_t *)value, sizeof(value));
  1402. sprintf((char *)value,"%s","BootLoader:");
  1403. DisplayValueToLcm(_Version_Dispenser_BootLoader_Text, (uint8_t *)value, sizeof(value));
  1404. sprintf((char *)value,"%s","Kernel Fw:");
  1405. DisplayValueToLcm(_Version_Dispenser_Kernel_Text, (uint8_t *)value, sizeof(value));
  1406. sprintf((char *)value,"%s","CSU Fw:");
  1407. DisplayValueToLcm(_Version_Dispenser_CSU_Text, (uint8_t *)value, sizeof(value));
  1408. sprintf((char *)value,"%s","Relay Fw:");
  1409. DisplayValueToLcm(_Version_Dispenser_Relay_Text, (uint8_t *)value, sizeof(value));
  1410. sprintf((char *)value,"%s","Fan Fw:");
  1411. DisplayValueToLcm(_Version_Dispenser_Fan_Text, (uint8_t *)value, sizeof(value));
  1412. sprintf((char *)value,"%s","Prim Fw:");
  1413. DisplayValueToLcm(_Version_Dispenser_Priamry_Text, (uint8_t *)value, sizeof(value));
  1414. sprintf((char *)value,"%s","LCM Hw:");
  1415. DisplayValueToLcm(_Version_Dispenser_LCM_Text, (uint8_t *)value, sizeof(value));
  1416. sprintf((char *)value,"%s","LED Fw:");
  1417. DisplayValueToLcm(_Version_Dispenser_LED_Text, (uint8_t *)value, sizeof(value));
  1418. sprintf((char *)value,"%s","Connector(0):");
  1419. DisplayValueToLcm(_Version_Dispenser_Connector0_Text, (uint8_t *)value, sizeof(value));
  1420. sprintf((char *)value,"%s","Connector(1):");
  1421. DisplayValueToLcm(_Version_Dispenser_Connector1_Text, (uint8_t *)value, sizeof(value));
  1422. sprintf((char *)value,"%s","IP Addr:");
  1423. DisplayValueToLcm(_Version_Dispenser_IPAddr_Text, (uint8_t *)value, sizeof(value));
  1424. }
  1425. void ShowCabientVersion()
  1426. {
  1427. char value[16];
  1428. memset(value, 0x00, sizeof(value));
  1429. sprintf((char *)value,"%s",ShmDcCommonData->CabinetModelName);
  1430. DisplayValueToLcm(_Version_Cabient_Model_value, (uint8_t *)value, sizeof(value));
  1431. sprintf((char *)value,"%s",ShmDcCommonData->CabinetBoolLoaderVersion);
  1432. DisplayValueToLcm(_Version_Cabient_BootLoader_value, (uint8_t *)value, sizeof(value));
  1433. sprintf((char *)value,"%s",ShmDcCommonData->CabinetKernelVersion);
  1434. DisplayValueToLcm(_Version_Cabient_Kernel_value, (uint8_t *)value, sizeof(value));
  1435. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRFSystemVersion);
  1436. DisplayValueToLcm(_Version_Cabient_CSU_value, (uint8_t *)value, sizeof(value));
  1437. sprintf((char *)value,"%s",ShmDcCommonData->CabinetPrimaryVersion);
  1438. DisplayValueToLcm(_Version_Cabient_Priamry_value, (uint8_t *)value, sizeof(value));
  1439. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay0Version);
  1440. DisplayValueToLcm(_Version_Cabient_Relay0_value, (uint8_t *)value, sizeof(value));
  1441. sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay1Version);
  1442. DisplayValueToLcm(_Version_Cabient_Relay1_value, (uint8_t *)value, sizeof(value));
  1443. sprintf((char *)value,"%s",ShmDcCommonData->CabinetFanVersion);
  1444. DisplayValueToLcm(_Version_Cabient_Fan_value, (uint8_t *)value, sizeof(value));
  1445. sprintf((char *)value,"%s",ShmDcCommonData->CabinetIPAddr);
  1446. DisplayValueToLcm(_Version_Cabient_IPAddr_value, (uint8_t *)value, sizeof(value));
  1447. if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number < 12) {
  1448. for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
  1449. if (i>=6) {
  1450. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].DCVersion);
  1451. DisplayValueToLcm(_Version_Cabient_PSU_Prim7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1452. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].FPCVersion);
  1453. DisplayValueToLcm(_Version_Cabient_PSU_Sec7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
  1454. continue;
  1455. }
  1456. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].DCVersion);
  1457. DisplayValueToLcm(_Version_Cabient_PSU_Prim1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1458. sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].FPCVersion);
  1459. DisplayValueToLcm(_Version_Cabient_PSU_Sec1_value+i*0x10, (uint8_t *)value, sizeof(value));
  1460. }
  1461. }
  1462. }
  1463. void ShowDispenserVersion()
  1464. {
  1465. char value[32];
  1466. memset(value, 0x00, sizeof(value));
  1467. sprintf((char *)value,"%s",pSysConfig->ModelName);
  1468. DisplayValueToLcm(_Version_Dispenser_Model_value, (uint8_t *)value, sizeof(value));
  1469. sprintf((char *)value,"%s",pSysInfo->CsuBootLoadFwRev);
  1470. DisplayValueToLcm(_Version_Dispenser_BootLoader_value, (uint8_t *)value, sizeof(value));
  1471. sprintf((char *)value,"%s",pSysInfo->CsuKernelFwRev);
  1472. DisplayValueToLcm(_Version_Dispenser_Kernel_value, (uint8_t *)value, sizeof(value));
  1473. sprintf((char *)value,"%s",pSysInfo->CsuRootFsFwRev);
  1474. DisplayValueToLcm(_Version_Dispenser_CSU_value, (uint8_t *)value, sizeof(value));
  1475. sprintf((char *)value,"%s",pSysInfo->RelayModuleFwRev);
  1476. DisplayValueToLcm(_Version_Dispenser_Relay_value, (uint8_t *)value, sizeof(value));
  1477. sprintf((char *)value,"%s",pSysInfo->FanModuleFwRev);
  1478. DisplayValueToLcm(_Version_Dispenser_Fan_value, (uint8_t *)value, sizeof(value));
  1479. sprintf((char *)value,"%s",pSysInfo->CsuPrimFwRev);
  1480. DisplayValueToLcm(_Version_Dispenser_Priamry_value, (uint8_t *)value, sizeof(value));
  1481. sprintf((char *)value,"%s",pSysInfo->LcmHwRev);
  1482. DisplayValueToLcm(_Version_Dispenser_LCM_value, (uint8_t *)value, sizeof(value));
  1483. sprintf((char *)value,"%s",pSysInfo->LedModuleFwRev);
  1484. DisplayValueToLcm(_Version_Dispenser_LED_value, (uint8_t *)value, sizeof(value));
  1485. sprintf((char *)value,"%s",pSysInfo->Connector1FwRev);
  1486. DisplayValueToLcm(_Version_Dispenser_Connector0_value, (uint8_t *)value, sizeof(value));
  1487. sprintf((char *)value,"%s",pSysInfo->Connector2FwRev);
  1488. DisplayValueToLcm(_Version_Dispenser_Connector1_value, (uint8_t *)value, sizeof(value));
  1489. sprintf((char *)value,"%s",pSysConfig->Eth0Interface.EthIpAddress);
  1490. DisplayValueToLcm(_Version_Dispenser_IPAddr_value, (uint8_t *)value, sizeof(value));
  1491. }
  1492. /*
  1493. void InformationShow()
  1494. {
  1495. is_show = true;
  1496. if (_showInformIndex == 0 ) {
  1497. pSysInfo->PageIndex = __SHOW_CABIENT_VERSION;
  1498. } else {
  1499. pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION;
  1500. ShowDispenserVersion();
  1501. }
  1502. }
  1503. */
  1504. void DefautLayOut()
  1505. {
  1506. int i;
  1507. for (i = 0 ; i <= 0x5C ; i+=2 ) {
  1508. ChangeDisplay2Value(0x1000+i,1);
  1509. if (i==0x28 || i ==0x2A)
  1510. continue;
  1511. }
  1512. ChangeDisplay2Value(_Icon_MobilePay,0);
  1513. ChangeDisplay2Value(_Icon_CardPay,0);
  1514. ChangeDisplay2Value(0x5000,1);
  1515. //ChangeDisplay2Value(_QRCode_Service, 1);
  1516. ShowSelectGun();
  1517. }
  1518. /*
  1519. static int InitialRfidPort(void)
  1520. {
  1521. int fd = open(rfidPortName, O_RDWR);
  1522. struct termios tios;
  1523. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  1524. if (fd != FAIL) {
  1525. ioctl (fd, TCGETS, &tios);
  1526. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  1527. tios.c_lflag = 0;
  1528. tios.c_iflag = 0;
  1529. tios.c_oflag = 0;
  1530. tios.c_cc[VMIN] = 0;
  1531. tios.c_cc[VTIME] = (uint8_t) 1;
  1532. tios.c_lflag = 0;
  1533. tcflush(fd, TCIFLUSH);
  1534. ioctl(fd, TCSETS, &tios);
  1535. }
  1536. if (fd < 0) {
  1537. pAlarmCode->AlarmEvents.bits.RfidModuleCommFail = 1;
  1538. }
  1539. return fd;
  1540. }
  1541. */
  1542. void DemoFunction(int index)
  1543. {
  1544. int i;
  1545. showGunWorkingType();
  1546. switch (index) {
  1547. case 1: // _PAGE_IDLE
  1548. /*
  1549. for (i = 0; i <= 100; i++) {
  1550. changeWeatherValue(i / 20);
  1551. ChangeDisplay2Value(_Icon_Week, i / 15);
  1552. changeDegreeValue(i);
  1553. sprintf(text, "20%02d/%02d/%02d %02d:%02d:%02d", i, i, i, i, i, i);
  1554. DisplayValueToLcm(_String_Date, (uint8_t*)text, 30);
  1555. usleep(100000);
  1556. }
  1557. */
  1558. break;
  1559. case 3:
  1560. ChangeQrCode_Idle((char*)pSysConfig->SystemId);
  1561. sleep(3);
  1562. break;
  1563. case 4: //_PAGE_ADD_FRIEND
  1564. for (i = 0; i <= 10; i++) {
  1565. ChangeDisplay2Value(_Icon_ScanCntDownTen, (short)_TCC_CntDownNumber0 + i);
  1566. ChangeDisplay2Value(_Icon_ScanCntDownDigits, (short)_TCC_CntDownNumber0 + i);
  1567. usleep(100000);
  1568. }
  1569. break;
  1570. case 7: //_PAGE_AUTHORIZE
  1571. for (i = 0; i < 10; i++) {
  1572. ChangeChargingRateValue(i+i*10);
  1573. ChangeDisplay2Value(_Icon_AuthCntDownTen, (short)_TCC_CntDownNumber0 + i);
  1574. ChangeDisplay2Value(_Icon_AuthCntDownDigits, (short)_TCC_CntDownNumber0 + i);
  1575. usleep(100000);
  1576. }
  1577. break;
  1578. case 8: //_PAGE_SENSING
  1579. for (i = 0; i < 10; i++) {
  1580. ChangeDisplay2Value(_Icon_CancelCntDownTen, (short)(_TCC_CancelNum_0 + i));
  1581. ChangeDisplay2Value(_Icon_CancelCntDownDigits, (short)(_TCC_CancelNum_0 + i));
  1582. usleep(100000);
  1583. }
  1584. break;
  1585. case 10: //_PAGE_PRECHARGE
  1586. for (i = 1; i <= 24; i++) {
  1587. ChangeDisplay2Value(_Icon_Precharge, i);
  1588. usleep(100000);
  1589. }
  1590. break;
  1591. case 11: //_PAGE_CHARGING
  1592. for (i = 0; i <= 100; i++) {
  1593. ChangeChargingPowerValue(i);
  1594. ChangeChargingEnergyValue(i);
  1595. ChangeChargingFeeValue(i);
  1596. ChangeTimeValue(i);
  1597. ChangeBattMapAndValue(i);
  1598. usleep(100000);
  1599. }
  1600. break;
  1601. case 13: //_PAGE_PAYING
  1602. break;
  1603. case 14: //_PAGE_COMPLETE
  1604. case 20: //_PAGE_PAYFAIL
  1605. for (i = 0; i <= 100; i++) {
  1606. ChangeChargingEnergyValue(i);
  1607. ChangeChargingFeeValue(i);
  1608. ChangeCarBonValue(i*2);
  1609. ChangeBattMapAndValue(i);
  1610. usleep(100000);
  1611. }
  1612. break;
  1613. }
  1614. sleep(1);
  1615. }
  1616. int main(void)
  1617. {
  1618. bool defaulttext = false;
  1619. if (CreateAllCsuShareMemory() == FAIL) {
  1620. log_error("create share memory error");
  1621. return FAIL;
  1622. }
  1623. MappingGunChargingInfo("LCM Control Task");
  1624. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  1625. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  1626. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  1627. ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
  1628. ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  1629. ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  1630. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  1631. ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
  1632. struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
  1633. _port = CreateCommunicationLcmPort();
  1634. uint8_t changeWarningPriority = 0;
  1635. uint8_t curWarningCount = 255;
  1636. uint8_t light = 0x64;
  1637. ShmDcCommonData->BackLight = light;
  1638. ChangeBackLight(light);
  1639. _totalCount = pSysConfig->TotalConnectorCount;
  1640. _everyPageRollChange = 0;
  1641. //Initialization();
  1642. //printf("_LCM_COMPLETE ");
  1643. //ChangeToOtherPage(_LCM_COMPLETE);
  1644. DefautLayOut();
  1645. //return 0;
  1646. uint8_t index = 1;
  1647. ShmDcCommonData->PSU_Number = 12;
  1648. /*
  1649. CardReadFd = InitialRfidPort();
  1650. if (CardReadFd <0) {
  1651. log_info("Card Read Port open fail!");
  1652. }*/
  1653. CheckLCMPressed();
  1654. while (_port != -1) {
  1655. if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
  1656. GetCurrentPage();
  1657. sleep(1);
  1658. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1659. } else {
  1660. UpdateLcmFunction(ShmDcCommonData,_port);
  1661. if (ShmDcCommonData->BackLight != light) {
  1662. ChangeBackLight(ShmDcCommonData->BackLight);
  1663. light = ShmDcCommonData->BackLight;
  1664. log_info("Set Backlight:%d",light);
  1665. }
  1666. /*
  1667. // Warning 處理
  1668. if (curWarningCount != pSysWarning->WarningCount) {
  1669. changeWarningPriority = 0;
  1670. pSysWarning->PageIndex = 0;
  1671. curWarningCount = pSysWarning->WarningCount;
  1672. ChangeWarningFunc();
  1673. } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
  1674. // 當有兩頁 Warning 則每隔三秒改變一次
  1675. if (pSysWarning->PageIndex == 0) {
  1676. pSysWarning->PageIndex = 1;
  1677. } else {
  1678. pSysWarning->PageIndex = 0;
  1679. }
  1680. ChangeWarningFunc();
  1681. }
  1682. */
  1683. ///*
  1684. // Show Default Text
  1685. if (!defaulttext) {
  1686. ShowCabientVersionDefaultText();
  1687. ShowDispenserVersionDefautlText();
  1688. defaulttext = true;
  1689. }
  1690. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
  1691. if (pSysInfo->SystemPage == _PAGE_LINEPAYING) {
  1692. StartSystemTimeoutDet(Timeout_LINEPAYING);
  1693. }
  1694. // 頁面資訊處理
  1695. if (!ShmDcCommonData->lcmtest)
  1696. ProcessPageInfo();
  1697. else
  1698. pSysInfo->SystemPage = index;
  1699. // 換頁處理
  1700. //GetCurrentPage(); //DS60-120 add
  1701. /*
  1702. if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
  1703. InformationShow();
  1704. ChangeToOtherPage(pSysInfo->PageIndex);
  1705. usleep(100000);
  1706. continue;
  1707. } else {
  1708. if (is_show)
  1709. _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
  1710. is_show = false;
  1711. }*/
  1712. GetCurrentPage(); //DS60-120 add
  1713. ChangeCurPage();
  1714. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  1715. if (ShmDcCommonData->lcmtest) {
  1716. DemoFunction(index);
  1717. index >= 20 ? index = 1 : index++;
  1718. }
  1719. usleep(10000); //*/
  1720. /*
  1721. GetCurrentPage();
  1722. ChangeCurPage();
  1723. usleep(10000);
  1724. //*/
  1725. }
  1726. } //while
  1727. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
  1728. log_info("Close LCM Uart Port");
  1729. CloseCommunicationLcmPort();
  1730. return FAIL;
  1731. }