Module_LcmContro_oldl.c 79 KB

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