Module_LcmControl.c 81 KB

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