Module_LcmControl.c 84 KB

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