Module_LcmControl.c 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318
  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. //------------------------------------------------------------------------------
  18. //struct SysConfigAndInfo *ShmSysConfigAndInfo;
  19. //struct StatusCodeData *ShmStatusCodeData;
  20. static struct SysConfigData *pSysConfig = NULL;
  21. static struct SysInfoData *pSysInfo = NULL;
  22. static struct WARNING_CODE_INFO *pSysWarning = NULL;
  23. static struct FanModuleData *ShmFanModuleData;
  24. static struct PrimaryMcuData *ShmPrimaryMcuData;
  25. static SelectGunInfo *ShmSelectGunInfo = NULL;
  26. static struct ChargingInfoData *pDcChargingInfo = NULL;
  27. static struct ChargingInfoData *pAcChargingInfo = NULL;
  28. bool needReloadQr = true;
  29. bool _isShow = false; //DS60-120 add
  30. uint8_t _showInformIndex = 0; //DS60-120 add
  31. int _port;
  32. //char* pPortName = "/dev/ttyO2";
  33. char *pPortName = "/dev/ttyS3";
  34. char *moduleName = "DMT80480T070_09WT";
  35. uint8_t _totalCount;
  36. uint8_t acgunCount;
  37. //struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  38. //struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
  39. uint8_t ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
  40. uint8_t isDiffStatus = false;
  41. uint8_t isChangeBattMap = false;
  42. // 當前選擇的槍號
  43. #if defined DD360Audi
  44. short _currentPage = _LCM_SELECT_GUN;
  45. short _oldPage = _LCM_SELECT_GUN;
  46. #else
  47. short _currentPage = _LCM_NONE;
  48. short _oldPage = _LCM_NONE;
  49. #endif //defined DD360Audi
  50. uint8_t _gunIndex = 0;
  51. bool _wifi_conn_status = false;
  52. bool _battery_display_ani = false;
  53. uint8_t _curPage_index = 0;
  54. bool _page_reload = false;
  55. // LCM - HW
  56. uint8_t _everyPageRollChange = 0;
  57. short __conn_status = 0x0030;
  58. short __ethernet_status = 0x0032;
  59. short __3G4G_status = 0x0036;
  60. short __3G4G_status1 = 0x0037;
  61. short __3G4G_move_status = 0x0038;
  62. short __wifi_status = 0x003C;
  63. short __sel_gun_btn = 0x0040;
  64. short __ret_home_btn = 0x0042;
  65. short __stop_method_btn = 0x0044;
  66. short __qr_code = 0x0250;
  67. short __main_rfid = 0x0052;
  68. short __main_qr = 0x0054;
  69. short __main_app = 0x0056;
  70. short __plug_in_arrow = 0x0060;
  71. short __conn_line = 0x0066;
  72. short __gun_type_index = 0x0070;
  73. short __cmp_gun_type_index = 0x0080; ////For Audi
  74. short __batt_map_empty = 0x0090; ////For Audi
  75. short __qr_code_pre = 0x0280;
  76. short __side_top = 0x0090;
  77. short __side_down = 0x0092;
  78. short __side_mid = 0x0094;
  79. short __conn_line_chag = 0x0096;
  80. short __batt_map = 0x0100;
  81. short __soc_value_charging = 0x0102;
  82. short __remain_time_map = 0x0106;
  83. short __power_map = 0x0108;
  84. short __energy_map = 0x010A;
  85. short __remain_time_tx = 0x0110;
  86. short __trp_remain_time_map = 0x0116;
  87. short __trp_power_map = 0x0118;
  88. short __trp_energy_map = 0x011A;
  89. short __output_eng_tx = 0x0120;
  90. short __total_out_eng_tx = 0x0130;
  91. short __conn_line_comp = 0x0140;
  92. short __charging_fee_map = 0x0146;
  93. short __charging_fee_tx = 0x0150;
  94. short __money_by_rate = 0x0200;
  95. short __money_rate = 0x0220;
  96. short __money_rate_map = 0x0230;
  97. //DS60-120 add
  98. short __csu_ver_string = 0x0300;
  99. short __csu_ver_value = 0x0310;
  100. short __fan_speed_string = 0x0390;
  101. short __fan_speed_value = 0x0400;
  102. short __dc1_ver_string = 0x0320;
  103. short __dc1_ver_value = 0x0330;
  104. short __dc2_ver_string = 0x0340;
  105. short __dc2_ver_value = 0x0350;
  106. short __eth0_ip_string = 0x0360;
  107. short __eth0_ip_value = 0x0370;
  108. short __sn_string = 0x0410;
  109. short __sn_value = 0x0420;
  110. //For Audi, for select gun
  111. short __left_gun_map = 0x0260;
  112. short __right_gun_map = 0x0262;
  113. short __add_chk_btn = 0x0264;
  114. //short __station_id = 0x0270;
  115. short __balance = 0x0270;
  116. short __remain_balance = 0x0280;
  117. short __custStationIdL1 = 0x0450;
  118. //short __custStationIdL2 = 0x0470;
  119. short _emergency_map = 0x011C;
  120. // ICON ID
  121. uint8_t _disappear = 0;
  122. uint8_t _disconnect = 1;
  123. uint8_t _connect = 2;
  124. uint8_t _warning = 3;
  125. uint8_t _arrow_dark = 4;
  126. uint8_t _arrow_light = 5;
  127. uint8_t _3G4G_disconnect = 6;
  128. uint8_t __3G4G_connect = 7;
  129. uint8_t _wifi_disconnect = 8;
  130. uint8_t _wifi_connect = 9;
  131. uint8_t _logo = 10;
  132. uint8_t _conn_map1 = 11;
  133. uint8_t _conn_map2 = 12;
  134. uint8_t _sel_gun_btn = 13;
  135. uint8_t _back_home_btn = 14;
  136. uint8_t _stop_charging_btn = 15;
  137. uint8_t _stop_charging_btn_scan = 16;
  138. uint8_t _chademo_dark = 17;
  139. uint8_t _ccs_dark = 18;
  140. uint8_t _gbt_dark = 19;
  141. uint8_t _actype_dark = 20;
  142. uint8_t _chademo_light = 21;
  143. uint8_t _ccs_light = 22;
  144. uint8_t _gbt_light = 23;
  145. uint8_t _actype_light = 24;
  146. uint8_t _main_none_rfid = 25;
  147. uint8_t _main_rfid = 26;
  148. uint8_t _main_none_app = 27;
  149. uint8_t _main_app = 28;
  150. uint8_t _main_none_qr = 29;
  151. uint8_t _main_qr = 30;
  152. uint8_t _charging_map1 = 31;
  153. uint8_t _charging_map2 = 32;
  154. uint8_t _battery_empty = 33;
  155. uint8_t _battery_cap_20 = 34;
  156. uint8_t _battery_cap_40 = 35;
  157. uint8_t _battery_cap_60 = 36;
  158. uint8_t _battery_cap_80 = 37;
  159. uint8_t _battery_cap_100 = 38;
  160. uint8_t _battery_map = 39;
  161. uint8_t _power_map = 40;
  162. uint8_t _time_map = 41;
  163. uint8_t _complete_map = 42;
  164. uint8_t _battery_soc_20 = 43;
  165. uint8_t _battery_soc_40 = 44;
  166. uint8_t _battery_soc_60 = 45;
  167. uint8_t _battery_soc_80 = 46;
  168. uint8_t _battery_soc_100 = 47;
  169. uint8_t _battery_eng_map = 48;
  170. uint8_t _money_map = 49;
  171. uint8_t _elapse_time_map = 50;
  172. uint8_t _charging_money = 51;
  173. //uint8_t _side_none_rfid = 52;
  174. //uint8_t _side_rfid = 53;
  175. //uint8_t _side_none_app = 54;
  176. //uint8_t _side_app = 55;
  177. //uint8_t _side_none_qr = 56;
  178. //uint8_t _side_qr = 57;
  179. uint8_t _eth_disconnect = 52; //58;
  180. uint8_t _eth_connect = 53; //59;
  181. uint8_t _chademo_dark_cmp = 54;
  182. uint8_t _ccs_dark_cmp = 55;
  183. uint8_t _gbt_dark_cmp = 56;
  184. uint8_t _actype_dark_cmp = 57;
  185. uint8_t _chademo_light_cmp = 58;
  186. uint8_t _ccs_light_cmp = 59;
  187. uint8_t _gbt_light_cmp = 60;
  188. uint8_t _actype_light_cmp = 61;
  189. uint8_t _logo_cmp = 62;
  190. uint8_t _battery_eng_trp_map = 63;
  191. uint8_t _money_trp_map = 64;
  192. uint8_t _elapse_time_trp_map = 65;
  193. ////For Audi
  194. uint8_t _left_gun_disable_map = 66;
  195. uint8_t _left_gun_enable_map = 67;
  196. uint8_t _right_gun_disable_map = 68;
  197. uint8_t _right_gun_enable_map = 69;
  198. uint8_t _select_gun_btn = 70;
  199. uint8_t _emergency_disable_map = 72;
  200. // For replug
  201. struct timespec showReplugStrTimer;
  202. short __show_replugString_value = 0x0460;
  203. uint8_t _showReplugStr_1 = 74;
  204. uint8_t _showReplugStr_2 = 75;
  205. //#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  206. //#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  207. //#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  208. //=================================
  209. // Common routine
  210. //=================================
  211. /*int StoreLogMsg(const char *fmt, ...)
  212. {
  213. char Buf[4096 + 256];
  214. char buffer[4096];
  215. va_list args;
  216. struct timeb SeqEndTime;
  217. struct tm *tm;
  218. va_start(args, fmt);
  219. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  220. va_end(args);
  221. memset(Buf, 0, sizeof(Buf));
  222. ftime(&SeqEndTime);
  223. SeqEndTime.time = time(NULL);
  224. tm = localtime(&SeqEndTime.time);
  225. if (pSysConfig->SwitchDebugFlag == YES) {
  226. sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
  227. tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
  228. printf("%s \n", Buf);
  229. } else {
  230. sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  231. tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
  232. buffer,
  233. tm->tm_year + 1900, tm->tm_mon + 1);
  234. system(Buf);
  235. }
  236. return rc;
  237. }
  238. char *getTimeString(void)
  239. {
  240. char *result = malloc(21);
  241. time_t timep;
  242. struct tm *p;
  243. time(&timep);
  244. p = gmtime(&timep);
  245. sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
  246. return result;
  247. }
  248. */
  249. #if 0
  250. //==========================================
  251. // Init all share memory
  252. //==========================================
  253. int InitShareMemory()
  254. {
  255. int result = PASS;
  256. int MeterSMId;
  257. //creat ShmSysConfigAndInfo
  258. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0) {
  259. #ifdef SystemLogMessage
  260. log_error("shmget ShmSysConfigAndInfo NG\n");
  261. #endif
  262. result = FAIL;
  263. } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  264. #ifdef SystemLogMessage
  265. log_error("shmat ShmSysConfigAndInfo NG\n");
  266. #endif
  267. result = FAIL;
  268. } else
  269. {}
  270. //creat ShmStatusCodeData
  271. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0) {
  272. #ifdef SystemLogMessage
  273. log_error("shmget ShmStatusCodeData NG\n");
  274. #endif
  275. result = FAIL;
  276. } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  277. #ifdef SystemLogMessage
  278. log_error("shmat ShmStatusCodeData NG\n");
  279. #endif
  280. result = FAIL;
  281. } else
  282. {}
  283. //creat Audi customization info
  284. if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
  285. log_error("[main]CreatShareMemory:shmget select gun info NG \n");
  286. return 0;
  287. } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  288. log_error("[main]CreatShareMemory:shmat shmget select gun info \n");
  289. return 0;
  290. }
  291. //creat ShmStatusCodeData
  292. if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
  293. #ifdef SystemLogMessage
  294. log_error("shmget ShmPrimaryMcuData NG\n");
  295. #endif
  296. result = FAIL;
  297. } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  298. #ifdef ShmPrimaryMcuData
  299. log_error("shmat ShmPrimaryMcuData NG\n");
  300. #endif
  301. result = FAIL;
  302. }
  303. return result;
  304. }
  305. #endif //0
  306. //==========================================
  307. // Open and Close RS232 and R/W
  308. //==========================================
  309. int CreateCommunicationLcmPort()
  310. {
  311. int fd;
  312. struct termios tios;
  313. fd = open(pPortName, O_RDWR);
  314. if (fd <= 0) {
  315. #ifdef SystemLogMessage
  316. log_error("open /dev/ttyS3 NG \n");
  317. #endif
  318. return -1;
  319. }
  320. ioctl(fd, TCGETS, &tios);
  321. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  322. tios.c_lflag = 0;
  323. tios.c_iflag = 0;
  324. tios.c_oflag = 0;
  325. tios.c_cc[VMIN] = 0;
  326. tios.c_cc[VTIME] = (uint8_t) 5;
  327. tios.c_lflag = 0;
  328. tcflush(fd, TCIFLUSH);
  329. ioctl(fd, TCSETS, &tios);
  330. return fd;
  331. }
  332. void CloseCommunicationLcmPort()
  333. {
  334. close(_port);
  335. }
  336. void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
  337. {
  338. int len = write(_port, cmd, cmdLen);
  339. if (len >= sizeof(cmd)) {
  340. //log_info("Write cmd to LCM successfully. \n");
  341. }
  342. }
  343. void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
  344. {
  345. read(_port, msg, readLen);
  346. if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2) {
  347. if (*(msg + 3) == CMD_WRITE) {
  348. switch (*(msg + 4)) {
  349. case CMD_REGISTER: {
  350. // 頁面
  351. strcpy((char *)pSysInfo->LcmHwRev, moduleName);
  352. }
  353. break;
  354. }
  355. } else if (*(msg + 3) == CMD_MULTI_READ) {
  356. // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
  357. // {
  358. // case BUTTON_GUN_INDEX:
  359. // {
  360. // // 當前選的槍號
  361. // _curGunIndex = (*(msg + 8));
  362. // }
  363. // break;
  364. // }
  365. }
  366. }
  367. }
  368. //================================================
  369. // Function
  370. //================================================
  371. void ChangeToOtherPage(short newPage)
  372. {
  373. uint8_t cmd[7];
  374. memset(cmd, 0x00, sizeof(cmd));
  375. cmd[0] = CMD_TITLE_1;
  376. cmd[1] = CMD_TITLE_2;
  377. cmd[2] = 0x02 + sizeof(newPage);
  378. cmd[3] = CMD_READ;
  379. cmd[4] = CMD_REGISTER;
  380. cmd[5] = newPage >> 8;
  381. cmd[6] = newPage & 0x00FF;
  382. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  383. usleep(100000);
  384. }
  385. void ChangeBackLight(bool islight)
  386. {
  387. uint8_t value = 0x01;
  388. if (islight) {
  389. value = 0x20;
  390. }
  391. uint8_t cmd[7];
  392. memset(cmd, 0x00, sizeof(cmd));
  393. cmd[0] = CMD_TITLE_1;
  394. cmd[1] = CMD_TITLE_2;
  395. cmd[2] = 0x03;
  396. cmd[3] = CMD_READ;
  397. cmd[4] = CMD_BACKLIGHT;
  398. cmd[5] = value;
  399. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  400. usleep(100000);
  401. }
  402. void GetCurrentPage()
  403. {
  404. uint8_t cmd[6];
  405. memset(cmd, 0x00, sizeof(cmd));
  406. uint8_t msg[8];
  407. memset(msg, 0x00, sizeof(msg));
  408. cmd[0] = CMD_TITLE_1;
  409. cmd[1] = CMD_TITLE_2;
  410. cmd[2] = 0x03; // 底下總長度
  411. cmd[3] = CMD_WRITE;
  412. cmd[4] = CMD_REGISTER;
  413. cmd[5] = 0x02;
  414. WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
  415. usleep(100000);
  416. ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
  417. }
  418. void DisplayValueToLcm(short address, uint8_t *data, uint8_t len)
  419. {
  420. uint8_t cmd[256];
  421. memset(cmd, 0x00, sizeof(cmd));
  422. cmd[0] = CMD_TITLE_1;
  423. cmd[1] = CMD_TITLE_2;
  424. cmd[2] = 0x03 + len;
  425. cmd[3] = CMD_MULTI_WRITE;
  426. cmd[4] = address >> 8;
  427. cmd[5] = address & 0x00FF;
  428. for (uint8_t count = 0; count < len; count++) {
  429. cmd[6 + count] = *(data + count);
  430. }
  431. WriteCmdToLcm(cmd, cmd[2] + 3);
  432. }
  433. void ChangeDisplay2Value(short address, short value)
  434. {
  435. uint8_t data[2];
  436. data[0] = value >> 8;
  437. data[1] = value & 0x00FF;
  438. DisplayValueToLcm(address, data, sizeof(data));
  439. }
  440. void GetBtnStatus(short address, uint8_t len)
  441. {
  442. uint8_t cmd[8];
  443. memset(cmd, 0x00, sizeof(cmd));
  444. uint8_t msg[8];
  445. memset(msg, 0x00, sizeof(msg));
  446. cmd[0] = CMD_TITLE_1;
  447. cmd[1] = CMD_TITLE_2;
  448. cmd[2] = 0x03 + len;
  449. cmd[3] = CMD_MULTI_READ;
  450. cmd[4] = address >> 8;
  451. cmd[5] = address & 0x00FF;
  452. cmd[6] = 0x00 + len;
  453. WriteCmdToLcm(cmd, cmd[2] + 3);
  454. usleep(100000);
  455. ReadMsgFromLcm(msg, (len * 2) + sizeof(msg));
  456. }
  457. //================================================
  458. // Warning process
  459. //================================================
  460. void string2ByteArray(uint8_t *input, uint8_t *output)
  461. {
  462. int loop;
  463. int i;
  464. loop = 0;
  465. i = 0;
  466. while (input[loop] != '\0') {
  467. output[i++] = input[loop++];
  468. }
  469. output[loop] = '\0';
  470. }
  471. void ChangeWarningFunc()
  472. {
  473. uint8_t cmd[7] = {0};
  474. uint8_t i = 0;
  475. //uint8_t j = 0;
  476. //log_info("ChangeWarningFunc \n");
  477. // 最多一次五筆
  478. //log_info("LCM PageIndex = %d \n", pSysWarning->PageIndex);
  479. //log_info("WarningCount = %d \n", pSysWarning->WarningCount);
  480. //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  481. for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
  482. memset(cmd, 0x00, sizeof(cmd));
  483. if ((i) >= 5) {
  484. break;
  485. }
  486. //error code
  487. string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
  488. DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
  489. //警告標示
  490. memset(cmd, 0x00, sizeof(cmd));
  491. cmd[0] = 0x00;
  492. cmd[1] = 0x01;
  493. DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
  494. }
  495. memset(cmd, 0x00, sizeof(cmd));
  496. for (; i < 5; i++) {
  497. DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
  498. DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
  499. }
  500. /*#else
  501. for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
  502. memset(cmd, 0x00, sizeof(cmd));
  503. if ((i - j) >= 5) {
  504. break;
  505. }
  506. if (
  507. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "033900", 6) == 0) ||
  508. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "033901", 6) == 0) ||
  509. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "033902", 6) == 0) ||
  510. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043627", 6) == 0) ||
  511. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043628", 6) == 0) ||
  512. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043622", 6) == 0) ||
  513. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043623", 6) == 0) ||
  514. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043624", 6) == 0) ||
  515. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043625", 6) == 0) ||
  516. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043626", 6) == 0) ||
  517. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "042241", 6) == 0) ||
  518. (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "042242", 6) == 0)
  519. ) {
  520. j++;
  521. continue;
  522. }
  523. //error code
  524. string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
  525. DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
  526. //警告標示
  527. memset(cmd, 0x00, sizeof(cmd));
  528. cmd[0] = 0x00;
  529. cmd[1] = 0x01;
  530. DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
  531. }
  532. memset(cmd, 0x00, sizeof(cmd));
  533. i = i - j;
  534. for (; (i) < 5; i++) {
  535. DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
  536. DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
  537. }
  538. #endif //!defined DD360 && !defined DD360Audi
  539. */
  540. }
  541. //================================================
  542. // QR Code process
  543. //================================================
  544. void ChangeQrCode_Idle(char *input)
  545. {
  546. #if defined DD360Audi
  547. int len = strlen(input) + 3;
  548. int loop = 0;
  549. int i = 0, j = 0, k = 0, l = 0;
  550. uint8_t qrUrl[128] = {0};
  551. uint16_t urlLen = 0;
  552. uint8_t cmd[len];
  553. uint8_t tmpBuf[15] = {0};
  554. //uint8_t tmpLen = sizeof(tmpBuf) - 1;
  555. strncpy((char *)cmd, " ", len);
  556. while (input[loop] != '\0') {
  557. cmd[i++] = input[loop++];
  558. l = loop - 1;
  559. if (len >= 25) {
  560. if (i >= 16 && i <= 19) {
  561. tmpBuf[k++] = input[l];
  562. //printf("tmpBuf = %s\r\n", tmpBuf);
  563. } else if (i >= 21 && i <= 23) {
  564. tmpBuf[k++] = input[l];
  565. }
  566. }
  567. }
  568. tmpBuf[k] = '\0';
  569. //printf("tmpBuf = %s\r\n", tmpBuf);
  570. j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
  571. cmd[len - 1] = '\0';
  572. urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
  573. qrUrl[urlLen] = '\0';
  574. //printf("qr url = %s\r\n", qrUrl);
  575. DisplayValueToLcm(__qr_code, qrUrl, urlLen);
  576. j = 0;
  577. j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
  578. tmpBuf[k + j] = '\0';
  579. //if (len < 25) {
  580. // strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  581. //}
  582. //tmpBuf[tmpLen] = '\0';
  583. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  584. /*if (len > sizeof(tmpBuf)) {
  585. strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  586. tmpBuf[tmpLen] = '\0';
  587. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  588. memset(tmpBuf, 0, sizeof(tmpBuf));
  589. strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
  590. tmpBuf[tmpLen] = '\0';
  591. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  592. } else {
  593. DisplayValueToLcm(__custStationIdL1, cmd, len);
  594. strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
  595. tmpBuf[tmpLen] = '\0';
  596. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  597. }*/
  598. #else
  599. int len = strlen(input);
  600. uint8_t cmd[len];
  601. int loop = 0;
  602. int i = 0;
  603. while (input[loop] != '\0') {
  604. cmd[i++] = input[loop++];
  605. }
  606. DisplayValueToLcm(__qr_code, cmd, len + 1);
  607. #endif //defined DD360Audi
  608. }
  609. void ChangeQrCode_Charge(char *input)
  610. {
  611. #if defined DD360Audi
  612. int len = strlen(input) + 3;
  613. int loop = 0;
  614. int i = 0, j = 0, k = 0, l = 0;
  615. uint8_t qrUrl[128] = {0};
  616. uint16_t urlLen = 0;
  617. uint8_t cmd[len];
  618. uint8_t tmpBuf[15] = {0};
  619. //uint8_t tmpLen = sizeof(tmpBuf) - 1;
  620. strncpy((char *)cmd, " ", len);
  621. while (input[loop] != '\0') {
  622. cmd[i++] = input[loop++];
  623. l = loop - 1;
  624. if (len >= 25) {
  625. if (i >= 16 && i <= 19) {
  626. tmpBuf[k++] = input[l];
  627. //printf("tmpBuf = %s\r\n", tmpBuf);
  628. } else if (i >= 21 && i <= 23) {
  629. tmpBuf[k++] = input[l];
  630. }
  631. }
  632. }
  633. tmpBuf[k] = '\0';
  634. //printf("tmpBuf = %s\r\n", tmpBuf);
  635. j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
  636. cmd[len - 1] = '\0';
  637. urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
  638. qrUrl[urlLen] = '\0';
  639. DisplayValueToLcm(__qr_code, qrUrl, urlLen);
  640. j = 0;
  641. j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
  642. tmpBuf[k + j] = '\0';
  643. if (len < 25) {
  644. strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  645. }
  646. //tmpBuf[tmpLen] = '\0';
  647. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  648. /*if (len > sizeof(tmpBuf)) {
  649. strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
  650. tmpBuf[tmpLen] = '\0';
  651. DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
  652. memset(tmpBuf, 0, sizeof(tmpBuf));
  653. strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
  654. tmpBuf[tmpLen] = '\0';
  655. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  656. } else {
  657. DisplayValueToLcm(__custStationIdL1, cmd, len);
  658. strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
  659. tmpBuf[tmpLen] = '\0';
  660. DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
  661. }*/
  662. #else
  663. int len = strlen(input);
  664. uint8_t cmd[len];
  665. int loop = 0;
  666. int i = 0;
  667. while (input[loop] != '\0') {
  668. cmd[i++] = input[loop++];
  669. }
  670. DisplayValueToLcm(__qr_code_pre, cmd, len + 1);
  671. #endif //defined DD360Audi
  672. }
  673. //================================================
  674. // Change current page
  675. //================================================
  676. void ChangeCurPage()
  677. {
  678. //log_info("cur = %d, new = %d \n", _currentPage, pSysInfo->PageIndex);
  679. if (_currentPage != pSysInfo->PageIndex) {
  680. _currentPage = pSysInfo->PageIndex;
  681. ChangeToOtherPage(_currentPage);
  682. _everyPageRollChange = 0;
  683. }
  684. }
  685. //================================================
  686. // Main process
  687. //================================================
  688. uint8_t demoCount = 0;
  689. void DemoFunction()
  690. {
  691. if (demoCount == 0) {
  692. pSysWarning->WarningCount = 6;
  693. memcpy(&pSysWarning->WarningCode[0][0], "000001", 7);
  694. memcpy(&pSysWarning->WarningCode[1][0], "000002", 7);
  695. memcpy(&pSysWarning->WarningCode[2][0], "000003", 7);
  696. memcpy(&pSysWarning->WarningCode[3][0], "000004", 7);
  697. memcpy(&pSysWarning->WarningCode[4][0], "000005", 7);
  698. memcpy(&pSysWarning->WarningCode[5][0], "000006", 7);
  699. } else {
  700. if (demoCount == 20) {
  701. pSysInfo->PageIndex = _LCM_IDLE;
  702. } else if (demoCount == 80) {
  703. pSysInfo->PageIndex = _LCM_AUTHORIZING;
  704. } else if (demoCount == 100) {
  705. pSysInfo->PageIndex = _LCM_AUTHORIZ_COMP;
  706. } else if (demoCount == 120) {
  707. pSysInfo->PageIndex = _LCM_AUTHORIZ_FAIL;
  708. } else if (demoCount == 140) {
  709. pSysInfo->PageIndex = _LCM_PRE_CHARGE;
  710. } else if (demoCount == 180) {
  711. pSysInfo->PageIndex = _LCM_CHARGING;
  712. }
  713. }
  714. if (demoCount < 180) {
  715. demoCount++;
  716. }
  717. }
  718. //================================================
  719. // Main process
  720. //================================================
  721. bool FindChargingInfoData(uint8_t target, struct ChargingInfoData **_chargingData)
  722. {
  723. for (uint8_t index = 0; index < CHAdeMO_QUANTITY; index++) {
  724. if (pSysInfo->ChademoChargingData[index].Index == target) {
  725. _chargingData[target] = &pSysInfo->ChademoChargingData[index];
  726. return true;
  727. }
  728. }
  729. for (uint8_t index = 0; index < CCS_QUANTITY; index++) {
  730. if (pSysInfo->CcsChargingData[index].Index == target) {
  731. _chargingData[target] = &pSysInfo->CcsChargingData[index];
  732. return true;
  733. }
  734. }
  735. for (uint8_t index = 0; index < GB_QUANTITY; index++) {
  736. if (pSysInfo->GbChargingData[index].Index == target) {
  737. _chargingData[target] = &pSysInfo->GbChargingData[index];
  738. return true;
  739. }
  740. }
  741. return false;
  742. }
  743. bool FindAcChargingInfoData(uint8_t target, struct ChargingInfoData **acChargingData)
  744. {
  745. if (target < AC_QUANTITY) {
  746. acChargingData[target] = &pSysInfo->AcChargingData[target];
  747. return true;
  748. }
  749. return false;
  750. }
  751. int GetTimeoutValue(struct timespec *startTime)
  752. {
  753. struct timespec endTime;
  754. clock_gettime(CLOCK_MONOTONIC_COARSE, &endTime);
  755. return endTime.tv_sec - startTime->tv_sec;
  756. }
  757. void GetTimespecFunc(struct timespec *time)
  758. {
  759. clock_gettime(CLOCK_MONOTONIC_COARSE, time);
  760. }
  761. void RunReplugStringFunction(bool isRun)
  762. {
  763. if (isRun) {
  764. int time = GetTimeoutValue(&showReplugStrTimer);
  765. if (time >=1 && time <2) {
  766. ChangeDisplay2Value(__show_replugString_value, _showReplugStr_1);
  767. } else if (time < 1) {
  768. ChangeDisplay2Value(__show_replugString_value, _showReplugStr_2);
  769. } else
  770. GetTimespecFunc(&showReplugStrTimer);
  771. } else
  772. ChangeDisplay2Value(__show_replugString_value, _disappear);
  773. }
  774. /**
  775. * [ChangeBalanceValue :print balance information]
  776. * @Author
  777. * @DateTime 2020-11-26
  778. */
  779. static void ChangeBalanceValue(uint16_t addr, uint8_t index) ////For Audi
  780. {
  781. uint8_t cmd[10] = {0};
  782. uint8_t value[10] = {0};
  783. uint8_t len = 0;
  784. float balance = ShmSelectGunInfo->PricesInfo[index].Balance;
  785. if ((balance) == (FAIL_BALANCE_PRICES)) {
  786. balance = 0.00;
  787. }
  788. len += sprintf((char *) value, "%.2f", balance);
  789. if (len < 6) {
  790. sprintf((char *)&value[len], "%s",
  791. (uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
  792. }
  793. value[sizeof(value) - 1] = '\0';
  794. string2ByteArray(value, cmd);
  795. DisplayValueToLcm(addr, cmd, sizeof(cmd));
  796. }
  797. void ChangeAcBattMapAndValue(short page)
  798. {
  799. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  800. if (page == _LCM_CHARGING) {
  801. if (isDiffStatus != _battery_display_ani) {
  802. isChangeBattMap = false;
  803. isDiffStatus = _battery_display_ani;
  804. }
  805. if (pAcChargingInfo->IsCharging && !isChangeBattMap) {
  806. isChangeBattMap = true;
  807. if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5) {
  808. ChangeDisplay2Value(__batt_map, _battery_empty);
  809. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_EMP;
  810. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP) {
  811. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  812. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV1;
  813. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1) {
  814. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  815. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV2;
  816. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2) {
  817. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  818. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV3;
  819. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3) {
  820. ChangeDisplay2Value(__batt_map, _battery_cap_80);
  821. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV4;
  822. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4) {
  823. ChangeDisplay2Value(__batt_map, _battery_cap_100);
  824. ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
  825. }
  826. }
  827. } else if (page == _LCM_COMPLETE) {
  828. if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5) {
  829. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  830. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP) {
  831. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  832. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1) {
  833. ChangeDisplay2Value(__batt_map, _battery_soc_40);
  834. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2) {
  835. ChangeDisplay2Value(__batt_map, _battery_soc_60);
  836. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3) {
  837. ChangeDisplay2Value(__batt_map, _battery_soc_80);
  838. } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4) {
  839. ChangeDisplay2Value(__batt_map, _battery_soc_100);
  840. }
  841. }
  842. ChangeDisplay2Value(__soc_value_charging, _disappear);
  843. }
  844. void ChangeBattMapAndValue(short page, int soc)
  845. {
  846. // srand(time(NULL));
  847. // int min = 10;
  848. // int max = 90;
  849. // soc = rand() % (max - min + 1) + min;
  850. if (page == _LCM_PRE_CHARGE) {
  851. ChangeDisplay2Value(__batt_map_empty, _battery_empty);
  852. } else if (page == _LCM_CHARGING) {
  853. if (soc < 20) {
  854. if (_battery_display_ani) {
  855. ChangeDisplay2Value(__batt_map, _battery_empty);
  856. } else {
  857. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  858. }
  859. } else if (soc >= 20 && soc < 40) {
  860. if (_battery_display_ani) {
  861. ChangeDisplay2Value(__batt_map, _battery_cap_20);
  862. } else {
  863. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  864. }
  865. } else if (soc >= 40 && soc < 60) {
  866. if (_battery_display_ani) {
  867. ChangeDisplay2Value(__batt_map, _battery_cap_40);
  868. } else {
  869. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  870. }
  871. } else if (soc >= 60 && soc < 80) {
  872. if (_battery_display_ani) {
  873. ChangeDisplay2Value(__batt_map, _battery_cap_60);
  874. } else {
  875. ChangeDisplay2Value(__batt_map, _battery_cap_80);
  876. }
  877. } else if (soc >= 80 && soc <= 100) {
  878. if (_battery_display_ani) {
  879. ChangeDisplay2Value(__batt_map, _battery_cap_80); //DS60-120 add
  880. } else {
  881. ChangeDisplay2Value(__batt_map, _battery_cap_100);
  882. }
  883. }
  884. } else if (page == _LCM_COMPLETE) {
  885. if (soc < 20) {
  886. ChangeDisplay2Value(__batt_map, _battery_soc_20);
  887. } else if (soc >= 20 && soc < 40) {
  888. ChangeDisplay2Value(__batt_map, _battery_soc_40);
  889. } else if (soc >= 40 && soc < 60) {
  890. ChangeDisplay2Value(__batt_map, _battery_soc_60);
  891. } else if (soc >= 60 && soc < 80) {
  892. ChangeDisplay2Value(__batt_map, _battery_soc_80);
  893. } else if (soc >= 80 && soc <= 100) {
  894. ChangeDisplay2Value(__batt_map, _battery_soc_100);
  895. }
  896. }
  897. uint8_t cmd[5];
  898. uint8_t value[5];
  899. memset(cmd, 0x00, sizeof(cmd));
  900. memset(value, 0x00, sizeof(value));
  901. sprintf((char *)value, "%d%%", soc);
  902. string2ByteArray(value, cmd);
  903. DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
  904. }
  905. void ChangeRemainTime(int sec)
  906. {
  907. int h, m, s;
  908. uint8_t cmd[10];
  909. uint8_t value[10];
  910. memset(cmd, 0x00, sizeof(cmd));
  911. // srand(time(NULL));
  912. // int min = 0;
  913. // int max = 65536;
  914. // sec = rand() % (max - min + 1) + min;
  915. h = (sec / 3600);
  916. m = (sec - (3600 * h)) / 60;
  917. s = (sec - (3600 * h) - (m * 60));
  918. sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
  919. string2ByteArray(value, cmd);
  920. DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
  921. }
  922. void ChangeChargingEnergyValue(float energy)
  923. {
  924. uint8_t cmd[10];
  925. uint8_t value[10];
  926. memset(cmd, 0x00, sizeof(cmd));
  927. if (energy >= 0.05) {
  928. energy -= 0.05;
  929. }
  930. sprintf((char *) value, "%.1f kWh", energy);
  931. string2ByteArray(value, cmd);
  932. DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
  933. }
  934. void ChangeChargingPowerValue(float pow)
  935. {
  936. uint8_t cmd[10];
  937. uint8_t value[10];
  938. memset(cmd, 0x00, sizeof(cmd));
  939. // float min = 0.0;
  940. // float max = 50;
  941. // pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
  942. sprintf((char *) value, "%.1f kW", pow);
  943. string2ByteArray(value, cmd);
  944. DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
  945. }
  946. void ChangeChargingFeeValue(float fee)
  947. {
  948. uint8_t cmd[10];
  949. uint8_t value[10];
  950. memset(cmd, 0x00, sizeof(cmd));
  951. sprintf((char *) value, "%.2f", fee);
  952. string2ByteArray(value, cmd);
  953. DisplayValueToLcm(__charging_fee_tx, cmd, sizeof(cmd));
  954. }
  955. void DisplayMoneyRate(float money)
  956. {
  957. uint8_t cmd[8];
  958. uint8_t value[8];
  959. memset(cmd, 0x00, sizeof(cmd));
  960. sprintf((char *) value, "%.2f", money);
  961. string2ByteArray(value, cmd);
  962. DisplayValueToLcm(__money_by_rate, cmd, sizeof(cmd));
  963. }
  964. void DisplayMoneyCur(uint8_t *cur)
  965. {
  966. uint8_t cmd[10] = {0};
  967. uint8_t buf[10] = {0};
  968. uint8_t len = 0;
  969. *(cur + 3) = '\0';
  970. memset(cmd, 0x00, sizeof(cmd));
  971. len = sprintf((char *) buf, "%s/kWh", cur);
  972. buf[len] = '\0';
  973. string2ByteArray(buf, cmd);
  974. DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
  975. }
  976. void RefreshPageAnimation(uint8_t value)
  977. {
  978. switch (_currentPage) {
  979. case _LCM_IDLE: {
  980. }
  981. break;
  982. case _LCM_WAIT_FOR_PLUG: {
  983. if (_everyPageRollChange == 0) {
  984. ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
  985. } else if (_everyPageRollChange == 15) {
  986. ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
  987. }
  988. _everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  989. }
  990. break;
  991. case _LCM_PRE_CHARGE:
  992. case _LCM_CHARGING:
  993. case _LCM_COMPLETE: {
  994. if (_currentPage == _LCM_PRE_CHARGE) {
  995. if (_everyPageRollChange == 0 || _everyPageRollChange == 22) {
  996. ChangeDisplay2Value(__conn_line, _conn_map1);
  997. } else if (_everyPageRollChange == 11 || _everyPageRollChange == 33) {
  998. ChangeDisplay2Value(__conn_line, _conn_map2);
  999. }
  1000. } else if (_currentPage == _LCM_CHARGING) {
  1001. if (_everyPageRollChange == 0 || _everyPageRollChange == 22) {
  1002. ChangeDisplay2Value(__conn_line_chag, _charging_map1);
  1003. } else if (_everyPageRollChange == 11 || _everyPageRollChange == 33) {
  1004. ChangeDisplay2Value(__conn_line_chag, _charging_map2);
  1005. }
  1006. } else if (_currentPage == _LCM_COMPLETE) {
  1007. if (_everyPageRollChange == 0) {
  1008. ChangeDisplay2Value(__conn_line_comp, _complete_map);
  1009. }
  1010. }
  1011. _everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
  1012. }
  1013. break;
  1014. }
  1015. }
  1016. void RefreshConnStatus()
  1017. {
  1018. // Wifi priority is higher than Ethernet
  1019. #if defined DD360 ||defined DD360Audi || defined DD360ComBox
  1020. uint8_t i = 0;
  1021. uint8_t ehtStatus = 0;
  1022. for (i = 0; i < pSysWarning->WarningCount; i++) {
  1023. if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  1024. ehtStatus = 1;
  1025. //if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
  1026. // ShmSelectGunInfo->EthDevStatus.Ethernet = DEV_ST_ENABLE_NO_USE;
  1027. //}
  1028. break;
  1029. }
  1030. }
  1031. if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_DISABLE) {
  1032. ChangeDisplay2Value(__conn_status, _disappear);
  1033. } else if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_ENABLE_USE) {
  1034. ChangeDisplay2Value(__conn_status, _connect);
  1035. } else if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_ENABLE_NO_USE) {
  1036. ChangeDisplay2Value(__conn_status, _disconnect);
  1037. }
  1038. if (ehtStatus == 1) {
  1039. if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
  1040. ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
  1041. }
  1042. } else {
  1043. if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
  1044. ChangeDisplay2Value(__ethernet_status, _eth_connect);
  1045. }
  1046. //if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_DISABLE) {
  1047. //} else if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_USE) {
  1048. // ChangeDisplay2Value(__ethernet_status, _eth_connect);
  1049. //} else if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_NO_USE) {
  1050. // ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
  1051. //}
  1052. }
  1053. if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_DISABLE) {
  1054. ChangeDisplay2Value(__wifi_status, _disappear);
  1055. ChangeDisplay2Value(__3G4G_status, _disappear);
  1056. if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
  1057. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1058. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
  1059. ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
  1060. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
  1061. ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
  1062. }
  1063. } else if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_USE) {
  1064. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1065. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  1066. } else if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_NO_USE) {
  1067. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1068. ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
  1069. }
  1070. if (ShmSelectGunInfo->EthDevStatus.Wifi != DEV_ST_DISABLE) {
  1071. if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
  1072. ChangeDisplay2Value(__3G4G_status, _disappear);
  1073. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
  1074. ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
  1075. } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
  1076. ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
  1077. }
  1078. }
  1079. //uint8_t flag[4] = {0};
  1080. /*for (i = 0; i < pSysWarning->WarningCount; i++) {
  1081. //printf("status code = %s\r\n", &pSysWarning->WarningCode[i][0]);
  1082. if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  1083. flag[0] = 1;
  1084. continue;
  1085. }
  1086. if (memcmp(&pSysWarning->WarningCode[i][0], "043625", 6) == 0) {
  1087. //disconnected from AP through WiFi
  1088. flag[1] = 1;
  1089. continue;
  1090. }
  1091. if (memcmp(&pSysWarning->WarningCode[i][0], "043627", 6) == 0) { //wifi disabled
  1092. flag[1] = 2;
  1093. continue;
  1094. }
  1095. if ((memcmp(&pSysWarning->WarningCode[i][0], "033900", 6) == 0) ||
  1096. (memcmp(&pSysWarning->WarningCode[i][0], "033901", 6) == 0) ||
  1097. (memcmp(&pSysWarning->WarningCode[i][0], "033902", 6) == 0)) {
  1098. flag[2] = 1;
  1099. continue;
  1100. }
  1101. if (memcmp(&pSysWarning->WarningCode[i][0], "043626", 6) == 0) {
  1102. //disconnected from APN through 3G/4G
  1103. flag[3] = 1;
  1104. continue;
  1105. }
  1106. if (memcmp(&pSysWarning->WarningCode[i][0], "043628", 6) == 0) { //4g disabled
  1107. flag[3] = 2;
  1108. continue;
  1109. }
  1110. }
  1111. if (flag[0] == 1) {
  1112. ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
  1113. } else {
  1114. ChangeDisplay2Value(__ethernet_status, _eth_connect);
  1115. }
  1116. //ChangeDisplay2Value(__wifi_status, _disappear);
  1117. //ChangeDisplay2Value(__conn_status, _disappear);
  1118. //ChangeDisplay2Value(__3G4G_status, _disappear);
  1119. if (flag[1] == 1) {
  1120. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1121. ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
  1122. } else if (flag[1] == 2) {
  1123. ChangeDisplay2Value(__wifi_status, _disappear);
  1124. } else {
  1125. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1126. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  1127. }
  1128. if (flag[2] == 1) {
  1129. ChangeDisplay2Value(__conn_status, _disconnect);
  1130. } else {
  1131. ChangeDisplay2Value(__conn_status, _connect);
  1132. }
  1133. if (flag[1] == 2) {
  1134. ChangeDisplay2Value(__3G4G_status, _disappear);
  1135. if (flag[3] == 1) {
  1136. ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
  1137. } else if (flag[3] == 2) {
  1138. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1139. } else {
  1140. ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
  1141. }
  1142. } else {
  1143. if (flag[3] == 1) {
  1144. ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
  1145. } else if (flag[3] == 2) {
  1146. ChangeDisplay2Value(__3G4G_status, _disappear);
  1147. } else {
  1148. ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
  1149. }
  1150. }
  1151. */
  1152. #else
  1153. // eth
  1154. if (pSysInfo->ethInternetConn == YES) {
  1155. ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
  1156. } else {
  1157. ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
  1158. }
  1159. // Wifi
  1160. if ((pSysConfig->ModelName[10] == 'W' ||
  1161. pSysConfig->ModelName[10] == 'D') &&
  1162. pSysConfig->AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE) {
  1163. if (pSysConfig->AthInterface.WifiNetworkConn == YES ||
  1164. pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
  1165. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  1166. } else {
  1167. ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
  1168. }
  1169. } else {
  1170. ChangeDisplay2Value(__wifi_status, _disappear);
  1171. }
  1172. if ((pSysConfig->ModelName[10] == 'T' ||
  1173. pSysConfig->ModelName[10] == 'D') &&
  1174. pSysConfig->TelecomInterface.TelcomEnabled != NO) {
  1175. if (pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_DISABLE) {
  1176. ChangeDisplay2Value(__3G4G_status, _disappear);
  1177. // 3G/4G
  1178. if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES)
  1179. { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
  1180. else
  1181. { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
  1182. } else {
  1183. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1184. // 3G/4G
  1185. if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES)
  1186. { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
  1187. else
  1188. { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
  1189. }
  1190. } else {
  1191. ChangeDisplay2Value(__3G4G_status, _disappear);
  1192. ChangeDisplay2Value(__3G4G_move_status, _disappear);
  1193. }
  1194. // 連線到後台
  1195. if (pSysInfo->OcppConnStatus == YES) {
  1196. ChangeDisplay2Value(__conn_status, _connect);
  1197. } else {
  1198. ChangeDisplay2Value(__conn_status, _disconnect);
  1199. }
  1200. /*if (pSysConfig->AthInterface.WifiNetworkConn == YES ||
  1201. pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
  1202. _wifi_conn_status = true;
  1203. ChangeDisplay2Value(__wifi_status, _wifi_connect);
  1204. ChangeDisplay2Value(__ethernet_status, _disappear);
  1205. } else {
  1206. _wifi_conn_status = false;
  1207. ChangeDisplay2Value(__wifi_status, _disappear);
  1208. }
  1209. if (!_wifi_conn_status) {
  1210. if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES ||
  1211. pSysInfo->InternetConn == YES) {
  1212. ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
  1213. } else {
  1214. ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
  1215. }
  1216. }
  1217. // 連線到後台
  1218. if (pSysInfo->OcppConnStatus == YES) {
  1219. ChangeDisplay2Value(__conn_status, _connect);
  1220. } else {
  1221. ChangeDisplay2Value(__conn_status, _disconnect);
  1222. }
  1223. */
  1224. #endif //defined DD360 || defined DD360Audi
  1225. }
  1226. uint8_t FirstPageChanged()
  1227. {
  1228. uint8_t result = NO;
  1229. if (_currentPage != _oldPage) {
  1230. result = YES;
  1231. _oldPage = _currentPage;
  1232. }
  1233. return result;
  1234. }
  1235. bool IsPageReloadChk()
  1236. {
  1237. bool result = false;
  1238. if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  1239. if (_curPage_index != pSysInfo->CurGunSelected) {
  1240. _curPage_index = pSysInfo->CurGunSelected;
  1241. result = true;
  1242. }
  1243. } else {
  1244. if (_curPage_index != pSysInfo->CurGunSelectedByAc) {
  1245. _curPage_index = pSysInfo->CurGunSelectedByAc;
  1246. result = true;
  1247. }
  1248. }
  1249. return result;
  1250. }
  1251. void ClearDisplayInfo()
  1252. {
  1253. ChangeDisplay2Value(__csu_ver_string, _disappear);
  1254. ChangeDisplay2Value(__csu_ver_value, _disappear);
  1255. ChangeDisplay2Value(__eth0_ip_string, _disappear);
  1256. ChangeDisplay2Value(__eth0_ip_value, _disappear);
  1257. ChangeDisplay2Value(__sn_string, _disappear);
  1258. ChangeDisplay2Value(__sn_value, _disappear);
  1259. ChangeDisplay2Value(__dc1_ver_string, _disappear);
  1260. ChangeDisplay2Value(__dc1_ver_value, _disappear);
  1261. ChangeDisplay2Value(__dc2_ver_string, _disappear);
  1262. ChangeDisplay2Value(__dc2_ver_value, _disappear);
  1263. ChangeDisplay2Value(__fan_speed_string, _disappear);
  1264. ChangeDisplay2Value(__fan_speed_value, _disappear);
  1265. }
  1266. void DisplayInfoCsuVer(bool isShow, uint8_t *modelName)
  1267. {
  1268. if (isShow) {
  1269. uint8_t value[10];
  1270. memset(value, 0x00, sizeof(value));
  1271. strcpy((char *)value, "CSU Ver >");
  1272. DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
  1273. memset(value, 0x00, sizeof(value));
  1274. strncpy((char *)value, (char *)modelName, 5);
  1275. DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
  1276. } else {
  1277. ChangeDisplay2Value(__csu_ver_string, _disappear);
  1278. ChangeDisplay2Value(__csu_ver_value, _disappear);
  1279. }
  1280. }
  1281. void ShowWifiMode(bool isShow, uint8_t mode)
  1282. {
  1283. if (isShow) {
  1284. uint8_t value[20];
  1285. memset(value, 0x00, sizeof(value));
  1286. strcpy((char *) value, "Wifi Mo. >");
  1287. DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
  1288. memset(value, 0x00, sizeof(value));
  1289. if (mode == 0) {
  1290. sprintf((char *)value, "disable");
  1291. } else if (mode == 1) {
  1292. sprintf((char *)value, "station");
  1293. } else if (mode == 2) {
  1294. sprintf((char *)value, "AP");
  1295. }
  1296. DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
  1297. } else {
  1298. ChangeDisplay2Value(__csu_ver_string, _disappear);
  1299. ChangeDisplay2Value(__csu_ver_value, _disappear);
  1300. }
  1301. }
  1302. void DisplayInfoEthIp(bool isShow, uint8_t *ip)
  1303. {
  1304. if (isShow) {
  1305. uint8_t value[20];
  1306. memset(value, 0x00, sizeof(value));
  1307. strcpy((char *) value, "Eth IP >");
  1308. DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
  1309. memset(value, 0x00, sizeof(value));
  1310. strcpy((char *) value, (char *) ip);
  1311. DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
  1312. } else {
  1313. ChangeDisplay2Value(__eth0_ip_string, _disappear);
  1314. ChangeDisplay2Value(__eth0_ip_value, _disappear);
  1315. }
  1316. }
  1317. void Show4GRssi(bool isShow, int dbValue)
  1318. {
  1319. if (isShow) {
  1320. uint8_t value[20];
  1321. memset(value, 0x00, sizeof(value));
  1322. strcpy((char *) value, "RSSI >");
  1323. DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
  1324. memset(value, 0x00, sizeof(value));
  1325. sprintf((char *)value, "%d dBm", dbValue);
  1326. DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
  1327. } else {
  1328. ChangeDisplay2Value(__eth0_ip_string, _disappear);
  1329. ChangeDisplay2Value(__eth0_ip_value, _disappear);
  1330. }
  1331. }
  1332. void DisplayInfoSN(bool isShow, uint8_t *sn)
  1333. {
  1334. if (isShow) {
  1335. uint8_t value[30];
  1336. memset(value, 0x00, sizeof(value));
  1337. strcpy((char *) value, "SN >");
  1338. DisplayValueToLcm(__sn_string, value, sizeof(value));
  1339. memset(value, 0x00, sizeof(value));
  1340. strcpy((char *) value, (char *) sn);
  1341. DisplayValueToLcm(__sn_value, value, sizeof(value));
  1342. } else {
  1343. ChangeDisplay2Value(__sn_string, _disappear);
  1344. ChangeDisplay2Value(__sn_value, _disappear);
  1345. }
  1346. }
  1347. void ShowWifiRssi(bool isShow, int dbValue)
  1348. {
  1349. if (isShow) {
  1350. uint8_t value[20];
  1351. memset(value, 0x00, sizeof(value));
  1352. strcpy((char *) value, "RSSI >");
  1353. DisplayValueToLcm(__sn_string, value, sizeof(value));
  1354. memset(value, 0x00, sizeof(value));
  1355. sprintf((char *)value, "%d dBm", dbValue);
  1356. DisplayValueToLcm(__sn_value, value, sizeof(value));
  1357. } else {
  1358. ChangeDisplay2Value(__sn_string, _disappear);
  1359. ChangeDisplay2Value(__sn_value, _disappear);
  1360. }
  1361. }
  1362. void DisplayInfoGun1Ver(bool isShow, uint8_t *version)
  1363. {
  1364. if (isShow) {
  1365. uint8_t value[10];
  1366. memset(value, 0x00, sizeof(value));
  1367. strcpy((char *) value, "Ct1 Ver >");
  1368. DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
  1369. memset(value, 0x00, sizeof(value));
  1370. strcpy((char *) value, (char *) version);
  1371. DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
  1372. } else {
  1373. ChangeDisplay2Value(__dc1_ver_string, _disappear);
  1374. ChangeDisplay2Value(__dc1_ver_value, _disappear);
  1375. }
  1376. }
  1377. void Show4GMode(bool isShow, uint8_t mode)
  1378. {
  1379. if (isShow) {
  1380. uint8_t value[20];
  1381. memset(value, 0x00, sizeof(value));
  1382. strcpy((char *) value, "3/4G Mo. >");
  1383. DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
  1384. memset(value, 0x00, sizeof(value));
  1385. if (mode == 0) {
  1386. sprintf((char *)value, "disable");
  1387. } else if (mode == 1) {
  1388. sprintf((char *)value, "enable");
  1389. }
  1390. DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
  1391. } else {
  1392. ChangeDisplay2Value(__dc1_ver_string, _disappear);
  1393. ChangeDisplay2Value(__dc1_ver_value, _disappear);
  1394. }
  1395. }
  1396. void DisplayInfoGun2Ver(bool isShow, uint8_t *version)
  1397. {
  1398. if (isShow) {
  1399. uint8_t value[10];
  1400. memset(value, 0x00, sizeof(value));
  1401. strcpy((char *) value, "Ct2 Ver >");
  1402. DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
  1403. memset(value, 0x00, sizeof(value));
  1404. strcpy((char *) value, (char *) version);
  1405. DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
  1406. } else {
  1407. ChangeDisplay2Value(__dc2_ver_string, _disappear);
  1408. ChangeDisplay2Value(__dc2_ver_value, _disappear);
  1409. }
  1410. }
  1411. void Show4GIP(bool isShow, uint8_t *ip)
  1412. {
  1413. if (isShow) {
  1414. uint8_t value[20];
  1415. memset(value, 0x00, sizeof(value));
  1416. strcpy((char *) value, "3/4G IP >");
  1417. DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
  1418. memset(value, 0x00, sizeof(value));
  1419. strcpy((char *) value, (char *) ip);
  1420. DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
  1421. } else {
  1422. ChangeDisplay2Value(__dc2_ver_string, _disappear);
  1423. ChangeDisplay2Value(__dc2_ver_value, _disappear);
  1424. }
  1425. }
  1426. void DisplayInfoSpeed(bool isShow, unsigned int fan)
  1427. {
  1428. if (isShow) {
  1429. uint8_t value[10];
  1430. memset(value, 0x00, sizeof(value));
  1431. strcpy((char *) value, "Fan Spd >");
  1432. DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
  1433. memset(value, 0x00, sizeof(value));
  1434. sprintf((char *)value, "%d", fan);
  1435. DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
  1436. } else {
  1437. ChangeDisplay2Value(__fan_speed_string, _disappear);
  1438. ChangeDisplay2Value(__fan_speed_value, _disappear);
  1439. }
  1440. }
  1441. void ShowWifiIP(bool isShow, uint8_t *ip)
  1442. {
  1443. if (isShow) {
  1444. uint8_t value[20];
  1445. memset(value, 0x00, sizeof(value));
  1446. strcpy((char *) value, "Wifi IP >");
  1447. DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
  1448. memset(value, 0x00, sizeof(value));
  1449. strcpy((char *) value, (char *) ip);
  1450. DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
  1451. } else {
  1452. ChangeDisplay2Value(__fan_speed_string, _disappear);
  1453. ChangeDisplay2Value(__fan_speed_value, _disappear);
  1454. }
  1455. }
  1456. void InformationShow()
  1457. {
  1458. if (pSysConfig->ShowInformation == YES) {
  1459. bool show = _isShow = true;
  1460. if (_showInformIndex == 0) {
  1461. DisplayInfoCsuVer(show, pSysInfo->CsuRootFsFwRev);
  1462. DisplayInfoSpeed(show, pSysInfo->SystemFanRotaSpeed);
  1463. DisplayInfoSN(show, pSysConfig->SerialNumber);
  1464. DisplayInfoEthIp(show, pSysConfig->Eth0Interface.EthIpAddress);
  1465. DisplayInfoGun1Ver(show, pSysInfo->Connector1FwRev);
  1466. if (_totalCount > 1) {
  1467. DisplayInfoGun2Ver(show, pSysInfo->Connector2FwRev);
  1468. } else {
  1469. DisplayInfoGun2Ver(false, pSysInfo->Connector2FwRev);
  1470. }
  1471. } else if (_showInformIndex == 1) {
  1472. ShowWifiMode(show, pSysConfig->AthInterface.WifiMode);
  1473. ShowWifiIP(show, pSysConfig->AthInterface.WifiIpAddress);
  1474. ShowWifiRssi(show, pSysConfig->AthInterface.WifiRssi);
  1475. Show4GMode(show, pSysConfig->TelecomInterface.TelcomEnabled);
  1476. Show4GIP(show, pSysConfig->TelecomInterface.TelcomIpAddress);
  1477. Show4GRssi(show, pSysConfig->TelecomInterface.TelcomRssi);
  1478. }
  1479. } else {
  1480. ClearDisplayInfo();
  1481. if (_isShow) {
  1482. _isShow = false;
  1483. _showInformIndex++;
  1484. if (_showInformIndex >= 2) {
  1485. _showInformIndex = 0;
  1486. }
  1487. }
  1488. }
  1489. }
  1490. void ProcessPageInfo()
  1491. {
  1492. _page_reload = IsPageReloadChk();
  1493. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  1494. // 隨插即充 - 可省略該按鈕 //DS60-120 add
  1495. if (pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE) {
  1496. ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
  1497. if (_totalCount >= 2 && pSysInfo->IsAlternatvieConf == NO) {
  1498. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1499. } else {
  1500. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1501. }
  1502. }
  1503. switch (_currentPage) {
  1504. #if defined DD360Audi
  1505. case _LCM_SELECT_GUN: ////For Audi
  1506. if (pSysInfo->CurGunSelected == 0) {
  1507. ChangeDisplay2Value(__left_gun_map, _left_gun_enable_map);
  1508. ChangeDisplay2Value(__right_gun_map, _right_gun_disable_map);
  1509. } else if (pSysInfo->CurGunSelected == 1) {
  1510. ChangeDisplay2Value(__left_gun_map, _left_gun_disable_map);
  1511. ChangeDisplay2Value(__right_gun_map, _right_gun_enable_map);
  1512. }
  1513. ChangeDisplay2Value(__add_chk_btn, _select_gun_btn);
  1514. break;
  1515. #endif //defined DD360Audi
  1516. case _LCM_IDLE: {
  1517. if (pSysConfig->isRFID) {
  1518. ChangeDisplay2Value(__main_rfid, _main_rfid);
  1519. } else {
  1520. ChangeDisplay2Value(__main_rfid, _main_none_rfid);
  1521. }
  1522. if (pSysConfig->isQRCode) {
  1523. ChangeDisplay2Value(__main_qr, _main_qr);
  1524. } else {
  1525. ChangeDisplay2Value(__qr_code, _disappear);
  1526. ChangeDisplay2Value(__main_qr, _main_none_qr);
  1527. needReloadQr = true;
  1528. }
  1529. if (pSysConfig->isAPP) {
  1530. ChangeDisplay2Value(__main_app, _main_app);
  1531. } else {
  1532. ChangeDisplay2Value(__main_app, _main_none_app);
  1533. }
  1534. //if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
  1535. if (pSysConfig->isQRCode) {
  1536. needReloadQr = false;
  1537. if (pSysConfig->QRCodeMadeMode == NO) {
  1538. //uint8_t len = strlen((char *)pSysConfig->SystemId);
  1539. ChangeQrCode_Idle((char *)pSysConfig->SystemId);
  1540. } else {
  1541. //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
  1542. ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
  1543. }
  1544. //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
  1545. }
  1546. //}
  1547. //DS60-120 add
  1548. bool isCharging = false;
  1549. for (uint8_t i = 0; i < _totalCount; i++) {
  1550. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
  1551. if (pDcChargingInfo->SystemStatus == S_IDLE) {
  1552. continue;
  1553. }
  1554. isCharging = true;
  1555. break;
  1556. }
  1557. if (isCharging && pSysInfo->IsAlternatvieConf == NO) {
  1558. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1559. } else {
  1560. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1561. }
  1562. }
  1563. break;
  1564. case _LCM_AUTHORIZING:
  1565. case _LCM_AUTHORIZ_COMP:
  1566. case _LCM_AUTHORIZ_FAIL: {
  1567. //case _LCM_WAIT_FOR_PLUG: {
  1568. FirstPageChanged();
  1569. #if defined DD360Audi
  1570. if (_currentPage == _LCM_AUTHORIZ_COMP) { ////For Audi
  1571. ChangeBalanceValue(__balance, pSysInfo->CurGunSelected);
  1572. }
  1573. #endif //defined DD360Audi
  1574. }
  1575. break;
  1576. case _LCM_WAIT_FOR_PLUG: {
  1577. FirstPageChanged();
  1578. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  1579. // 新增隨插即充功能預設在等待插槍頁面在開啟
  1580. ChangeDisplay2Value(__ret_home_btn, _disappear);
  1581. bool isCharging = false;
  1582. for (uint8_t i = 0; i < _totalCount; i++) {
  1583. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
  1584. if (pDcChargingInfo->SystemStatus == S_IDLE) {
  1585. continue;
  1586. }
  1587. isCharging = true;
  1588. break;
  1589. }
  1590. if (isCharging && pSysInfo->IsAlternatvieConf == NO) {
  1591. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1592. } else {
  1593. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1594. }
  1595. } else {
  1596. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1597. }
  1598. }
  1599. break;
  1600. case _LCM_PRE_CHARGE:
  1601. case _LCM_CHARGING:
  1602. case _LCM_COMPLETE: {
  1603. bool isShowAc = false;
  1604. uint8_t gunTargetIndex = 0;
  1605. if (acgunCount > 0) {
  1606. gunTargetIndex = 2;
  1607. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  1608. isShowAc = true;
  1609. //ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_light); //DS60-120 remove
  1610. if (_currentPage == _LCM_COMPLETE) {
  1611. ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_light_cmp);
  1612. } else {
  1613. ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_light);
  1614. }
  1615. if (_currentPage == _LCM_CHARGING) {
  1616. ChangeAcBattMapAndValue(_LCM_CHARGING);
  1617. if (pAcChargingInfo->PresentChargedDuration >= 0 &&
  1618. pAcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
  1619. ChangeRemainTime(pAcChargingInfo->PresentChargedDuration);
  1620. } else {
  1621. ChangeRemainTime(0);
  1622. }
  1623. if (pAcChargingInfo->PresentChargingPower >= 0.1 &&
  1624. pAcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  1625. ChangeChargingPowerValue(pAcChargingInfo->PresentChargingPower);
  1626. } else {
  1627. ChangeChargingPowerValue(0);
  1628. }
  1629. if (pAcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1630. pAcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1631. ChangeChargingEnergyValue(pAcChargingInfo->PresentChargedEnergy);
  1632. } else {
  1633. ChangeChargingEnergyValue(0);
  1634. }
  1635. if (strcmp((char *)pAcChargingInfo->StartUserId, "") == 0 ||
  1636. pSysConfig->StopChargingByButton == YES) {
  1637. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  1638. } else {
  1639. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  1640. }
  1641. } else if (_currentPage == _LCM_COMPLETE) {
  1642. ChangeAcBattMapAndValue(_LCM_COMPLETE);
  1643. if (pAcChargingInfo->PresentChargedDuration >= 0 &&
  1644. pAcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
  1645. ChangeRemainTime(pAcChargingInfo->PresentChargedDuration);
  1646. } else {
  1647. ChangeRemainTime(0);
  1648. }
  1649. if (pAcChargingInfo->PresentChargingPower >= 0.1 &&
  1650. pAcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  1651. ChangeChargingPowerValue(pAcChargingInfo->PresentChargingPower);
  1652. } else {
  1653. ChangeChargingPowerValue(0);
  1654. }
  1655. if (pAcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1656. pAcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1657. ChangeChargingEnergyValue(pAcChargingInfo->PresentChargedEnergy);
  1658. if (pSysConfig->BillingData.isBilling &&
  1659. pAcChargingInfo->ChargingFee >= 0) {
  1660. ChangeChargingFeeValue(pAcChargingInfo->ChargingFee);
  1661. }
  1662. } else {
  1663. ChangeChargingEnergyValue(0);
  1664. if (pSysConfig->BillingData.isBilling) {
  1665. ChangeChargingFeeValue(0);
  1666. }
  1667. }
  1668. if (!pSysConfig->BillingData.isBilling) {
  1669. ChangeDisplay2Value(__charging_fee_map, _disappear);
  1670. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  1671. } else {
  1672. ChangeDisplay2Value(__charging_fee_map, _money_map);
  1673. }
  1674. }
  1675. } else {
  1676. //ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_dark); //DS60-120 remove
  1677. if (_currentPage == _LCM_COMPLETE) {
  1678. ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_dark_cmp);
  1679. } else {
  1680. ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_dark);
  1681. }
  1682. }
  1683. } else {
  1684. //ChangeDisplay2Value(__gun_type_index + (2 * 2), _disappear); //DS60-120 remove
  1685. if (_totalCount > 1) {
  1686. gunTargetIndex = 2;
  1687. ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _disappear);
  1688. ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _disappear);
  1689. }
  1690. }
  1691. gunTargetIndex = 0; //DS60-120 add
  1692. for (uint8_t i = 0; i < _totalCount; i++) {
  1693. if (_totalCount == 1 && acgunCount <= 0) { //DS60-120 add
  1694. gunTargetIndex = 2;
  1695. } else {
  1696. gunTargetIndex = i;
  1697. }
  1698. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
  1699. switch (pDcChargingInfo->Type) {
  1700. case _Type_Chademo: {
  1701. if (pSysInfo->CurGunSelected == i && !isShowAc) {
  1702. if (_currentPage == _LCM_COMPLETE) {
  1703. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _chademo_light_cmp);
  1704. } else {
  1705. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_light);
  1706. }
  1707. } else {
  1708. if (_currentPage == _LCM_COMPLETE) {
  1709. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _chademo_dark_cmp);
  1710. } else {
  1711. ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_dark);
  1712. }
  1713. }
  1714. }
  1715. break;
  1716. case _Type_GB: {
  1717. if (pSysInfo->CurGunSelected == i && !isShowAc) {
  1718. if (_currentPage == _LCM_COMPLETE) {
  1719. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _gbt_light_cmp);
  1720. } else {
  1721. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_light);
  1722. }
  1723. } else {
  1724. if (_currentPage == _LCM_COMPLETE) {
  1725. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _gbt_dark_cmp);
  1726. } else {
  1727. ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_dark);
  1728. }
  1729. }
  1730. }
  1731. break;
  1732. case _Type_CCS_2: {
  1733. if (pSysInfo->CurGunSelected == i && !isShowAc) {
  1734. if (_currentPage == _LCM_COMPLETE) {
  1735. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _ccs_light_cmp);
  1736. } else {
  1737. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_light);
  1738. }
  1739. } else {
  1740. if (_currentPage == _LCM_COMPLETE) {
  1741. ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _ccs_dark_cmp);
  1742. } else {
  1743. ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_dark);
  1744. }
  1745. }
  1746. }
  1747. break;
  1748. }
  1749. if (_currentPage == _LCM_PRE_CHARGE && !isShowAc) {
  1750. if (pSysInfo->CurGunSelected == i) {
  1751. ChangeBattMapAndValue(_currentPage, pDcChargingInfo->EvBatterySoc);
  1752. }
  1753. } else if (_currentPage == _LCM_CHARGING && !isShowAc) {
  1754. if (pSysInfo->CurGunSelected == i) {
  1755. ChangeBattMapAndValue(_LCM_CHARGING, pDcChargingInfo->EvBatterySoc);
  1756. if (pDcChargingInfo->PresentChargedDuration >= 0 &&
  1757. pDcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
  1758. ChangeRemainTime(pDcChargingInfo->PresentChargedDuration);
  1759. } else {
  1760. ChangeRemainTime(0);
  1761. }
  1762. if (pDcChargingInfo->PresentChargingPower >= 0 &&
  1763. pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  1764. ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower);
  1765. } else {
  1766. ChangeChargingPowerValue(0);
  1767. }
  1768. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1769. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1770. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1771. } else {
  1772. ChangeChargingEnergyValue(0);
  1773. }
  1774. if (strcmp((char *)pDcChargingInfo->StartUserId, "") == 0 ||
  1775. pSysConfig->StopChargingByButton == YES) {
  1776. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
  1777. } else {
  1778. ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
  1779. }
  1780. }
  1781. } else if (_currentPage == _LCM_COMPLETE && !isShowAc) {
  1782. if (pSysInfo->CurGunSelected == i) {
  1783. ChangeBattMapAndValue(_LCM_COMPLETE, pDcChargingInfo->EvBatterySoc);
  1784. if (pDcChargingInfo->PresentChargedDuration >= 0 &&
  1785. pDcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
  1786. ChangeRemainTime(pDcChargingInfo->PresentChargedDuration);
  1787. } else {
  1788. ChangeRemainTime(0);
  1789. }
  1790. if (pDcChargingInfo->PresentChargingPower >= 0 &&
  1791. pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
  1792. ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower);
  1793. } else {
  1794. ChangeChargingPowerValue(0);
  1795. }
  1796. #if 1
  1797. if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
  1798. pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
  1799. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1800. if (pSysConfig->BillingData.isBilling &&
  1801. pDcChargingInfo->ChargingFee >= 0) {
  1802. ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
  1803. ChangeBalanceValue(__remain_balance, i);
  1804. }
  1805. } else {
  1806. ChangeChargingEnergyValue(0);
  1807. if (pSysConfig->BillingData.isBilling) {
  1808. ChangeChargingFeeValue(0);
  1809. ChangeBalanceValue(__remain_balance, i);
  1810. }
  1811. }
  1812. #else
  1813. ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
  1814. if (pSysConfig->BillingData.isBilling &&
  1815. pDcChargingInfo->ChargingFee >= 0) {
  1816. ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
  1817. ChangeBalanceValue(__remain_balance, i);
  1818. }
  1819. #endif // 0
  1820. if (!pSysConfig->BillingData.isBilling) {
  1821. ChangeDisplay2Value(__charging_fee_map, _disappear);
  1822. ChangeDisplay2Value(__charging_fee_tx, _disappear);
  1823. } else {
  1824. ChangeDisplay2Value(__charging_fee_map, _money_map);
  1825. }
  1826. #ifdef DD360Audi
  1827. // Warming Occur in prepare or precharing state, turn into complete mode
  1828. if (pDcChargingInfo->Replug_flag) {
  1829. RunReplugStringFunction(true);
  1830. } else {
  1831. RunReplugStringFunction(false);
  1832. }
  1833. #else
  1834. #endif
  1835. }
  1836. }
  1837. }
  1838. // gun btn and QR code
  1839. if (_totalCount + acgunCount >= 2 && _currentPage) {
  1840. uint8_t index = 0;
  1841. for (index = 0; index < _totalCount; index++) {
  1842. if (pSysInfo->CurGunSelected != index) {
  1843. break;
  1844. }
  1845. }
  1846. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
  1847. if (pDcChargingInfo->SystemStatus == S_IDLE ||
  1848. pDcChargingInfo->SystemStatus == S_RESERVATION ||
  1849. pDcChargingInfo->SystemStatus == S_BOOTING) {
  1850. if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
  1851. if (pSysConfig->isQRCode) {
  1852. needReloadQr = false;
  1853. //ChangeQrCode_Charge((char *)pSysConfig->SystemId); //DS60-120 remove
  1854. if (pSysConfig->QRCodeMadeMode == NO) {
  1855. //uint8_t len = strlen((char *)pSysConfig->SystemId);
  1856. ChangeQrCode_Charge((char *)pSysConfig->SystemId);
  1857. } else {
  1858. //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
  1859. ChangeQrCode_Charge((char *)pSysConfig->QRCodeContent);
  1860. }
  1861. }
  1862. }
  1863. }
  1864. }
  1865. }
  1866. break;
  1867. case _LCM_FIX:
  1868. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == 1) {
  1869. ChangeDisplay2Value(_emergency_map, _emergency_disable_map);
  1870. } else {
  1871. ChangeDisplay2Value(_emergency_map, _disappear);
  1872. }
  1873. break;
  1874. }
  1875. }
  1876. void ChangeDisplayMoneyInfo()
  1877. {
  1878. uint8_t curGun = pSysInfo->CurGunSelected;
  1879. if (pSysConfig->BillingData.isBilling) {
  1880. struct timeb csuTime;
  1881. struct tm *tmCSU;
  1882. ftime(&csuTime);
  1883. tmCSU = localtime(&csuTime.time);
  1884. ChangeDisplay2Value(__money_rate_map, _charging_money);
  1885. #if defined DD360Audi
  1886. if (ShmSelectGunInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
  1887. DisplayMoneyRate(ShmSelectGunInfo->PricesInfo[curGun].UserPrices);
  1888. } else {
  1889. #endif //defined DD360Audi
  1890. if (tmCSU->tm_hour <= 23) {
  1891. pSysConfig->BillingData.Cur_fee = pSysConfig->BillingData.Fee[tmCSU->tm_hour];
  1892. DisplayMoneyRate(pSysConfig->BillingData.Cur_fee);
  1893. }
  1894. if (pSysConfig->BillingData.Currency <= 53) {
  1895. DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
  1896. }
  1897. #if defined DD360Audi
  1898. }
  1899. #endif //defined DD360Audi
  1900. } else {
  1901. ChangeDisplay2Value(__money_rate_map, _disappear);
  1902. ChangeDisplay2Value(__money_by_rate, _disappear);
  1903. ChangeDisplay2Value(__money_rate, _disappear);
  1904. }
  1905. }
  1906. /*void Initialization()
  1907. {
  1908. bool isPass = false;
  1909. uint8_t count = 5;
  1910. while (!isPass && count > 0) {
  1911. isPass = true;
  1912. for (uint8_t _index = 0; _index < _totalCount; _index++) {
  1913. if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
  1914. log_error("LcmComm (main) : FindChargingInfoData false \n");
  1915. isPass = false;
  1916. count--;
  1917. break;
  1918. }
  1919. }
  1920. sleep(1);
  1921. }
  1922. isPass = false;
  1923. if (acgunCount > 0) {
  1924. while (!isPass) {
  1925. isPass = true;
  1926. for (uint8_t _index = 0; _index < acgunCount; _index++) {
  1927. if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
  1928. log_error("LcmComm : FindAcChargingInfoData false \n");
  1929. isPass = false;
  1930. break;
  1931. }
  1932. }
  1933. sleep(1);
  1934. }
  1935. }
  1936. if (count == 0) {
  1937. log_info("LCM Initialization Gun Fail.............\n");
  1938. }
  1939. }
  1940. */
  1941. //DS60-120 add
  1942. void DefaultIconStatus()
  1943. {
  1944. for (uint8_t i = 0; i < 3; i++) {
  1945. ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
  1946. }
  1947. if (pSysInfo->IsAlternatvieConf == YES || _totalCount == 1) {
  1948. ChangeDisplay2Value(__sel_gun_btn, _disappear);
  1949. } else {
  1950. ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
  1951. }
  1952. }
  1953. int main(void)
  1954. {
  1955. //if (InitShareMemory() == FAIL) {
  1956. // log_error("InitShareMemory NG\n");
  1957. //
  1958. // if (ShmStatusCodeData != NULL) {
  1959. // ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  1960. // }
  1961. // sleep(5);
  1962. // return 0;
  1963. //}
  1964. if (CreateAllCsuShareMemory() == FAIL) {
  1965. log_error("create share memory error\r\n");
  1966. return FAIL;
  1967. }
  1968. MappingGunChargingInfo("LCM Control Task");
  1969. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  1970. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  1971. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  1972. ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
  1973. ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  1974. ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  1975. _port = CreateCommunicationLcmPort();
  1976. uint8_t changeWarningPriority = 0;
  1977. uint8_t curWarningCount = 255;
  1978. ChangeBackLight(true);
  1979. _totalCount = pSysConfig->TotalConnectorCount;
  1980. acgunCount = pSysConfig->AcConnectorCount;
  1981. //Initialization();
  1982. //printf("_LCM_COMPLETE \r\n");
  1983. //ChangeToOtherPage(_LCM_COMPLETE);
  1984. //return 0;
  1985. for (uint8_t i = 0; i < 3; i++) {
  1986. ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
  1987. }
  1988. DefaultIconStatus(); //DS60-120 add
  1989. while (_port != -1) {
  1990. if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
  1991. GetCurrentPage();
  1992. sleep(1);
  1993. } else {
  1994. //DemoFunction();
  1995. // Warning 處理
  1996. if (curWarningCount != pSysWarning->WarningCount) {
  1997. changeWarningPriority = 0;
  1998. pSysWarning->PageIndex = 0;
  1999. curWarningCount = pSysWarning->WarningCount;
  2000. ChangeWarningFunc();
  2001. } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
  2002. // 當有兩頁 Warning 則每隔三秒改變一次
  2003. if (pSysWarning->PageIndex == 0) {
  2004. pSysWarning->PageIndex = 1;
  2005. } else {
  2006. pSysWarning->PageIndex = 0;
  2007. }
  2008. ChangeWarningFunc();
  2009. }
  2010. // 頁面資訊處理
  2011. ProcessPageInfo();
  2012. // 網路 - wifi - 連線訊號處理
  2013. RefreshConnStatus();
  2014. // 換頁處理
  2015. GetCurrentPage(); //DS60-120 add
  2016. ChangeCurPage();
  2017. RefreshPageAnimation(_everyPageRollChange);
  2018. #if defined DD360Audi
  2019. ChangeDisplayMoneyInfo();
  2020. #else
  2021. if (changeWarningPriority == 0) { ////For Audi
  2022. ChangeDisplayMoneyInfo();
  2023. InformationShow();
  2024. }
  2025. #endif //defined DD360Audi
  2026. changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);
  2027. changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
  2028. usleep(100000);
  2029. }
  2030. }
  2031. CloseCommunicationLcmPort();
  2032. return FAIL;
  2033. }