Primary.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. #include <stdio.h> /*標準輸入輸出定義*/
  2. #include <stdlib.h> /*標準函數庫定義*/
  3. #include <string.h>
  4. #include <stdint.h>
  5. #include "../Config.h"
  6. #include "../Log/log.h"
  7. #include "../Define/define.h"
  8. #include "../ShareMemory/shmMem.h"
  9. #include "../SelectGun/SelectGun.h"
  10. #include "main.h"
  11. #include "../common.h"
  12. //------------------------------------------------------------------------------
  13. typedef struct StLedConfig {
  14. //OutputDrvValue[0]
  15. uint8_t LeftButtonLed: 1; //bit 0, H: ON, L:OFF
  16. uint8_t RightButtonLed: 1; //bit 1, H: ON, L:OFF
  17. uint8_t GreenLED: 1; //bit 2, H: ON, L:OFF
  18. uint8_t YellowLED: 1; //bit 3, H: ON, L:OFF
  19. uint8_t RedLED: 1; //bit 4, H: ON, L:OFF
  20. uint8_t SystemLed4: 1; //bit 5, H: ON, L:OFF
  21. uint8_t AcContactor: 1; //bit 6, H: ON, L:OFF
  22. uint8_t Reserved: 1; //bit 7 reserved
  23. } LedConfig;
  24. time_t showInfoTimer;
  25. //------------------------------------------------------------------------------
  26. static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
  27. {
  28. uint8_t ret = NO;
  29. LedConfig *pLedConfig = (LedConfig *)ledConfig;
  30. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  31. if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
  32. ret = YES;
  33. if (pLedConfig->RedLED == YES ||
  34. pLedConfig->YellowLED == YES ||
  35. pLedConfig->GreenLED == YES) {
  36. pLedConfig->RedLED = NO;
  37. pLedConfig->YellowLED = NO;
  38. pLedConfig->GreenLED = NO;
  39. } else {
  40. pLedConfig->RedLED = YES;
  41. pLedConfig->YellowLED = YES;
  42. pLedConfig->GreenLED = YES;
  43. }
  44. }
  45. return ret;
  46. }
  47. void PrimaryLedIndicatorCtrlFork(void)
  48. {
  49. #if !defined DD360ComBox
  50. return;
  51. #endif //!defined DD360ComBox
  52. pid_t pid = fork();
  53. if (pid == 0) {
  54. uint8_t gunIndex = 0;
  55. int isContinue = 1;
  56. log_info("Primary Fork Child's PID is %d", getpid());
  57. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  58. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  59. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  60. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  61. struct ChargingInfoData *pDcChargingInfo = NULL;
  62. LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
  63. while (isContinue) {
  64. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  65. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  66. if (pSysWarning->Level == WARN_LV_ER) {
  67. if (checkCabinetEthConnectState(pLedConfig) == YES) {
  68. usleep(500000);
  69. continue;
  70. }
  71. pLedConfig->YellowLED = NO;
  72. pLedConfig->GreenLED = NO;
  73. pLedConfig->RedLED = YES;
  74. usleep(500000);
  75. continue;
  76. }
  77. //log_info("led indicator status = %d", pDcChargingInfo->SystemStatus);
  78. //printf("level = %d", pSysWarning->Level);
  79. switch (pDcChargingInfo->SystemStatus) {
  80. case S_BOOTING:
  81. if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
  82. //Module_DoComm tcp disconnect
  83. if (pLedConfig->RedLED == YES ||
  84. pLedConfig->YellowLED == YES ||
  85. pLedConfig->GreenLED == YES) {
  86. pLedConfig->RedLED = NO;
  87. pLedConfig->YellowLED = NO;
  88. pLedConfig->GreenLED = NO;
  89. } else {
  90. pLedConfig->RedLED = YES;
  91. pLedConfig->YellowLED = YES;
  92. pLedConfig->GreenLED = YES;
  93. }
  94. break;
  95. }
  96. pLedConfig->RedLED = YES;
  97. pLedConfig->YellowLED = YES;
  98. pLedConfig->GreenLED = YES;
  99. break;
  100. case S_IDLE:
  101. //Module_DoComm connected and system idle
  102. pLedConfig->RedLED = NO;
  103. pLedConfig->YellowLED = NO;
  104. pLedConfig->GreenLED = YES;
  105. break;
  106. case S_RESERVATION:
  107. case S_AUTHORIZING:
  108. case S_REASSIGN_CHECK:
  109. case S_REASSIGN:
  110. case S_PREPARNING:
  111. case S_PREPARING_FOR_EV:
  112. case S_PREPARING_FOR_EVSE:
  113. case S_CCS_PRECHARGE_ST0:
  114. case S_CCS_PRECHARGE_ST1:
  115. //precharging status
  116. if (pLedConfig->GreenLED == YES) {
  117. pLedConfig->GreenLED = NO;
  118. } else {
  119. pLedConfig->GreenLED = YES;
  120. }
  121. break;
  122. case S_CHARGING:
  123. pLedConfig->RedLED = NO;
  124. #ifdef DD360ComBox
  125. pLedConfig->YellowLED = YES;
  126. #else
  127. if (pLedConfig->YellowLED == YES) {
  128. pLedConfig->YellowLED = NO;
  129. } else {
  130. pLedConfig->YellowLED = YES;
  131. }
  132. #endif
  133. pLedConfig->GreenLED = NO;
  134. break;
  135. case S_ALARM:
  136. pLedConfig->YellowLED = NO;
  137. pLedConfig->GreenLED = NO;
  138. if (checkCabinetEthConnectState(pLedConfig) == YES) {
  139. break;
  140. }
  141. pLedConfig->RedLED = YES;
  142. break;
  143. case S_TERMINATING:
  144. case S_COMPLETE:
  145. //if (pSysWarning->Level == WARN_LV_ER) {
  146. // pLedConfig->YellowLED = NO;
  147. // pLedConfig->GreenLED = NO;
  148. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  149. // break;
  150. // }
  151. // pLedConfig->RedLED = YES;
  152. //} else {
  153. pLedConfig->RedLED = NO;
  154. #ifdef DD360ComBox
  155. if (pLedConfig->YellowLED == YES) {
  156. pLedConfig->YellowLED = NO;
  157. } else {
  158. pLedConfig->YellowLED = YES;
  159. }
  160. #else
  161. pLedConfig->YellowLED = YES;
  162. #endif
  163. pLedConfig->GreenLED = NO;
  164. //}
  165. break;
  166. case S_MAINTAIN:
  167. case S_FAULT:
  168. case S_UPDATE:
  169. pLedConfig->YellowLED = NO;
  170. pLedConfig->GreenLED = NO;
  171. pLedConfig->RedLED = YES;
  172. //if (pSysWarning->Level == WARN_LV_ER) {
  173. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  174. // break;
  175. // }
  176. // pLedConfig->RedLED = YES;
  177. //}
  178. break;
  179. case S_BOOKING:
  180. case S_DEBUG:
  181. case S_NONE:
  182. break;
  183. }//switch
  184. }//for
  185. usleep(500000);
  186. }//while
  187. }//fork
  188. }
  189. void SetIDLE(int gunIndex)
  190. {
  191. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  192. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  193. struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
  194. log_info("Set Gun%d to IDLE", gunIndex);
  195. pDcChargingInfo->SystemStatus = S_IDLE;
  196. strcpy((char*)pSysConfig->UserId, "");
  197. StopSystemTimeoutDet();
  198. StopGunInfoTimeoutDet(gunIndex);
  199. destroySelGun(gunIndex);
  200. ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit = NO;
  201. ShmDcCommonData->LcmPage = _PAGE_SELECTGUN;
  202. }
  203. void LeftBtnPress()
  204. {
  205. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  206. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  207. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  208. struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  209. if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
  210. if (pSysInfo->SystemPage == _LCM_WAIT_FOR_PLUG) {
  211. if (isDetectPlugin(LEFT_GUN_NUM)) {
  212. _DetectPlugInTimeout(LEFT_GUN_NUM);
  213. destroySelGun(LEFT_GUN_NUM);
  214. }
  215. if (isDetectPlugin(RIGHT_GUN_NUM)) {
  216. _DetectPlugInTimeout(RIGHT_GUN_NUM);
  217. destroySelGun(RIGHT_GUN_NUM);
  218. }
  219. //systemPageRestoreInit();
  220. //connectorPageRestoreIdle();
  221. }
  222. switch (pDcChargingInfo->SystemStatus) {
  223. case S_IDLE:
  224. case S_RESERVATION:
  225. if (isDetectPlugin(pSysInfo->CurGunSelected)) {
  226. _DetectPlugInTimeout(pSysInfo->CurGunSelected);
  227. destroySelGun(pSysInfo->CurGunSelected);
  228. } else {
  229. if( pSysConfig->isAuthrizeByEVCCID && pSysInfo->ConnectorPage == _LCM_PRE_CHARGE) {
  230. _evccidlinktimeout(pSysInfo->CurGunSelected);
  231. pDcChargingInfo->isEVCCIDVerify = true;
  232. break;
  233. }
  234. #if !defined DD360Audi
  235. break;
  236. #endif //!defined DD360Audi
  237. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  238. //printf("destroy gun = %d", pSysInfo->CurGunSelected);
  239. destroySelGun(pSysInfo->CurGunSelected);
  240. } else {
  241. confirmSelGun(pSysInfo->CurGunSelected);
  242. log_info("confirm select gun ............................... %d ",
  243. pSysInfo->CurGunSelected);
  244. }
  245. }
  246. break;
  247. case S_REASSIGN_CHECK:
  248. case S_REASSIGN:
  249. case S_PREPARNING:
  250. case S_PREPARING_FOR_EV:
  251. case S_PREPARING_FOR_EVSE:
  252. case S_CCS_PRECHARGE_ST0:
  253. case S_CCS_PRECHARGE_ST1:
  254. // 取消充電
  255. if (pSysConfig->StopChargingByButton == YES ||
  256. pDcChargingInfo->StartMethod == _CHARGING_START_AUTOSTART ||
  257. pDcChargingInfo->StartMethod == _CHARGING_START_EVCCID) {
  258. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  259. }
  260. break;
  261. case S_CHARGING:
  262. if (pSysConfig->StopChargingByButton == YES ||
  263. pDcChargingInfo->StartMethod == _CHARGING_START_AUTOSTART ||
  264. pDcChargingInfo->StartMethod == _CHARGING_START_EVCCID) {
  265. // 停止充電
  266. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  267. }
  268. break;
  269. case S_COMPLETE:
  270. break;
  271. }
  272. } else {
  273. strcpy((char*)pSysConfig->UserId, "");
  274. switch (ShmDcCommonData->LcmPage) {
  275. case _PAGE_SELECTGUN:
  276. if (!ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].WaitForPlugit) {
  277. ClearDetectPluginFlag(LEFT_GUN_NUM);
  278. confirmSelGun(LEFT_GUN_NUM);
  279. ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
  280. StopSystemTimeoutDet(); // Clear Timeout_SelectGun
  281. }
  282. pSysInfo->CurGunSelected = LEFT_GUN_NUM;
  283. break;
  284. case _PAGE_SELECT_PAY:
  285. SetIDLE(pSysInfo->CurGunSelected);
  286. break;
  287. case _PAGE_SETTING:
  288. ShmDcCommonData->LcmPage = ShmDcCommonData->previousPage;
  289. StopSystemTimeoutDet();
  290. break;
  291. case _PAGE_BACKLIGHT:
  292. ( ShmDcCommonData->MaxBlackLight >= BRIGHTNESS_LEVEL_5 ) ? (ShmDcCommonData->MaxBlackLight -=2) : ( ShmDcCommonData->MaxBlackLight = BRIGHTNESS_LEVEL_3);
  293. StopSystemTimeoutDet();
  294. break;
  295. case _PAGE_LANGUAGE:
  296. if (ShmDcCommonData->language >= 1)
  297. ShmDcCommonData->language--;
  298. StopSystemTimeoutDet();
  299. break;
  300. case _PAGE_AUTHORIZING:
  301. break;
  302. case _PAGE_AUTHORIZE_COMPLETE:
  303. break;
  304. case _PAGE_AUTHORIZE_FAIL:
  305. SetIDLE(pSysInfo->CurGunSelected);
  306. break;
  307. case _PAGE_PLUGIN_TIMEOUT:
  308. case _PAGE_WAIT_FOR_PLUGIN:
  309. SetIDLE(pSysInfo->CurGunSelected);
  310. case _PAGE_CHARGING:
  311. case _PAGE_PRECHARGE:
  312. if (pSysConfig->StopChargingByButton) {
  313. pDcChargingInfo->SystemStatus = S_TERMINATING;
  314. } else {
  315. if (pDcChargingInfo->StartMethod == _CHARGING_START_REMOTESTART)
  316. ShmDcCommonData->LcmPage = _PAGE_APP_STOP;
  317. else if (pDcChargingInfo->StartMethod == _CHARGING_START_RFID)
  318. ShmDcCommonData->LcmPage = _PAGE_RFID_STOP;
  319. else
  320. pDcChargingInfo->SystemStatus = S_TERMINATING;
  321. strcpy((char*)pSysConfig->UserId, "");
  322. }
  323. break;
  324. case _PAGE_COMPLETE:
  325. case _PAGE_COMPLETE_RECEIPT:
  326. SetIDLE(pSysInfo->CurGunSelected);
  327. //ShmDcCommonData->LcmPage = _PAGE_SELECTGUN;
  328. break;
  329. case _PAGE_APP_STOP:
  330. ShmDcCommonData->LcmPage = _PAGE_CHARGING;
  331. StopSystemTimeoutDet(); // Clear Timeout_ShowStopPage
  332. break;
  333. case _PAGE_RFID_STOP:
  334. ShmDcCommonData->LcmPage = _PAGE_CHARGING;
  335. StopSystemTimeoutDet(); // Clear Timeout_ShowStopPage
  336. break;
  337. case _PAGE_ALARM:
  338. if (!pDcChargingInfo->ConnectorPlugIn) {
  339. SetIDLE(pSysInfo->CurGunSelected);
  340. break;
  341. }
  342. if (pDcChargingInfo->Replug_flag)
  343. ShmDcCommonData->LcmPage = _PAGE_PRECHARGE_FAIL;
  344. break;
  345. case _PAGE_PRECHARGE_FAIL:
  346. ShmDcCommonData->LcmPage = _PAGE_ALARM;
  347. break;
  348. case _PAGE_MAINTAIN:
  349. break;
  350. case _PAGE_EMG_BTN:
  351. break;
  352. case _PAGE_DEBUG:
  353. ShmDcCommonData->LcmPage = ShmDcCommonData->previousPage;
  354. StopSystemTimeoutDet();
  355. break;
  356. }
  357. }
  358. }
  359. void RightBtnPress()
  360. {
  361. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  362. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  363. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  364. if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
  365. } else {
  366. strcpy((char*)pSysConfig->UserId, "");
  367. switch (ShmDcCommonData->LcmPage) {
  368. case _PAGE_SELECTGUN:
  369. if (!ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].WaitForPlugit) {
  370. ClearDetectPluginFlag(RIGHT_GUN_NUM);
  371. strcpy((char*)pSysConfig->UserId, "");
  372. confirmSelGun(RIGHT_GUN_NUM);
  373. ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
  374. }
  375. pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
  376. break;
  377. case _PAGE_SETTING:
  378. if (ShmDcCommonData->LcmSetItem == _SET_LANGUAGE)
  379. ShmDcCommonData->LcmSetItem = _SET_BACKLIGHT;
  380. else
  381. ShmDcCommonData->LcmSetItem = _SET_LANGUAGE;
  382. StopSystemTimeoutDet();
  383. break;
  384. case _PAGE_BACKLIGHT:
  385. ShmDcCommonData->MaxBlackLight >= BRIGHTNESS_LEVEL_11 ? (ShmDcCommonData->MaxBlackLight = BRIGHTNESS_LEVEL_11) : (ShmDcCommonData->MaxBlackLight += 2);
  386. log_info("Black Light Max Value:%d",ShmDcCommonData->MaxBlackLight);
  387. StopSystemTimeoutDet();
  388. break;
  389. case _PAGE_LANGUAGE:
  390. ShmDcCommonData->language++;
  391. if (ShmDcCommonData->language >= ShmDcCommonData->languageCount) {
  392. ShmDcCommonData->language = ShmDcCommonData->languageCount;
  393. }
  394. StopSystemTimeoutDet();
  395. break;
  396. //case _PAGE_SELECT_PAY:
  397. // SetIDLE(pSysInfo->CurGunSelected);
  398. // break;
  399. case _PAGE_WAIT_FOR_PLUGIN:
  400. case _PAGE_PRECHARGE:
  401. case _PAGE_CHARGING:
  402. case _PAGE_COMPLETE:
  403. case _PAGE_COMPLETE_RECEIPT:
  404. (pSysInfo->CurGunSelected == LEFT_GUN_NUM) ? (pSysInfo->CurGunSelected = RIGHT_GUN_NUM) : (pSysInfo->CurGunSelected = LEFT_GUN_NUM);
  405. break;
  406. }
  407. }
  408. }
  409. void CenterBtnPress()
  410. {
  411. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  412. switch (ShmDcCommonData->LcmPage) {
  413. case _PAGE_SELECTGUN:
  414. case _PAGE_SELECT_PAY:
  415. case _PAGE_WAIT_FOR_PLUGIN:
  416. case _PAGE_PRECHARGE:
  417. case _PAGE_CHARGING:
  418. case _PAGE_COMPLETE:
  419. case _PAGE_COMPLETE_RECEIPT:
  420. ShmDcCommonData->LcmPage = _PAGE_SETTING;
  421. break;
  422. case _PAGE_SETTING:
  423. StopSystemTimeoutDet();
  424. if (ShmDcCommonData->LcmSetItem == _SET_LANGUAGE) {
  425. ShmDcCommonData->LcmPage = _PAGE_LANGUAGE;
  426. } else if (ShmDcCommonData->LcmSetItem == _SET_BACKLIGHT) {
  427. ShmDcCommonData->LcmPage = _PAGE_BACKLIGHT;
  428. }
  429. StopSystemTimeoutDet();
  430. break;
  431. case _PAGE_BACKLIGHT:
  432. ShmDcCommonData->LcmPage = _PAGE_SETTING;
  433. StopSystemTimeoutDet();
  434. break;
  435. case _PAGE_LANGUAGE:
  436. ShmDcCommonData->LcmPage = _PAGE_SETTING;
  437. StopSystemTimeoutDet();
  438. break;
  439. case _PAGE_AUTHORIZE_FAIL:
  440. break;
  441. }
  442. }
  443. void setTouch()
  444. {
  445. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  446. GetClockTime(&ShmDcCommonData->_touch_time);
  447. ShmDcCommonData->isTouch = TRUE;
  448. }
  449. void ChkPrimaryStatus(void)
  450. {
  451. static bool leftBtnPush = false;
  452. static bool rightBtnPush = false;
  453. static bool centerBtnPush = false;
  454. uint8_t i = 0;
  455. uint8_t Rtn = 0;
  456. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  457. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  458. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  459. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  460. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  461. struct ChargingInfoData *pDcChargingInfo = NULL;
  462. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  463. if (pSysWarning->WarningCount > 0) {
  464. Rtn = 0;
  465. for (i = 0; i < pSysWarning->WarningCount; i++) {
  466. if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
  467. EmcOccureByString("042251");
  468. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
  469. Rtn = 1;
  470. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
  471. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
  472. EmcOccureByString("042252");
  473. Rtn = 1;
  474. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042327", 6) == 0) {
  475. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = YES;
  476. EmcOccureByString("042327");
  477. Rtn = 1;
  478. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042328", 6) == 0) {
  479. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = YES;
  480. EmcOccureByString("042328");
  481. Rtn = 1;
  482. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
  483. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
  484. EmcOccureByString("042200");
  485. Rtn = 1;
  486. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
  487. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
  488. EmcOccureByString("042201");
  489. Rtn = 1;
  490. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
  491. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
  492. EmcOccureByString("042202");
  493. Rtn = 1;
  494. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
  495. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
  496. EmcOccureByString("042267");
  497. Rtn = 1;
  498. } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  499. EmcOccureByString("012304");
  500. Rtn = 1;
  501. }
  502. }
  503. if (Rtn == 0) {
  504. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  505. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  506. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
  507. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
  508. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  509. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  510. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  511. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  512. ReleaseEmsOccureByString(0, "042251");
  513. ReleaseEmsOccureByString(0, "042252");
  514. ReleaseEmsOccureByString(0, "042327");
  515. ReleaseEmsOccureByString(0, "042328");
  516. ReleaseEmsOccureByString(0, "042200");
  517. ReleaseEmsOccureByString(0, "042201");
  518. ReleaseEmsOccureByString(0, "042202");
  519. ReleaseEmsOccureByString(0, "042267");
  520. ReleaseEmsOccureByString(0, "012304");
  521. }
  522. } else {
  523. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  524. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  525. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
  526. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
  527. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  528. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  529. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  530. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  531. ReleaseEmsOccureByString(0, "042251");
  532. ReleaseEmsOccureByString(0, "042252");
  533. ReleaseEmsOccureByString(0, "042327");
  534. ReleaseEmsOccureByString(0, "042328");
  535. ReleaseEmsOccureByString(0, "042200");
  536. ReleaseEmsOccureByString(0, "042201");
  537. ReleaseEmsOccureByString(0, "042202");
  538. ReleaseEmsOccureByString(0, "042267");
  539. ReleaseEmsOccureByString(0, "012304");
  540. }
  541. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
  542. pAlarmCode->AlarmEvents.bits.EmergencyStopTrip = YES;
  543. EmcOccureByString("012251");
  544. } else {
  545. ReleaseEmsOccureByString(0, "012251");
  546. }
  547. if (ShmPrimaryMcuData->InputDet.bits.Ac_Drop == ABNORMAL) {
  548. pAlarmCode->AlarmEvents.bits.ChillerAlarmFail = YES;
  549. EmcOccureByString("012348");
  550. } else {
  551. ReleaseEmsOccureByString(0, "012348");
  552. }
  553. if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == ABNORMAL) {
  554. pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip = YES;
  555. EmcOccureByString("012238");
  556. } else {
  557. ReleaseEmsOccureByString(0, "012238");
  558. }
  559. if (ShmPrimaryMcuData->InputDet.bits.SpdDetec == ABNORMAL) {
  560. pAlarmCode->AlarmEvents.bits.SpdTrip = YES;
  561. } else {
  562. pAlarmCode->AlarmEvents.bits.SpdTrip = NO;
  563. }
  564. if (ShmPrimaryMcuData->InputDet.bits.DoorOpen == ABNORMAL) {
  565. pAlarmCode->AlarmEvents.bits.DoorOpen = YES;
  566. EmcOccureByString("012252");
  567. } else {
  568. ReleaseEmsOccureByString(0, "012252");
  569. }
  570. //DS60-120 add
  571. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  572. ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
  573. pSysConfig->ShowInformation = YES;
  574. showInfoTimer = time((time_t*)NULL);
  575. } else {
  576. if ( (time((time_t*)NULL) - showInfoTimer) > 3 )
  577. pSysConfig->ShowInformation = NO;
  578. }
  579. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  580. !leftBtnPush ) {
  581. if (!leftBtnPush && !ShmDcCommonData->isTouch) {
  582. leftBtnPush = true;
  583. GetClockTime(&ShmDcCommonData->SleepTimer);
  584. ShmDcCommonData->BlackLight = ShmDcCommonData->MaxBlackLight;
  585. if (!ShmDcCommonData->ScreenSave)
  586. LeftBtnPress();
  587. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  588. log_info("left btn down...............................%d %d %d",
  589. pSysInfo->CurGunSelected, pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
  590. ShmDcCommonData->ScreenSave = FALSE;
  591. setTouch();
  592. }
  593. } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
  594. if (leftBtnPush) {
  595. leftBtnPush = false;
  596. //log_info("left btn up............................... ");
  597. }
  598. }
  599. if (ShmPrimaryMcuData->InputDet.bits.Key3 == BTN_PRESS &&
  600. !centerBtnPush ) {
  601. if (!centerBtnPush && !ShmDcCommonData->isTouch) {
  602. centerBtnPush = true;
  603. GetClockTime(&ShmDcCommonData->SleepTimer);
  604. ShmDcCommonData->BlackLight = ShmDcCommonData->MaxBlackLight;
  605. if (!ShmDcCommonData->ScreenSave)
  606. CenterBtnPress();
  607. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  608. log_info("center btn down...............................%d %d %d ",
  609. pSysInfo->CurGunSelected, pDcChargingInfo->SystemStatus, ShmDcCommonData->LcmPage);
  610. ShmDcCommonData->ScreenSave = FALSE;
  611. setTouch();
  612. }
  613. } else if (ShmPrimaryMcuData->InputDet.bits.Key3 == BTN_RELEASE) {
  614. if (centerBtnPush) {
  615. centerBtnPush = false;
  616. //log_info("left btn up............................... ");
  617. }
  618. }
  619. bool isCharging = false;
  620. if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
  621. for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
  622. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
  623. if (IntoChargeProcess(pDcChargingInfo->SystemStatus)) {
  624. isCharging = true;
  625. }
  626. }
  627. }
  628. if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
  629. !rightBtnPush) {
  630. if (!rightBtnPush && !ShmDcCommonData->isTouch) {
  631. rightBtnPush = true;
  632. if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
  633. if (pSysInfo->SystemPage == _LCM_WAIT_FOR_PLUG && !isCharging) {
  634. return;
  635. }
  636. strcpy((char *)pSysConfig->UserId, "");
  637. if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount) {
  638. pSysInfo->CurGunSelected++;
  639. } else {
  640. pSysInfo->CurGunSelected = 0;
  641. }
  642. pSysInfo->SystemPage = _LCM_NONE;
  643. } else {
  644. GetClockTime(&ShmDcCommonData->SleepTimer);
  645. ShmDcCommonData->BlackLight = ShmDcCommonData->MaxBlackLight;
  646. if (!ShmDcCommonData->ScreenSave)
  647. RightBtnPress();
  648. ShmDcCommonData->ScreenSave = FALSE;
  649. }
  650. setTouch();
  651. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  652. log_info("right btn down............................... %d %d %d",
  653. pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus, pSysInfo->SystemPage);
  654. }
  655. } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
  656. if (rightBtnPush) {
  657. rightBtnPush = false;
  658. //log_info("right btn up............................... ");
  659. }
  660. }
  661. }