Module_LcmControl.c 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133
  1. /*
  2. * Module_LcmControl.c
  3. *
  4. * Created on : 2020-10-20
  5. * Update on : 2021-02-20
  6. * Author : Folus Wen, Eason Yang
  7. * Version : D0.01
  8. *
  9. */
  10. #include <sys/time.h>
  11. #include "define.h"
  12. #include "main.h"
  13. #include "lcmComm_dgus.h"
  14. //=======================================
  15. // Declare share memory
  16. //=======================================
  17. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  18. struct StatusCodeData *ShmStatusCodeData;
  19. struct OCPP16Data *ShmOCPP16Data;
  20. struct OCPP20Data *ShmOCPP20Data;
  21. struct Charger *ShmCharger;
  22. //=======================================
  23. // Declare Basic function
  24. //=======================================
  25. void trim(char *s);
  26. int mystrcmp(char *p1,char *p2);
  27. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
  28. uint8_t split(char **arr, char *str, const char *del);
  29. void string2ByteArray(uint8_t *input, uint8_t *output);
  30. //=======================================
  31. // Declare Control panel function
  32. //=======================================
  33. uint8_t getCurrentPage();
  34. void setCurrentPage(uint8_t page);
  35. void setCurrencyFromWebsite(char *unit);
  36. void setWarningStatus(uint8_t gun_index);
  37. void setAuthorizationPage(uint8_t gun_index);
  38. void setPriceFromWebsite(float monry_rate);
  39. void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode);
  40. void setPresentChargedEnergy(uint8_t gun_index);
  41. void setPresentChargingPower(uint8_t gun_index);
  42. void setBatteryPercentageValue(uint8_t gun_index);
  43. void setPresentChargedDuration(uint8_t gun_index);
  44. void setQRcodeContent(char *input, uint8_t length);
  45. void setDisplayValue(uint16_t address, uint8_t value);
  46. void setGunPluginAnimation(uint8_t gun_index);
  47. void setBatteryAnimation(uint8_t gun_index, uint8_t system_mode);
  48. void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode);
  49. void setPresentFinalCost(float cost);
  50. float getPresentFinalCost(uint8_t gun_index);
  51. void setDefaultValue(uint8_t gun_index, uint8_t system_mode);
  52. void setUserPrice(uint8_t type);
  53. void setDefaultPrice(uint8_t type);
  54. void setFinalCost(uint8_t gun_index, uint8_t type);
  55. void setCurrencyAndUnitFromBackend(uint8_t type_price,uint8_t type_currency_unit, uint8_t gun_index);
  56. void setRTC();
  57. void setRfidIcon();
  58. void setWifi4GIcon();
  59. void setQRCodeIcon();
  60. void setBackendIcon();
  61. void setEthernetIcon();
  62. void setAlarmCodeAndIcon();
  63. void setBillingFromWebsite();
  64. //=======================================
  65. // Declare Timer
  66. //=======================================
  67. #define TMR_IDX_BATTERY 0
  68. #define TMR_IDX_CONNECTION 1
  69. #define TMR_IDX_PLUGIN 2
  70. #define TMR_IDX_ALARM 3
  71. #define TMR_IDX_PRICE 4
  72. #define TMR_IDX_EMULATOR 5
  73. #define TMR_IDX_6 6
  74. #define TMR_IDX_7 7
  75. #define TMR_IDX_8 8
  76. #define TMR_IDX_9 9
  77. struct timeb startTime[AC_QUANTITY][10];
  78. #define TIME_ANIMATION_PLUGIN 1000
  79. #define TIME_ANIMATION_BATTERY 1000
  80. #define TIME_ANIMATION_CONNECTION 1000
  81. #define TIME_ANIMATION_ALARM 5000
  82. #define TIME_REFRESH_TIME 2000
  83. //=======================================
  84. // Declare Variable
  85. //=======================================
  86. uint8_t BATTERY_LEVEL_STATUS = BATTERY_LEVEL_5;
  87. uint8_t CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  88. uint8_t GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
  89. uint8_t WarningCount = 255;
  90. int Uart1Fd;
  91. //=======================================
  92. // Emulator
  93. //=======================================
  94. int PERCENTAGE;
  95. uint8_t isChange;
  96. uint8_t isEmulator = NO;
  97. uint8_t isCharging = YES;
  98. //=======================================
  99. // Record version and date
  100. //=======================================
  101. char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.17", "2021-04-28", "REV.01.00"};
  102. //=======================================
  103. // Common routine
  104. //=======================================
  105. int StoreLogMsg(const char *fmt, ...)
  106. {
  107. char Buf[4096+256];
  108. char buffer[4096];
  109. time_t CurrentTime;
  110. struct tm *tm;
  111. struct timeval tv;
  112. va_list args;
  113. va_start(args, fmt);
  114. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  115. va_end(args);
  116. memset(Buf,0,sizeof(Buf));
  117. CurrentTime = time(NULL);
  118. tm=localtime(&CurrentTime);
  119. gettimeofday(&tv, NULL); // get microseconds, 10^-6
  120. sprintf(Buf,"echo -n \'[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\' >> /Storage/SystemLog/[%04d.%02d]Module_LcmControlLog",
  121. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
  122. buffer,
  123. tm->tm_year+1900,tm->tm_mon+1);
  124. #ifdef SystemLogMessage
  125. system(Buf);
  126. #endif
  127. #ifdef ConsloePrintLog
  128. printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
  129. #endif
  130. return rc;
  131. }
  132. long long DiffTimebWithNow(struct timeb ST)
  133. {
  134. //return milli-second
  135. struct timeb ET;
  136. long long StartTime,StopTime;
  137. ftime(&ET);
  138. StartTime=(long long)ST.time;
  139. StopTime=(long long)ET.time;
  140. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  141. }
  142. int DiffTimeb(struct timeb ST, struct timeb ET)
  143. {
  144. //return milli-second
  145. unsigned int StartTime,StopTime;
  146. StartTime=(unsigned int)ST.time;
  147. StopTime=(unsigned int)ET.time;
  148. return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
  149. }
  150. void trim(char *s)
  151. {
  152. int i=0, j, k, l=0;
  153. while((s[i]==' ')||(s[i]=='\t')||(s[i]=='\n'))
  154. i++;
  155. j = strlen(s)-1;
  156. while((s[j]==' ')||(s[j]=='\t')||(s[j]=='\n'))
  157. j--;
  158. if(i==0 && j==strlen(s)-1) { }
  159. else if(i==0) s[j+1] = '\0';
  160. else {
  161. for(k=i; k<=j; k++) s[l++] = s[k];
  162. s[l] = '\0';
  163. }
  164. }
  165. void trim_string(char *s, unsigned char len)
  166. {
  167. for(unsigned char i = 0 ; i < len; i++)
  168. {
  169. if (!(s[i] =='.')&& !((s[i]>='0') && (s[i]<='9')))
  170. {
  171. s[i] = s[i + 1];
  172. strncpy(s + i, s + i + 1, len);
  173. i -= 1;
  174. len -= 1;
  175. }
  176. }
  177. s[len + 1] = '\0';
  178. }
  179. int mystrcmp(char *p1,char *p2)
  180. {
  181. while(*p1==*p2)
  182. {
  183. if(*p1=='\0' || *p2=='\0')
  184. break;
  185. p1++;
  186. p2++;
  187. }
  188. if(*p1=='\0' && *p2=='\0')
  189. return(PASS);
  190. else
  191. return(FAIL);
  192. }
  193. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
  194. {
  195. strncpy(dest, src + start, cnt);
  196. dest[cnt] = 0;
  197. }
  198. uint8_t split(char **arr, char *str, const char *del)
  199. {
  200. uint8_t result = 0;
  201. char *s = strtok(str, del);
  202. while(s != NULL)
  203. {
  204. *arr++ = s;
  205. result += 1;
  206. s = strtok(NULL, del);
  207. }
  208. return result;
  209. }
  210. void getDateTimeString(char* result)
  211. {
  212. time_t CurrentTime;
  213. struct tm *tm;
  214. CurrentTime = time(NULL);
  215. tm=localtime(&CurrentTime);
  216. sprintf(result, "%04d/%02d/%02d %02d:%02d", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min);
  217. }
  218. //=======================================
  219. // Function to page routine
  220. //=======================================
  221. void page_booting()
  222. {
  223. if(getCurrentPage() != SYSTEM_SCREEN_BOOTING)
  224. {
  225. setCurrentPage(SYSTEM_SCREEN_BOOTING);
  226. DEBUG_INFO("Setting page to booting.\n");
  227. }
  228. else
  229. {}
  230. }
  231. void page_idle(uint8_t gun_index, uint8_t system_mode)
  232. {
  233. if(getCurrentPage() != SYSTEM_SCREEN_IDLE)
  234. {
  235. setCurrentPage(SYSTEM_SCREEN_IDLE);
  236. setDefaultValue(gun_index, system_mode);
  237. DEBUG_INFO("Setting page to idle.\n");
  238. }
  239. else
  240. {
  241. setRfidIcon();
  242. setQRCodeIcon();
  243. if(isEmulator == YES)
  244. {
  245. //if(isCharging == YES)
  246. //PERCENTAGE = 0;
  247. //else
  248. //PERCENTAGE = 100;
  249. }
  250. }
  251. }
  252. void page_authorizing(uint8_t gun_index)
  253. {
  254. // CHANGE DISPLAY TO AUTHORIZATION
  255. setAuthorizationPage(gun_index);
  256. // SHOW USER ACCOUNT BALANCE WHEN THE SYSTEM IS ONLINE
  257. if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
  258. {
  259. if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
  260. {
  261. if((strcmp((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, (char *)ShmOCPP16Data->Cost.SetUserPrice.idToken) == 0) &&
  262. ((strcmp((char *)ShmOCPP16Data->Cost.SetUserPrice.idToken,"") != 0)))
  263. {
  264. // SEARCHING USER PRICE FOR ACCOUNT BALANCE
  265. setUserPrice(ACCOUNT_BALANCE);
  266. }
  267. else
  268. {
  269. // DISAPPEAR ACCOUNT BALANCE AND ICON
  270. setDisplayValue(ICON_BALANCE_WALLET, DISAPPEAR);
  271. setDisplayValue(TEXT_BALANCE, DISAPPEAR);
  272. }
  273. }
  274. else
  275. {
  276. // DISPLAY BY OCPP 2.0.1
  277. }
  278. }
  279. else
  280. {
  281. // DISAPPEAR ACCOUNT BALANCE AND ICON
  282. setDisplayValue(ICON_BALANCE_WALLET, DISAPPEAR);
  283. setDisplayValue(TEXT_BALANCE, DISAPPEAR);
  284. }
  285. }
  286. void page_preparing(uint8_t gun_index, uint8_t system_mode)
  287. {
  288. // CHECK PREPARING MODE (BS & SOCKET) / HLC
  289. if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
  290. {
  291. if((getCurrentPage() != SYSTEM_SCREEN_PREPARE_FOR_EVSE))
  292. {
  293. setCurrentPage(SYSTEM_SCREEN_PREPARE_FOR_EVSE);
  294. setDefaultValue(gun_index, system_mode);
  295. DEBUG_INFO("Setting page to prepare for EVSE.\n");
  296. }
  297. else
  298. {
  299. setConnectionAnimation(gun_index, system_mode);
  300. }
  301. }
  302. else
  303. {
  304. if((getCurrentPage() != SYSTEM_SCREEN_PREPARING))
  305. {
  306. setCurrentPage(SYSTEM_SCREEN_PREPARING);
  307. setDefaultValue(gun_index, system_mode);
  308. DEBUG_INFO("Setting page to preparing.\n");
  309. }
  310. else
  311. {
  312. setGunPluginAnimation(gun_index);
  313. }
  314. }
  315. }
  316. void page_charging(uint8_t gun_index, uint8_t system_mode)
  317. {
  318. if((getCurrentPage() != SYSTEM_SCREEN_CHARGING) && (ShmCharger->gun_info[gun_index].resultAuthorization == DEFAULT_RFID))
  319. {
  320. setCurrentPage(SYSTEM_SCREEN_CHARGING);
  321. setDefaultValue(gun_index, system_mode);
  322. DEBUG_INFO("Setting page to charging.\n");
  323. //isChange = 0;
  324. //ftime(&startTime[gun_index][TMR_IDX_EMULATOR]);
  325. }
  326. else
  327. {
  328. setAuthorizationPage(gun_index);
  329. setConnectionAnimation(gun_index, system_mode);
  330. setBatteryAnimation(gun_index, system_mode);
  331. setPresentChargedDuration(gun_index);
  332. setPresentChargedEnergy(gun_index);
  333. setPresentChargingPower(gun_index);
  334. }
  335. }
  336. void page_complete(uint8_t gun_index, uint8_t system_mode)
  337. {
  338. if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE)
  339. {
  340. setCurrentPage(SYSTEM_SCREEN_COMPLETE);
  341. DEBUG_INFO("Setting page to complete.\n");
  342. }
  343. else
  344. {
  345. setPresentChargedDuration(gun_index);
  346. setPresentChargedEnergy(gun_index);
  347. setBatteryAnimation(gun_index, system_mode);
  348. // SHOW FINAL COST AND ACCOUNT BALANCE AFTER THE END OF TRANSACTION
  349. if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
  350. {
  351. if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
  352. {
  353. setFinalCost(gun_index, TOTAL_COST);
  354. setFinalCost(gun_index, ACCOUNT_BALANCE);
  355. setCurrencyAndUnitFromBackend(FINAL_COST, ACCOUNT_BALANCE, gun_index);
  356. }
  357. else
  358. {
  359. // DISPLAY BY OCPP 2.0.1
  360. }
  361. }
  362. else
  363. {
  364. if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
  365. {
  366. // APPEAR COST AND ICON
  367. setDisplayValue(ICON_COST_COMPLETE, APPEAR);
  368. setPresentFinalCost(getPresentFinalCost(gun_index));
  369. }
  370. else
  371. {
  372. // DISAPPEAR ACCOUNT BALANCE AND ICON
  373. setDisplayValue(ICON_WALLER_COMPLETE, DISAPPEAR);
  374. setDisplayValue(TEXT_ACCOUNT_COMPLETE, DISAPPEAR);
  375. // DISAPPEAR COST AND ICON
  376. setDisplayValue(ICON_COST_COMPLETE, DISAPPEAR);
  377. setDisplayValue(TEXT_COST_COMPLETE, DISAPPEAR);
  378. // DISAPPEAR BALANCE CURRENCY UNIT
  379. setDisplayValue(TEXT_CURRENCY_COMPLETE, DISAPPEAR);
  380. }
  381. }
  382. }
  383. }
  384. void page_terminating(uint8_t gun_index, uint8_t system_mode)
  385. {
  386. if((getCurrentPage() != SYSTEM_SCREEN_TERMINATING) && (ShmCharger->gun_info[gun_index].resultAuthorization == DEFAULT_RFID))
  387. {
  388. setCurrentPage(SYSTEM_SCREEN_TERMINATING);
  389. setDefaultValue(gun_index, system_mode);
  390. DEBUG_INFO("Setting page to terminating.\n");
  391. }
  392. else
  393. {
  394. setAuthorizationPage(gun_index);
  395. setConnectionAnimation(gun_index, system_mode);
  396. setBatteryAnimation(gun_index, system_mode);
  397. setPresentChargedDuration(gun_index);
  398. setPresentChargedEnergy(gun_index);
  399. setPresentChargingPower(gun_index);
  400. if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
  401. {
  402. if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
  403. {
  404. setFinalCost(gun_index, TOTAL_COST);
  405. setFinalCost(gun_index, ACCOUNT_BALANCE);
  406. setCurrencyAndUnitFromBackend(FINAL_COST, ACCOUNT_BALANCE, gun_index);
  407. }
  408. else
  409. {
  410. // DISPLAY BY OCPP 2.0.1
  411. }
  412. }
  413. else
  414. {
  415. // DISAPPEAR ACCOUNT BALANCE AND ICON
  416. setDisplayValue(ICON_WALLER_COMPLETE, DISAPPEAR);
  417. setDisplayValue(TEXT_ACCOUNT_COMPLETE, DISAPPEAR);
  418. // DISAPPEAR COST ADN ICON
  419. setDisplayValue(ICON_COST_COMPLETE, DISAPPEAR);
  420. setDisplayValue(TEXT_COST_COMPLETE, DISAPPEAR);
  421. // DISAPPEAR BALANCE CURRENCY UNIT
  422. setDisplayValue(TEXT_CURRENCY_COMPLETE, DISAPPEAR);
  423. }
  424. }
  425. }
  426. void page_alarm()
  427. {
  428. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip != ON)
  429. {
  430. if(getCurrentPage() != SYSTEM_SCREEN_MAINTAIN)
  431. {
  432. setCurrentPage(SYSTEM_SCREEN_MAINTAIN);
  433. DEBUG_INFO("Setting page to repair man.\n");
  434. }
  435. else
  436. {}
  437. }
  438. else
  439. {
  440. if(getCurrentPage() != SYSTEM_SCREEN_EMERGENCY)
  441. {
  442. setCurrentPage(SYSTEM_SCREEN_EMERGENCY);
  443. DEBUG_INFO("Setting page to emergency.\n");
  444. }
  445. else
  446. {}
  447. }
  448. }
  449. void page_fault()
  450. {
  451. //DEBUG_INFO("Page fault.\n");
  452. }
  453. void page_maintain()
  454. {
  455. if(getCurrentPage() != SYSTEM_SCREEN_MAINTAIN)
  456. {
  457. setCurrentPage(SYSTEM_SCREEN_MAINTAIN);
  458. DEBUG_INFO("Setting page to maintain.\n");
  459. }
  460. else
  461. {}
  462. }
  463. void page_update()
  464. {
  465. if(getCurrentPage() != SYSTEM_SCREEN_MAINTAIN)
  466. {
  467. setCurrentPage(SYSTEM_SCREEN_MAINTAIN);
  468. DEBUG_INFO("Setting page to update.\n");
  469. }
  470. else
  471. {}
  472. }
  473. void page_reservation()
  474. {
  475. //DEBUG_INFO("Page reservation.\n");
  476. }
  477. void page_booking()
  478. {
  479. //DEBUG_INFO("Page booking.\n");
  480. }
  481. void page_debug()
  482. {
  483. if(getCurrentPage() != SYSTEM_SCREEN_MAINTAIN)
  484. {
  485. setCurrentPage(SYSTEM_SCREEN_MAINTAIN);
  486. DEBUG_INFO("Setting page to debug.\n");
  487. }
  488. else
  489. {}
  490. }
  491. void page_unknown()
  492. {
  493. //DEBUG_INFO("Page unknown.\n");
  494. }
  495. void page_header(uint8_t gun_index, uint8_t system_mode)
  496. {
  497. setEthernetIcon();
  498. setBackendIcon();
  499. setWifi4GIcon();
  500. setWarningStatus(gun_index);
  501. // CHANGE LCD BRIGHNESS ( POWER SAVING MODE )
  502. if((ShmCharger->isLcdOn == ON))
  503. setDisplayValue(REG_ADDRESS_WRITE_BRIGHTNESS,BRIGHTNESS_100);
  504. else
  505. setDisplayValue(REG_ADDRESS_WRITE_BRIGHTNESS,BRIGHTNESS_10);
  506. // SET BILLING
  507. if((ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON) && (ShmSysConfigAndInfo->SysInfo.OcppConnStatus != ON))
  508. {
  509. setBillingFromWebsite();
  510. }
  511. else
  512. {
  513. // EVERY 2 SECONDS TO UPDATE PRICE
  514. if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PRICE]) > (TIME_REFRESH_TIME))
  515. {
  516. ftime(&startTime[gun_index][TMR_IDX_PRICE]);
  517. setBillingFromBackend(gun_index, system_mode);
  518. }
  519. }
  520. }
  521. void page_footer()
  522. {
  523. setRTC();
  524. }
  525. //=======================================
  526. // Setting icon display value
  527. //=======================================
  528. void setDisplayValue(uint16_t address, uint8_t value)
  529. {
  530. uint8_t data[2];
  531. data[0] = value >> 8;
  532. data[1] = value & 0X00FF;
  533. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, address, data, ARRAY_SIZE(data));
  534. }
  535. //=======================================
  536. // Getting current page
  537. //=======================================
  538. uint8_t getCurrentPage()
  539. {
  540. uint8_t currentPage[2];
  541. uint8_t result = 255;
  542. if(lcdRegisterRead(Uart1Fd, REG_TYPE_CONTROL, REG_ADDRESS_READ_PAGE_ID, currentPage, ARRAY_SIZE(currentPage)))
  543. {
  544. result = currentPage[1];
  545. // DEBUG_INFO("currentPage[0] : %X\n", currentPage[0]);
  546. // DEBUG_INFO("currentPage[1] : %X\n", currentPage[1]);
  547. // DEBUG_INFO("Getting current page : [%d] \n", result);
  548. }
  549. else
  550. {
  551. DEBUG_INFO("Getting current page fail! \n");
  552. }
  553. return result;
  554. }
  555. //=======================================
  556. // Setting current page
  557. //=======================================
  558. void setCurrentPage(uint8_t page)
  559. {
  560. uint8_t settingPage[2] = {0x00, page};
  561. if(lcdRegisterWrite(Uart1Fd, REG_TYPE_CONTROL, REG_ADDRESS_SET_PAGE_ID, settingPage, ARRAY_SIZE(settingPage)))
  562. DEBUG_INFO("Setting current page to : [%d] \n", page);
  563. else
  564. DEBUG_INFO("Setting current page fail! \n");
  565. }
  566. //=======================================
  567. // Convert string to byte array
  568. //=======================================
  569. void string2ByteArray(unsigned char *input, uint8_t *output)
  570. {
  571. int loop;
  572. int i;
  573. loop = 0;
  574. i = 0;
  575. while(input[loop] != '\0')
  576. {
  577. output[i++] = input[loop++];
  578. }
  579. output[loop] = '\0';
  580. }
  581. //=======================================
  582. // Setting ETHERNET icon status
  583. //=======================================
  584. void setEthernetIcon()
  585. {
  586. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet == ON)
  587. setDisplayValue(ICON_ETHERENT_CONNECTION, ETHERENT_OFFLINE);
  588. else
  589. setDisplayValue(ICON_ETHERENT_CONNECTION, EHTERNET_ONLINE);
  590. }
  591. //=======================================
  592. // Setting BACKEND icon status
  593. //=======================================
  594. void setBackendIcon()
  595. {
  596. if(ShmSysConfigAndInfo->SysInfo.OcppConnStatus != ON)
  597. setDisplayValue(ICON_BACKEND_CONNECTION,BACKEND_OFFLINE);
  598. else
  599. setDisplayValue(ICON_BACKEND_CONNECTION,BACKEND_ONLINE);
  600. }
  601. //=======================================
  602. // Setting WIFI / 4G icon status
  603. //=======================================
  604. void setWifi4GIcon()
  605. {
  606. // SET WIFI + 4G ICON STATUS ( ONLINE OR OFFLINE )
  607. if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')
  608. {
  609. if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == DISABLE_WIFI)
  610. {
  611. if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == DISABLE_4G)
  612. {
  613. setDisplayValue(ICON_WIFI_CONNECTION, DISAPPEAR);
  614. setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
  615. }
  616. else
  617. {
  618. setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
  619. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi == ON)
  620. setDisplayValue(ICON_WIFI_CONNECTION, TELECOM_OFFLINE);
  621. else
  622. setDisplayValue(ICON_WIFI_CONNECTION, TELECOM_ONLINE);
  623. }
  624. }
  625. else
  626. {
  627. if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == WIFI_STATION)
  628. {
  629. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)
  630. setDisplayValue(ICON_WIFI_CONNECTION, WIFI_OFFLINE);
  631. else
  632. setDisplayValue(ICON_WIFI_CONNECTION, WIFI_ONLINE);
  633. }
  634. else
  635. setDisplayValue(ICON_WIFI_CONNECTION, WIFI_OFFLINE);
  636. if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == DISABLE_4G)
  637. {
  638. setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
  639. }
  640. else
  641. {
  642. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi == ON)
  643. setDisplayValue(ICON_4G_CONNECTION, TELECOM_OFFLINE);
  644. else
  645. setDisplayValue(ICON_4G_CONNECTION, TELECOM_ONLINE);
  646. }
  647. }
  648. }
  649. else
  650. {
  651. // SET 4G ICON STATUS ( ONLINE OR OFFLINE )
  652. if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T')
  653. {
  654. switch(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled)
  655. {
  656. case DISABLE_4G:
  657. setDisplayValue(ICON_WIFI_CONNECTION, DISAPPEAR);
  658. setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
  659. break;
  660. case ENABLE_4G:
  661. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi == ON)
  662. setDisplayValue(ICON_WIFI_CONNECTION, TELECOM_OFFLINE);
  663. else
  664. setDisplayValue(ICON_WIFI_CONNECTION, TELECOM_ONLINE);
  665. break;
  666. default:
  667. break;
  668. }
  669. }
  670. // SET WIFI ICON STATUS ( ONLINE OR OFFLINE)
  671. if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W')
  672. {
  673. switch(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode)
  674. {
  675. case DISABLE_WIFI:
  676. setDisplayValue(ICON_WIFI_CONNECTION, DISAPPEAR);
  677. setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
  678. break;
  679. case WIFI_STATION:
  680. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)
  681. setDisplayValue(ICON_WIFI_CONNECTION, WIFI_OFFLINE);
  682. else
  683. setDisplayValue(ICON_WIFI_CONNECTION, WIFI_ONLINE);
  684. break;
  685. case WIFI_ACCESS_POINT:
  686. setDisplayValue(ICON_WIFI_CONNECTION, WIFI_OFFLINE);
  687. break;
  688. default:
  689. break;
  690. }
  691. }
  692. }
  693. }
  694. //=======================================
  695. // Setting billing ( WEB PAGE )
  696. //=======================================
  697. void setBillingFromWebsite()
  698. {
  699. if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
  700. {
  701. setDisplayValue(ICON_PRICE, APPEAR);
  702. struct timeb csuTime;
  703. struct tm *tmCSU;
  704. ftime(&csuTime);
  705. tmCSU = localtime(&csuTime.time);
  706. if(tmCSU->tm_hour <= 23)
  707. {
  708. ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = ShmSysConfigAndInfo->SysConfig.BillingData.Fee[tmCSU->tm_hour];
  709. setPriceFromWebsite(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
  710. }
  711. // CURRENCY UNIT ( 53 COUNTRIES )
  712. if(ShmSysConfigAndInfo->SysConfig.BillingData.Currency <= 53)
  713. {
  714. setCurrencyFromWebsite((char *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
  715. }
  716. }
  717. else
  718. {
  719. setDisplayValue(ICON_PRICE, DISAPPEAR);
  720. setDisplayValue(TEXT_CURRENCY_UNIT, DISAPPEAR);
  721. setDisplayValue(TEXT_PRICE, DISAPPEAR);
  722. }
  723. }
  724. //=======================================
  725. // Setting currency ( WEB PAGE )
  726. //=======================================
  727. void setCurrencyFromWebsite(char *unit)
  728. {
  729. uint8_t data[16];
  730. uint8_t currency[16];
  731. unsigned char kWh [16];
  732. memset(data, 0x00, ARRAY_SIZE(data));
  733. memset(currency, 0x00, ARRAY_SIZE(currency));
  734. strcpy((char*)kWh, "/kWh");
  735. *(unit + 3) = '\0';
  736. sprintf((char *) currency, "%s%s", unit,kWh);
  737. string2ByteArray(currency, data);
  738. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CURRENCY_UNIT, data, ARRAY_SIZE(data));
  739. }
  740. //=======================================
  741. // Setting price ( WEB PAGE )
  742. //=======================================
  743. void setPriceFromWebsite(float monry_rate)
  744. {
  745. uint8_t data[16];
  746. uint8_t price[16];
  747. memset(data, 0x00, ARRAY_SIZE(data));
  748. memset(price, 0x00, ARRAY_SIZE(price));
  749. sprintf((char *)price, "%.2f", monry_rate);
  750. string2ByteArray(price, data);
  751. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRICE, data, ARRAY_SIZE(data));
  752. }
  753. //=======================================
  754. // Setting final cost
  755. //=======================================
  756. void setPresentFinalCost(float cost)
  757. {
  758. uint8_t data[16];
  759. uint8_t finalCost[16];
  760. memset(data, 0x00, ARRAY_SIZE(data));
  761. memset(finalCost, 0x00, ARRAY_SIZE(finalCost));
  762. sprintf((char *)finalCost, "%.2f", cost);
  763. string2ByteArray(finalCost, data);
  764. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_COST_COMPLETE, data, ARRAY_SIZE(data));
  765. }
  766. //=======================================
  767. // Getting final cost
  768. //=======================================
  769. float getPresentFinalCost(uint8_t gun_index)
  770. {
  771. float result = 0.0f;
  772. for(int idx=0;idx<ARRAY_SIZE(ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod);idx++)
  773. {
  774. result += ((ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod[idx]/10) * ShmSysConfigAndInfo->SysConfig.BillingData.Fee[idx]);
  775. }
  776. return result;
  777. }
  778. //=======================================
  779. // Setting billing ( BACKEND )
  780. //=======================================
  781. void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode)
  782. {
  783. if((system("pidof -s OcppBackend > /dev/null") != 0))
  784. {
  785. // DISAPPEAR PRICE ICON, PRICE TEXT AND CURRENCY TEXT
  786. setDisplayValue(ICON_PRICE, DISAPPEAR);
  787. setDisplayValue(TEXT_PRICE, DISAPPEAR);
  788. setDisplayValue(TEXT_CURRENCY_UNIT, DISAPPEAR);
  789. }
  790. else
  791. {
  792. if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
  793. {
  794. if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
  795. {
  796. if((strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData,"") != 0))
  797. {
  798. if(system_mode == SYS_MODE_IDLE)
  799. {
  800. /*
  801. * 1. SEARCHING DEFAULT PRICE FOR PRICE TEXT
  802. * 2. SEARCHING DEFAULT PRICE FOR CURRENCY AND UNIT TO APPEAR
  803. */
  804. setDefaultPrice(CURRENT_RATE);
  805. setCurrencyAndUnitFromBackend(DEFAULE_PRICE, CURRENT_RATE, gun_index);
  806. }
  807. else
  808. {
  809. /*
  810. * 1. IF STARTUSERID IS NOT MATCH WITH IDTOKEN ALSO VALUE CAN'T BE NULL, OTHERWISE THE SYSTEM MUST USE DEFAULT PRICE
  811. */
  812. if((strcmp((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, (char *)ShmOCPP16Data->Cost.SetUserPrice.idToken) == 0) &&
  813. ((strcmp((char *)ShmOCPP16Data->Cost.SetUserPrice.idToken,"") != 0)))
  814. {
  815. /*
  816. * 1. SEARCHING USER PRICE FOR PRICE TEXT
  817. * 2. SEARCHING USER PRICE FOR URRENCY AND UNIT TO APPEAR
  818. */
  819. setUserPrice(CURRENT_RATE);
  820. setCurrencyAndUnitFromBackend(SET_USER_PRICE, CURRENT_RATE,gun_index);
  821. }
  822. else
  823. {
  824. /*
  825. * 1. SEARCHING DEFAULT PRICE FOR PRICE TEXT
  826. * 2. SEARCHING DEFAULT PRICE FOR CURRENCY AND UNIT TO APPEAR
  827. */
  828. setDefaultPrice(CURRENT_RATE);
  829. setCurrencyAndUnitFromBackend(DEFAULE_PRICE, CURRENT_RATE, gun_index);
  830. }
  831. }
  832. }
  833. else
  834. {
  835. // DISAPPEAR PRICE ICON, PRICE TEXT AND CURRENCY TEXT
  836. setDisplayValue(ICON_PRICE, DISAPPEAR);
  837. setDisplayValue(TEXT_PRICE, DISAPPEAR);
  838. setDisplayValue(TEXT_CURRENCY_UNIT, DISAPPEAR);
  839. }
  840. }
  841. else
  842. {
  843. // DISPLAY BY OCPP 2.0.1
  844. }
  845. }
  846. else
  847. {
  848. // DISAPPEAR PRICE ICON, PRICE TEXT AND CURRENCY TEXT
  849. setDisplayValue(ICON_PRICE, DISAPPEAR);
  850. setDisplayValue(TEXT_PRICE, DISAPPEAR);
  851. setDisplayValue(TEXT_CURRENCY_UNIT, DISAPPEAR);
  852. }
  853. }
  854. }
  855. //=======================================
  856. // Setting UserPrice ( BACKEND )
  857. //=======================================
  858. void setUserPrice(uint8_t type)
  859. {
  860. uint8_t length;
  861. uint8_t Split_String_Count;
  862. uint8_t output_data[32];
  863. char input_data[32];
  864. char tmp[256];
  865. char *splitString[10];
  866. const char *Symbol = ";";
  867. memset(tmp, 0, ARRAY_SIZE(tmp));
  868. memset(input_data, 0x00, ARRAY_SIZE(input_data));
  869. memset(output_data, 0x00, ARRAY_SIZE(output_data));
  870. switch(type)
  871. {
  872. case CONNECTION_FEE:
  873. break;
  874. case CURRENT_RATE:
  875. if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Current Rate:") > 0)
  876. {
  877. // APPEAR PRICE ICON
  878. setDisplayValue(ICON_PRICE, APPEAR);
  879. // APPEAR PRICE TEXT
  880. strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
  881. Split_String_Count = split((char**)splitString, tmp, Symbol);
  882. memcpy(input_data, splitString[1], strlen(splitString[1]));
  883. length = strlen(input_data);
  884. trim_string(input_data,length);
  885. memcpy(output_data ,input_data, strlen(input_data));
  886. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRICE, output_data, ARRAY_SIZE(output_data));
  887. }
  888. else
  889. {
  890. // DISAPPEAR PRICE ICON AND PRICE TEXT
  891. setDisplayValue(ICON_PRICE, DISAPPEAR);
  892. setDisplayValue(TEXT_PRICE, DISAPPEAR);
  893. }
  894. break;
  895. case OCCUPANCY_FEE:
  896. break;
  897. case ACCOUNT_BALANCE:
  898. if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Account Balance:") > 0)
  899. {
  900. // APPEAR ACCOUNT BALANCE ICON
  901. setDisplayValue(ICON_BALANCE_WALLET, APPEAR);
  902. // APPEAR ACCOUNT BALANCE TEXT
  903. strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
  904. Split_String_Count = split((char**)splitString, tmp, Symbol);
  905. memcpy(input_data, splitString[3], strlen(splitString[3]));
  906. length = strlen(input_data);
  907. trim_string(input_data,length);
  908. memcpy(output_data ,input_data, strlen(input_data));
  909. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_BALANCE, output_data, ARRAY_SIZE(output_data));
  910. }
  911. else
  912. {
  913. // DISAPPEAR BALANCE ICON AND BALANCE TEXT
  914. setDisplayValue(ICON_BALANCE_WALLET, DISAPPEAR);
  915. setDisplayValue(TEXT_BALANCE, DISAPPEAR);
  916. }
  917. break;
  918. default:
  919. break;
  920. }
  921. }
  922. //=======================================
  923. // Setting DefaultPrice ( BACKEND )
  924. //=======================================
  925. void setDefaultPrice(uint8_t type)
  926. {
  927. uint8_t length;
  928. uint8_t Split_String_Count;
  929. uint8_t output_data[32];
  930. char input_data[32];
  931. char tmp[256];
  932. char *splitString[10];
  933. const char *Symbol = ";";
  934. memset(tmp, 0, ARRAY_SIZE(tmp));
  935. memset(input_data, 0x00, ARRAY_SIZE(input_data));
  936. memset(output_data, 0x00, ARRAY_SIZE(output_data));
  937. switch(type)
  938. {
  939. case CONNECTION_FEE:
  940. break;
  941. case CURRENT_RATE:
  942. if(strstr((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData, "Current Rate:") > 0)
  943. {
  944. // APPEAR PRICE ICON
  945. setDisplayValue(ICON_PRICE, APPEAR);
  946. // APPEAR PRICE TEXT
  947. strcpy((char*)tmp,(char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
  948. Split_String_Count = split((char**)splitString, tmp, Symbol);
  949. memcpy(input_data, splitString[1], strlen(splitString[1]));
  950. length = strlen(input_data);
  951. trim_string(input_data,length);
  952. memcpy(output_data ,input_data, strlen(input_data));
  953. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRICE, output_data, ARRAY_SIZE(output_data));
  954. }
  955. else
  956. {
  957. setDisplayValue(TEXT_PRICE, DISAPPEAR);
  958. setDisplayValue(ICON_PRICE, DISAPPEAR);
  959. }
  960. break;
  961. case OCCUPANCY_FEE:
  962. break;
  963. default:
  964. break;
  965. }
  966. }
  967. //=======================================
  968. // Setting FinalCost ( BACKEND )
  969. //=======================================
  970. void setFinalCost(uint8_t gun_index, uint8_t type)
  971. {
  972. uint8_t length;
  973. uint8_t Split_String_Count;
  974. uint8_t output_data[32];
  975. char input_data[32];
  976. char tmp[256];
  977. char *splitString[10];
  978. const char *Symbol = ";";
  979. memset(tmp, 0, ARRAY_SIZE(tmp));
  980. memset(output_data, 0x00, ARRAY_SIZE(output_data));
  981. memset(input_data, 0x00, ARRAY_SIZE(input_data));
  982. switch(type)
  983. {
  984. case CONNECTION_FEE:
  985. break;
  986. case SESSION_FEE:
  987. break;
  988. case OCCUPANCY_FEE:
  989. break;
  990. case TOTAL_COST:
  991. if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Total Cost:") > 0))
  992. {
  993. // APPEAR COST ICON
  994. setDisplayValue(ICON_COST_COMPLETE, APPEAR);
  995. // APPEAR COST TEXT
  996. strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
  997. Split_String_Count = split((char**)splitString, tmp, Symbol);
  998. memcpy(input_data, splitString[3], strlen(splitString[3]));
  999. length = strlen(input_data);
  1000. trim_string(input_data,length);
  1001. memcpy(output_data ,input_data, strlen(input_data));
  1002. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_COST_COMPLETE, output_data, ARRAY_SIZE(output_data));
  1003. }
  1004. else
  1005. {
  1006. // DISAPPEAR COST ICON AND COST TEXT
  1007. setDisplayValue(ICON_COST_COMPLETE, DISAPPEAR);
  1008. setDisplayValue(TEXT_COST_COMPLETE, DISAPPEAR);
  1009. }
  1010. break;
  1011. case ACCOUNT_BALANCE:
  1012. if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Account Balance:") > 0))
  1013. {
  1014. // APPEAR BALANCE ICON
  1015. setDisplayValue(ICON_WALLER_COMPLETE, APPEAR);
  1016. setDisplayValue(ICON_BALANCE_WALLET, APPEAR);
  1017. // APPEAR BALANCE TEXT
  1018. strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
  1019. Split_String_Count = split((char**)splitString, tmp, Symbol);
  1020. memcpy(input_data, splitString[4], strlen(splitString[4]));
  1021. length = strlen(input_data);
  1022. trim_string(input_data,length);
  1023. memcpy(output_data ,input_data, strlen(input_data));
  1024. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_ACCOUNT_COMPLETE, output_data, ARRAY_SIZE(output_data));
  1025. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_BALANCE, output_data, ARRAY_SIZE(output_data));
  1026. }
  1027. else
  1028. {
  1029. /*
  1030. * 1. DISAPPEAR ACCOUNT BALANCE WHEN THE SYSTEM IS COMPLETE MODE
  1031. * 2. DISAPPEAR ACCOUNT ICON WHEN THE SYSTEM IS COMPLETE MODE
  1032. */
  1033. setDisplayValue(ICON_WALLER_COMPLETE, DISAPPEAR);
  1034. setDisplayValue(TEXT_ACCOUNT_COMPLETE, DISAPPEAR);
  1035. setDisplayValue(ICON_BALANCE_WALLET, DISAPPEAR);
  1036. setDisplayValue(TEXT_BALANCE, DISAPPEAR);
  1037. }
  1038. break;
  1039. default:
  1040. break;
  1041. }
  1042. }
  1043. //=======================================
  1044. // Setting currency ( BACKEND )
  1045. //=======================================
  1046. void setCurrencyAndUnitFromBackend(uint8_t type_price ,uint8_t type_currency_unit,uint8_t gun_index)
  1047. {
  1048. uint8_t length;
  1049. uint8_t Split_String_Count;
  1050. uint8_t output_data[32];
  1051. char input_data[32];
  1052. char tmp[256];
  1053. char *splitString[10];
  1054. const char *Symbol = ";";
  1055. memset(tmp, 0, ARRAY_SIZE(tmp));
  1056. memset(input_data, 0x00, ARRAY_SIZE(input_data));
  1057. memset(output_data, 0x00, ARRAY_SIZE(output_data));
  1058. if(type_price == DEFAULE_PRICE)
  1059. {
  1060. switch(type_currency_unit)
  1061. {
  1062. case CONNECTION_FEE:
  1063. break;
  1064. case CURRENT_RATE:
  1065. if(strstr((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData, "Current Rate:") > 0)
  1066. {
  1067. strcpy((char*)tmp,(char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
  1068. Split_String_Count = split((char**)splitString, tmp, Symbol);
  1069. memcpy(input_data, splitString[1], strlen(splitString[1]));
  1070. length = strlen(input_data);
  1071. memcpy(output_data , input_data+(length-7), 7);
  1072. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CURRENCY_UNIT, output_data, ARRAY_SIZE(output_data));
  1073. }
  1074. else
  1075. {
  1076. setDisplayValue(TEXT_CURRENCY_UNIT, DISAPPEAR);
  1077. }
  1078. break;
  1079. case OCCUPANCY_FEE:
  1080. break;
  1081. default:
  1082. break;
  1083. }
  1084. }
  1085. else if(type_price == SET_USER_PRICE)
  1086. {
  1087. switch(type_currency_unit)
  1088. {
  1089. case CONNECTION_FEE:
  1090. break;
  1091. case CURRENT_RATE:
  1092. if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Current Rate:") > 0)
  1093. {
  1094. strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
  1095. Split_String_Count = split((char**)splitString, tmp, Symbol);
  1096. memcpy(input_data, splitString[1], strlen(splitString[1]));
  1097. length = strlen(input_data);
  1098. memcpy(output_data , input_data+(length-7), 7);
  1099. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CURRENCY_UNIT, output_data, ARRAY_SIZE(output_data));
  1100. }
  1101. else
  1102. {
  1103. setDisplayValue(TEXT_CURRENCY_UNIT, DISAPPEAR);
  1104. }
  1105. break;
  1106. case OCCUPANCY_FEE:
  1107. break;
  1108. case ACCOUNT_BALANCE:
  1109. break;
  1110. default:
  1111. break;
  1112. }
  1113. }
  1114. else if(type_price == FINAL_COST)
  1115. {
  1116. switch(type_currency_unit)
  1117. {
  1118. case CONNECTION_FEE:
  1119. break;
  1120. case SESSION_FEE:
  1121. break;
  1122. case OCCUPANCY_FEE:
  1123. break;
  1124. case TOTAL_COST:
  1125. break;
  1126. case ACCOUNT_BALANCE:
  1127. if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Account Balance:") > 0))
  1128. {
  1129. strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
  1130. Split_String_Count = split((char**)splitString, tmp, Symbol);
  1131. memcpy(input_data, splitString[4], strlen(splitString[4]));
  1132. length = strlen(input_data);
  1133. memcpy(output_data , input_data+(length-3), 3);
  1134. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CURRENCY_COMPLETE, output_data, ARRAY_SIZE(output_data));
  1135. }
  1136. else
  1137. {
  1138. setDisplayValue(TEXT_CURRENCY_COMPLETE, DISAPPEAR);
  1139. }
  1140. break;
  1141. default:
  1142. break;
  1143. }
  1144. }
  1145. else
  1146. {}
  1147. }
  1148. //=======================================
  1149. // Setting RTC value
  1150. //=======================================
  1151. void setRTC()
  1152. {
  1153. uint8_t data[32];
  1154. uint8_t rtc[32];
  1155. memset(data, 0x00, ARRAY_SIZE(data));
  1156. memset(rtc, 0x00, ARRAY_SIZE(rtc));
  1157. getDateTimeString((char*)rtc);
  1158. string2ByteArray(rtc, data);
  1159. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_RTC, data, ARRAY_SIZE(data));
  1160. }
  1161. //=======================================
  1162. // Setting RFID icon status
  1163. //=======================================
  1164. void setRfidIcon()
  1165. {
  1166. //=======================================
  1167. // AX-Series Generation 1
  1168. //=======================================
  1169. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A') &&
  1170. (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'X') &&
  1171. (ShmSysConfigAndInfo->SysConfig.ModelName[11] == '1'))
  1172. {
  1173. if(ShmSysConfigAndInfo->SysConfig.isRFID == ON)
  1174. setDisplayValue(ICON_RFID, RFID_ENABLE);
  1175. else
  1176. setDisplayValue(ICON_RFID, RFID_DISABLE);
  1177. }
  1178. //=======================================
  1179. // AX-Series Generation 2/3/4
  1180. //=======================================
  1181. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A') &&
  1182. (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'X') &&
  1183. ((ShmSysConfigAndInfo->SysConfig.ModelName[11] == '2') || (ShmSysConfigAndInfo->SysConfig.ModelName[11] == '3') || (ShmSysConfigAndInfo->SysConfig.ModelName[11] == '4')))
  1184. {
  1185. if(ShmSysConfigAndInfo->SysConfig.isRFID == ON)
  1186. setDisplayValue(ICON_RFID, VISA_ENABLE);
  1187. else
  1188. setDisplayValue(ICON_RFID, VISA_DISABLE);
  1189. }
  1190. //=======================================
  1191. // AW-Series Generation
  1192. //=======================================
  1193. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A') &&
  1194. (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'W'))
  1195. {
  1196. if(ShmSysConfigAndInfo->SysConfig.isRFID == ON)
  1197. setDisplayValue(ICON_RFID, RFID_ENABLE);
  1198. else
  1199. setDisplayValue(ICON_RFID, RFID_DISABLE);
  1200. }
  1201. }
  1202. //=======================================
  1203. // Setting QRCODE icon status
  1204. //=======================================
  1205. void setQRCodeIcon()
  1206. {
  1207. uint8_t length = 0;
  1208. // QR CODE ( ENABLE / DISABLE )
  1209. if(ShmSysConfigAndInfo->SysConfig.isQRCode == ON)
  1210. {
  1211. setDisplayValue(ICON_QRCODE,QRCODE_ENABLE);
  1212. if(ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO)
  1213. {
  1214. length = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
  1215. setQRcodeContent((char *)ShmSysConfigAndInfo->SysConfig.SystemId, length);
  1216. }
  1217. else
  1218. {
  1219. length = strlen((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
  1220. setQRcodeContent((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent, length);
  1221. }
  1222. }
  1223. else
  1224. {
  1225. setDisplayValue(TEXT_QRCODE_CONTENT, DISAPPEAR);
  1226. setDisplayValue(ICON_QRCODE,QRCODE_DISABLE);
  1227. }
  1228. }
  1229. //=======================================
  1230. // Setting QR code content
  1231. //=======================================
  1232. void setQRcodeContent(char *input, uint8_t length)
  1233. {
  1234. uint8_t output[length];
  1235. int loop = 0;
  1236. input[length] = '\0';
  1237. output[length] = '\0';
  1238. while(input[loop] != '\0')
  1239. {
  1240. output[loop] = input[loop];
  1241. loop++;
  1242. }
  1243. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_QRCODE_CONTENT, output, ARRAY_SIZE(output)+1);
  1244. }
  1245. //=======================================
  1246. // Setting warning page switch
  1247. //=======================================
  1248. void setWarningStatus(uint8_t gun_index)
  1249. {
  1250. /*
  1251. * 1. WARNING COUNT IS DIFFERENT BETWEEN BEGINNING CHANGE DISPLAY
  1252. * 2. WARNING COUNT BIGGER THAN 4 AND EVERY 5 SECONDS CHANGE NEXT PAGE
  1253. */
  1254. if(WarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
  1255. {
  1256. WarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
  1257. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1258. setAlarmCodeAndIcon();
  1259. }
  1260. else if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 4 && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_ALARM]) > (TIME_ANIMATION_ALARM)))
  1261. {
  1262. ftime(&startTime[gun_index][TMR_IDX_ALARM]);
  1263. if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
  1264. {
  1265. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
  1266. }
  1267. else
  1268. {
  1269. ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
  1270. }
  1271. setAlarmCodeAndIcon();
  1272. }
  1273. }
  1274. //=======================================
  1275. // Setting alarm code and icon status
  1276. //=======================================
  1277. void setAlarmCodeAndIcon()
  1278. {
  1279. uint8_t cmd[7];
  1280. uint8_t index = 0;
  1281. for(index = 0; (index + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 4) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; index++)
  1282. {
  1283. memset(cmd, 0x00, sizeof(cmd));
  1284. if(index >= 4)
  1285. {
  1286. break;
  1287. }
  1288. // ALARM CODE TEXT (XXXXXX)
  1289. string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[index + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 4][0], cmd);
  1290. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_ALARM_CODE_1 + (index * 6), cmd, ARRAY_SIZE(cmd));
  1291. // ALARM CODE ICON STATUS (!)
  1292. memset(cmd, 0x00, sizeof(cmd));
  1293. cmd[0] = 0x00;
  1294. cmd[1] = 0x01;
  1295. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, ICON_ALARM_1 + index, cmd, 2);
  1296. }
  1297. memset(cmd, 0x00, sizeof(cmd));
  1298. for(; index < 4; index++)
  1299. {
  1300. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_ALARM_CODE_1 + (index * 6), cmd, ARRAY_SIZE(cmd));
  1301. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, ICON_ALARM_1 + index, cmd, 2);
  1302. }
  1303. }
  1304. //=======================================
  1305. // Setting Battery icon animation
  1306. //=======================================
  1307. void setBatteryAnimation(uint8_t gun_index, uint8_t system_mode)
  1308. {
  1309. switch(system_mode)
  1310. {
  1311. case SYS_MODE_IDLE:
  1312. // INITIALIZATION BATTERY ICON AND PERCENTAGE TEXT
  1313. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_EMPTY);
  1314. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_EMPTY);
  1315. setDisplayValue(TEXT_PERCENTAGE, DISAPPEAR);
  1316. break;
  1317. case SYS_MODE_CHARGING:
  1318. if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
  1319. {
  1320. if(isEmulator == YES)
  1321. {
  1322. if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_EMULATOR]) > 3000))
  1323. {
  1324. if(isCharging == YES)
  1325. PERCENTAGE++;
  1326. else
  1327. PERCENTAGE--;
  1328. ftime(&startTime[gun_index][TMR_IDX_EMULATOR]);
  1329. }
  1330. if(isCharging == YES)
  1331. {
  1332. if(PERCENTAGE > 100)
  1333. PERCENTAGE = 0;
  1334. }
  1335. else
  1336. {
  1337. if(PERCENTAGE <= 0)
  1338. PERCENTAGE = 100;
  1339. }
  1340. ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc = PERCENTAGE;
  1341. if((isChange == 0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY)))
  1342. {
  1343. isChange = 1;
  1344. }
  1345. else if((isChange == 1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY*2)))
  1346. {
  1347. isChange = 0;
  1348. ftime(&startTime[gun_index][TMR_IDX_BATTERY]);
  1349. }
  1350. }
  1351. else
  1352. {}
  1353. // SET BATTERY ANIMATION
  1354. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 20)
  1355. {
  1356. if(isChange == 0)
  1357. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_EMPTY);
  1358. else
  1359. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_20);
  1360. }
  1361. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 20) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 40))
  1362. {
  1363. if(isChange == 0)
  1364. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_20);
  1365. else
  1366. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_40);
  1367. }
  1368. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 40) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 60))
  1369. {
  1370. if(isChange == 0)
  1371. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_40);
  1372. else
  1373. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_60);
  1374. }
  1375. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 60) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 80))
  1376. {
  1377. if(isChange == 0)
  1378. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_60);
  1379. else
  1380. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_80);
  1381. }
  1382. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 80) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 100))
  1383. {
  1384. if(isChange == 0)
  1385. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_80);
  1386. else
  1387. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_100);
  1388. }
  1389. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc == 100)
  1390. {
  1391. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_100);
  1392. }
  1393. // SET BATTERY SOC VALUE
  1394. setBatteryPercentageValue(gun_index);
  1395. // SET ICON TO CHARGE OR DISCHARGE
  1396. if(isCharging == YES)
  1397. setDisplayValue(ICON_ELECTRICITY_DIRECTION, ELECTRICITY_DIRECTION_LEFT);
  1398. else
  1399. setDisplayValue(ICON_ELECTRICITY_DIRECTION, ELECTRICITY_DIRECTION_RIGHT);
  1400. }
  1401. else
  1402. {
  1403. // SET BATTERY PERCENTAGE TEXT TO DISAPPEAR
  1404. setDisplayValue(TEXT_PERCENTAGE, DISAPPEAR);
  1405. // SET BATTERY ANIMATION
  1406. if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_5))
  1407. {
  1408. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_EMPTY);
  1409. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_0;
  1410. }
  1411. else if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY)))
  1412. {
  1413. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_20);
  1414. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_1;
  1415. }
  1416. else if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY*2)))
  1417. {
  1418. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_40);
  1419. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_2;
  1420. }
  1421. else if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_2) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY*3)))
  1422. {
  1423. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_60);
  1424. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_3;
  1425. }
  1426. else if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_3) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY*4)))
  1427. {
  1428. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_80);
  1429. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_4;
  1430. }
  1431. else if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_4) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_BATTERY]) > (TIME_ANIMATION_BATTERY*5)))
  1432. {
  1433. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_100);
  1434. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_5;
  1435. ftime(&startTime[gun_index][TMR_IDX_BATTERY]);
  1436. }
  1437. }
  1438. break;
  1439. case SYS_MODE_TERMINATING:
  1440. if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
  1441. {
  1442. // SET BATTERY ANIMATION
  1443. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 20)
  1444. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_20);
  1445. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 20) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 40))
  1446. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_40);
  1447. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 40) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 60))
  1448. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_60);
  1449. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 60) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 80))
  1450. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_80);
  1451. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 80) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc <= 100))
  1452. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_100);
  1453. // SET BATTERY SOC VALUE
  1454. setBatteryPercentageValue(gun_index);
  1455. // SET ELECTRIC ARROW DIRECTION ICON DISAPPEAR
  1456. setDisplayValue(ICON_ELECTRICITY_DIRECTION, DISAPPEAR);
  1457. }
  1458. else
  1459. {
  1460. // SET BATTERY ICON TO EMPTY ICON
  1461. setDisplayValue(ICON_BATTERY_CHARGING, BATTERY_CAPACITY_EMPTY);
  1462. // SET BATTERY PERCENTAGE TO DISAPPEAR
  1463. setDisplayValue(TEXT_PERCENTAGE, DISAPPEAR);
  1464. }
  1465. break;
  1466. case SYS_MODE_COMPLETE:
  1467. if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
  1468. {
  1469. // SET BATTERY ANIMATION
  1470. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 20)
  1471. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_20);
  1472. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 20) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 40))
  1473. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_40);
  1474. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 40) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 60))
  1475. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_60);
  1476. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 60) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc < 80))
  1477. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_80);
  1478. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc >= 80) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc <= 100))
  1479. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_100);
  1480. // SET BATTERY SOC VALUE
  1481. setBatteryPercentageValue(gun_index);
  1482. // SET ELECTRIC ARROW DIRECTION ICON DISAPPEAR
  1483. setDisplayValue(ICON_ELECTRICITY_DIRECTION, DISAPPEAR);
  1484. }
  1485. else
  1486. {
  1487. // SET BATTERY ICON TO FULL BATTERY ICON
  1488. setDisplayValue(ICON_BATTERY_COMPLETE, BATTERY_SOC_100);
  1489. // SET BATTERY PERCENTAGE TO DISAPPEAR
  1490. setDisplayValue(TEXT_PERCENTAGE, DISAPPEAR);
  1491. }
  1492. break;
  1493. default:
  1494. break;
  1495. }
  1496. }
  1497. //=======================================
  1498. // Setting connection icon animation
  1499. //=======================================
  1500. void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode)
  1501. {
  1502. switch(system_mode)
  1503. {
  1504. case SYS_MODE_PREPARING:
  1505. if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
  1506. {
  1507. setDisplayValue(ICON_CONNECTION_PRECHARGING, CONNECTION_QUESTION_MARK_1);
  1508. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
  1509. }
  1510. else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
  1511. {
  1512. setDisplayValue(ICON_CONNECTION_PRECHARGING, CONNECTION_QUESTION_MARK_2);
  1513. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  1514. ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
  1515. }
  1516. break;
  1517. case SYS_MODE_CHARGING:
  1518. if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
  1519. {
  1520. setDisplayValue(ICON_CONNECTION_CHARGING, CONNECTION_ELECTRIC_MARK_1);
  1521. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
  1522. }
  1523. else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
  1524. {
  1525. setDisplayValue(ICON_CONNECTION_CHARGING, CONNECTION_ELECTRIC_MARK_2);
  1526. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  1527. ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
  1528. }
  1529. break;
  1530. case SYS_MODE_TERMINATING:
  1531. if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
  1532. {
  1533. setDisplayValue(ICON_CONNECTION_CHARGING, CONNECTION_QUESTION_MARK_1);
  1534. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
  1535. }
  1536. else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
  1537. {
  1538. setDisplayValue(ICON_CONNECTION_CHARGING, CONNECTION_QUESTION_MARK_2);
  1539. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  1540. ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
  1541. }
  1542. break;
  1543. default:
  1544. break;
  1545. }
  1546. }
  1547. //=======================================
  1548. // Setting gun plug-in animation
  1549. //=======================================
  1550. void setGunPluginAnimation(uint8_t gun_index)
  1551. {
  1552. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState != CP_STATE_B) ||
  1553. (!ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn))
  1554. {
  1555. if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN)))
  1556. {
  1557. setDisplayValue(ICON_PLUGIN_ARROW, PLUGIN_ARROW_1);
  1558. GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_1;
  1559. }
  1560. else if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN*2)))
  1561. {
  1562. setDisplayValue(ICON_PLUGIN_ARROW, PLUGIN_ARROW_2);
  1563. GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
  1564. ftime(&startTime[gun_index][TMR_IDX_PLUGIN]);
  1565. }
  1566. }
  1567. else
  1568. {
  1569. setDisplayValue(ICON_PLUGIN_ARROW, PLUGIN_ARROW_2);
  1570. }
  1571. }
  1572. //=======================================
  1573. // Setting battery SOC value
  1574. //=======================================
  1575. void setBatteryPercentageValue(uint8_t gun_index)
  1576. {
  1577. uint8_t data[16];
  1578. uint8_t soc[16];
  1579. memset(data, 0x00, ARRAY_SIZE(data));
  1580. memset(soc, 0x00, ARRAY_SIZE(soc));
  1581. sprintf((char *)soc, "%d%%", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc);
  1582. string2ByteArray(soc, data);
  1583. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PERCENTAGE, data, ARRAY_SIZE(data));
  1584. }
  1585. //=======================================
  1586. // Setting present charging power
  1587. //=======================================
  1588. void setPresentChargingPower(uint8_t gun_index)
  1589. {
  1590. uint8_t data[16];
  1591. uint8_t power[16];
  1592. memset(data, 0x00, ARRAY_SIZE(data));
  1593. memset(power, 0x00, ARRAY_SIZE(power));
  1594. sprintf((char *)power, "%.2f kW", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower);
  1595. string2ByteArray(power, data);
  1596. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_POWER_CHARGING, data, ARRAY_SIZE(data));
  1597. }
  1598. //=======================================
  1599. // Setting present charged energy
  1600. //=======================================
  1601. void setPresentChargedEnergy(uint8_t gun_index)
  1602. {
  1603. uint8_t data[16];
  1604. uint8_t energy[16];
  1605. memset(data, 0x00, ARRAY_SIZE(data));
  1606. memset(energy, 0x00, ARRAY_SIZE(energy));
  1607. sprintf((char *)energy, "%.4f kWh", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
  1608. string2ByteArray(energy, data);
  1609. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_ENERGY_CHARGING, data, ARRAY_SIZE(data));
  1610. }
  1611. //=======================================
  1612. // Setting present charged duration
  1613. //=======================================
  1614. void setPresentChargedDuration(uint8_t gun_index)
  1615. {
  1616. uint8_t data[16];
  1617. uint8_t time[16];
  1618. uint16_t hour;
  1619. uint16_t minute;
  1620. uint16_t second;
  1621. uint16_t PresentChargedDuration = ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration;
  1622. memset(data, 0x00, ARRAY_SIZE(data));
  1623. memset(time, 0x00, ARRAY_SIZE(time));
  1624. hour = (PresentChargedDuration / 3600);
  1625. minute = (PresentChargedDuration - (3600 * hour)) / 60;
  1626. second = (PresentChargedDuration - (3600 * hour) - (minute * 60));
  1627. sprintf((char *)time, "%02d:%02d:%02d", hour, minute, second);
  1628. string2ByteArray(time, data);
  1629. lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_TIMER_CHARGING, data, ARRAY_SIZE(data));
  1630. }
  1631. //=======================================
  1632. // Setting authorization page
  1633. //=======================================
  1634. void setAuthorizationPage(uint8_t gun_index)
  1635. {
  1636. switch(ShmCharger->gun_info[gun_index].resultAuthorization)
  1637. {
  1638. case VALIDATED_RFID:
  1639. if(getCurrentPage() != SYSTEM_SCREEN_AUTH_PASS)
  1640. {
  1641. setCurrentPage(SYSTEM_SCREEN_AUTH_PASS);
  1642. DEBUG_INFO("Setting page to authorizing : Validated RFID.\n");
  1643. }
  1644. else
  1645. {}
  1646. break;
  1647. case UNVALIDATED_RFID:
  1648. if(getCurrentPage() != SYSTEM_SCREEN_AUTH_FAIL)
  1649. {
  1650. setCurrentPage(SYSTEM_SCREEN_AUTH_FAIL);
  1651. DEBUG_INFO("Setting page to authorizing : Unvalidated RFID.\n");
  1652. }
  1653. else
  1654. {}
  1655. break;
  1656. case UNKNOW_RFID:
  1657. if(getCurrentPage() != SYSTEM_SCREEN_AUTH_UNKNOW)
  1658. {
  1659. setCurrentPage(SYSTEM_SCREEN_AUTH_UNKNOW);
  1660. DEBUG_INFO("Setting page to authorizing : Unknown RFID\n");
  1661. }
  1662. else
  1663. {}
  1664. break;
  1665. case DEFAULT_RFID:
  1666. break;
  1667. default:
  1668. break;
  1669. }
  1670. }
  1671. //=======================================
  1672. // Setting default values
  1673. //=======================================
  1674. void setDefaultValue(uint8_t gun_index, uint8_t system_mode)
  1675. {
  1676. switch(system_mode)
  1677. {
  1678. case SYS_MODE_BOOTING:
  1679. break;
  1680. case SYS_MODE_IDLE:
  1681. setBatteryAnimation(gun_index, system_mode);
  1682. break;
  1683. case SYS_MODE_AUTHORIZING:
  1684. break;
  1685. case SYS_MODE_PREPARING:
  1686. // DEFAULT TIMER, ICON AND STATUS OF ANIMATION. ( BS / HLC ) MODE
  1687. if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
  1688. {
  1689. setDisplayValue(ICON_CONNECTION_PRECHARGING, CONNECTION_QUESTION_MARK_1);
  1690. setDisplayValue(ICON_BATTERY_PRECHARGING, BATTERY_CAPACITY_EMPTY);
  1691. ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
  1692. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  1693. }
  1694. else
  1695. {
  1696. setDisplayValue(ICON_PLUGIN_ARROW, PLUGIN_ARROW_1);
  1697. GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
  1698. ftime(&startTime[gun_index][TMR_IDX_PLUGIN]);
  1699. }
  1700. break;
  1701. case SYS_MODE_CHARGING:
  1702. // DEFAULT TIMER, ICON AND STATUS OF ANIMATION
  1703. setDisplayValue(ICON_CONNECTION_CHARGING, CONNECTION_ELECTRIC_MARK_1);
  1704. ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
  1705. ftime(&startTime[gun_index][TMR_IDX_BATTERY]);
  1706. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  1707. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_5;
  1708. break;
  1709. case SYS_MODE_TERMINATING:
  1710. // DEFAULT TIMER, ICON AND STATUS OF ANIMATION
  1711. setDisplayValue(ICON_CONNECTION_CHARGING, CONNECTION_QUESTION_MARK_1);
  1712. ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
  1713. CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
  1714. BATTERY_LEVEL_STATUS = BATTERY_LEVEL_5;
  1715. break;
  1716. case SYS_MODE_COMPLETE:
  1717. break;
  1718. case SYS_MODE_ALARM:
  1719. break;
  1720. case SYS_MODE_FAULT:
  1721. break;
  1722. case SYS_MODE_MAINTAIN:
  1723. break;
  1724. case SYS_MODE_UPDATE:
  1725. break;
  1726. case SYS_MODE_RESERVATION:
  1727. break;
  1728. case SYS_MODE_BOOKING:
  1729. break;
  1730. case SYS_MODE_DEBUG:
  1731. break;
  1732. default:
  1733. break;
  1734. }
  1735. }
  1736. //=======================================
  1737. // Initial all share memory
  1738. //=======================================
  1739. int InitShareMemory()
  1740. {
  1741. int result = PASS;
  1742. int MeterSMId;
  1743. // Initial ShmSysConfigAndInfo
  1744. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  1745. {
  1746. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  1747. result = FAIL;
  1748. }
  1749. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  1750. {
  1751. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  1752. result = FAIL;
  1753. }
  1754. else
  1755. {}
  1756. // Initial ShmStatusCodeData
  1757. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  1758. {
  1759. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  1760. result = FAIL;
  1761. }
  1762. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  1763. {
  1764. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  1765. result = FAIL;
  1766. }
  1767. else
  1768. {}
  1769. // Initial ShmCharger
  1770. if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), 0777)) < 0)
  1771. {
  1772. DEBUG_ERROR("shmget ShmChargerKey NG\n");
  1773. result = FAIL;
  1774. }
  1775. else if ((ShmCharger = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  1776. {
  1777. DEBUG_ERROR("shmat ShmChargerKey NG\n");
  1778. result = FAIL;
  1779. }
  1780. // Initial ShmOCPP16Data
  1781. if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
  1782. {
  1783. DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
  1784. result = FAIL;
  1785. }
  1786. else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  1787. {
  1788. DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
  1789. result = FAIL;
  1790. }
  1791. // Initial ShmOCPP20Data
  1792. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  1793. {
  1794. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  1795. result = FAIL;
  1796. }
  1797. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  1798. {
  1799. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  1800. result = FAIL;
  1801. }
  1802. return result;
  1803. }
  1804. //=======================================
  1805. // Initial communication port
  1806. //=======================================
  1807. int InitComPort()
  1808. {
  1809. int fd;
  1810. struct termios tios;
  1811. fd = open("/dev/ttyS3", O_RDWR);
  1812. if(fd<=0)
  1813. {
  1814. DEBUG_ERROR("open /dev/ttyS3 NG\n");
  1815. return -1;
  1816. }
  1817. ioctl (fd, TCGETS, &tios);
  1818. tios.c_cflag = B115200| CS8 | CLOCAL | CREAD;
  1819. tios.c_lflag = 0;
  1820. tios.c_iflag = 0;
  1821. tios.c_oflag = 0;
  1822. tios.c_cc[VMIN]=0;
  1823. tios.c_cc[VTIME]=(unsigned char)5; // timeout 500ms
  1824. tios.c_lflag=0;
  1825. tcflush(fd, TCIFLUSH);
  1826. ioctl (fd, TCSETS, &tios);
  1827. return fd;
  1828. }
  1829. //=======================================
  1830. // Main process
  1831. //=======================================
  1832. int main(void)
  1833. {
  1834. uint8_t previousMode = 0xff;
  1835. if(InitShareMemory() == FAIL)
  1836. {
  1837. #ifdef SystemLogMessage
  1838. DEBUG_ERROR("InitShareMemory NG\n");
  1839. #endif
  1840. if(ShmStatusCodeData!=NULL)
  1841. {
  1842. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  1843. }
  1844. sleep(5);
  1845. return FAIL;
  1846. }
  1847. Uart1Fd=InitComPort();
  1848. if(Uart1Fd<0)
  1849. {
  1850. #ifdef SystemLogMessage
  1851. DEBUG_ERROR("InitComPort NG\n");
  1852. #endif
  1853. if(ShmStatusCodeData!=NULL)
  1854. {
  1855. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
  1856. }
  1857. sleep(5);
  1858. return FAIL;
  1859. }
  1860. else
  1861. {}
  1862. DEBUG_INFO("Initial completed\n");
  1863. DEBUG_INFO("Latest Firmware Version : [%s] \n", FIRMWARE_UPDATE_IMAGE[0]);
  1864. DEBUG_INFO("Latest Upgrade Date : [%s]. \n", FIRMWARE_UPDATE_IMAGE[1]);
  1865. DEBUG_INFO("Latest Image Version : [%s]. \n", FIRMWARE_UPDATE_IMAGE[2]);
  1866. for(;;)
  1867. {
  1868. if(previousMode != ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus)
  1869. {
  1870. previousMode = ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus;
  1871. }
  1872. switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus)
  1873. {
  1874. case SYS_MODE_BOOTING:
  1875. page_booting();
  1876. break;
  1877. case SYS_MODE_IDLE:
  1878. page_idle(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
  1879. break;
  1880. case SYS_MODE_AUTHORIZING:
  1881. page_authorizing(ShmCharger->gun_selectd);
  1882. break;
  1883. case SYS_MODE_PREPARING:
  1884. page_preparing(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
  1885. break;
  1886. case SYS_MODE_CHARGING:
  1887. page_charging(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
  1888. break;
  1889. case SYS_MODE_TERMINATING:
  1890. page_terminating(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
  1891. break;
  1892. case SYS_MODE_COMPLETE:
  1893. page_complete(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
  1894. break;
  1895. case SYS_MODE_ALARM:
  1896. page_alarm();
  1897. break;
  1898. case SYS_MODE_FAULT:
  1899. page_fault();
  1900. break;
  1901. case SYS_MODE_MAINTAIN:
  1902. page_maintain();
  1903. break;
  1904. case SYS_MODE_UPDATE:
  1905. page_update();
  1906. break;
  1907. case SYS_MODE_RESERVATION:
  1908. page_reservation();
  1909. break;
  1910. case SYS_MODE_BOOKING:
  1911. page_booking();
  1912. break;
  1913. case SYS_MODE_DEBUG:
  1914. page_debug();
  1915. break;
  1916. default:
  1917. page_unknown();
  1918. break;
  1919. }
  1920. page_header(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
  1921. page_footer();
  1922. usleep(100000);
  1923. }
  1924. return FAIL;
  1925. }