Module_LcmControl.c.test 61 KB

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