Primary.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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. //------------------------------------------------------------------------------
  12. typedef struct StLedConfig {
  13. //OutputDrvValue[0]
  14. uint8_t LeftButtonLed: 1; //bit 0, H: ON, L:OFF
  15. uint8_t RightButtonLed: 1; //bit 1, H: ON, L:OFF
  16. uint8_t GreenLED: 1; //bit 2, H: ON, L:OFF
  17. uint8_t YellowLED: 1; //bit 3, H: ON, L:OFF
  18. uint8_t RedLED: 1; //bit 4, H: ON, L:OFF
  19. uint8_t SystemLed4: 1; //bit 5, H: ON, L:OFF
  20. uint8_t AcContactor: 1; //bit 6, H: ON, L:OFF
  21. uint8_t Reserved: 1; //bit 7 reserved
  22. } LedConfig;
  23. time_t showInfoTimer;
  24. //------------------------------------------------------------------------------
  25. static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
  26. {
  27. uint8_t ret = NO;
  28. LedConfig *pLedConfig = (LedConfig *)ledConfig;
  29. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  30. if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
  31. ret = YES;
  32. if (pLedConfig->RedLED == YES ||
  33. pLedConfig->YellowLED == YES ||
  34. pLedConfig->GreenLED == YES) {
  35. pLedConfig->RedLED = NO;
  36. pLedConfig->YellowLED = NO;
  37. pLedConfig->GreenLED = NO;
  38. } else {
  39. pLedConfig->RedLED = YES;
  40. pLedConfig->YellowLED = YES;
  41. pLedConfig->GreenLED = YES;
  42. }
  43. }
  44. return ret;
  45. }
  46. void PrimaryLedIndicatorCtrlFork(void)
  47. {
  48. #if !defined DD360ComBox
  49. return;
  50. #endif //!defined DD360ComBox
  51. pid_t pid = fork();
  52. if (pid == 0) {
  53. uint8_t gunIndex = 0;
  54. int isContinue = 1;
  55. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  56. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  57. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  58. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  59. struct ChargingInfoData *pDcChargingInfo = NULL;
  60. LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
  61. while (isContinue) {
  62. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  63. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  64. if (pSysWarning->Level == WARN_LV_ER) {
  65. if (checkCabinetEthConnectState(pLedConfig) == YES) {
  66. usleep(500000);
  67. continue;
  68. }
  69. pLedConfig->YellowLED = NO;
  70. pLedConfig->GreenLED = NO;
  71. pLedConfig->RedLED = YES;
  72. usleep(500000);
  73. continue;
  74. }
  75. //log_info("led indicator status = %d", pDcChargingInfo->SystemStatus);
  76. //printf("level = %d", pSysWarning->Level);
  77. switch (pDcChargingInfo->SystemStatus) {
  78. case S_BOOTING:
  79. if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
  80. //Module_DoComm tcp disconnect
  81. if (pLedConfig->RedLED == YES ||
  82. pLedConfig->YellowLED == YES ||
  83. pLedConfig->GreenLED == YES) {
  84. pLedConfig->RedLED = NO;
  85. pLedConfig->YellowLED = NO;
  86. pLedConfig->GreenLED = NO;
  87. } else {
  88. pLedConfig->RedLED = YES;
  89. pLedConfig->YellowLED = YES;
  90. pLedConfig->GreenLED = YES;
  91. }
  92. break;
  93. }
  94. pLedConfig->RedLED = YES;
  95. pLedConfig->YellowLED = YES;
  96. pLedConfig->GreenLED = YES;
  97. break;
  98. case S_IDLE:
  99. //Module_DoComm connected and system idle
  100. pLedConfig->RedLED = NO;
  101. pLedConfig->YellowLED = NO;
  102. pLedConfig->GreenLED = YES;
  103. break;
  104. case S_RESERVATION:
  105. case S_AUTHORIZING:
  106. case S_REASSIGN_CHECK:
  107. case S_REASSIGN:
  108. case S_PREPARNING:
  109. case S_PREPARING_FOR_EV:
  110. case S_PREPARING_FOR_EVSE:
  111. case S_CCS_PRECHARGE_ST0:
  112. case S_CCS_PRECHARGE_ST1:
  113. //precharging status
  114. if (pLedConfig->GreenLED == YES) {
  115. pLedConfig->GreenLED = NO;
  116. } else {
  117. pLedConfig->GreenLED = YES;
  118. }
  119. break;
  120. case S_CHARGING:
  121. pLedConfig->RedLED = NO;
  122. #ifdef DD360ComBox
  123. pLedConfig->YellowLED = YES;
  124. #else
  125. if (pLedConfig->YellowLED == YES) {
  126. pLedConfig->YellowLED = NO;
  127. } else {
  128. pLedConfig->YellowLED = YES;
  129. }
  130. #endif
  131. pLedConfig->GreenLED = NO;
  132. break;
  133. case S_ALARM:
  134. pLedConfig->YellowLED = NO;
  135. pLedConfig->GreenLED = NO;
  136. if (checkCabinetEthConnectState(pLedConfig) == YES) {
  137. break;
  138. }
  139. pLedConfig->RedLED = YES;
  140. break;
  141. case S_TERMINATING:
  142. case S_COMPLETE:
  143. //if (pSysWarning->Level == WARN_LV_ER) {
  144. // pLedConfig->YellowLED = NO;
  145. // pLedConfig->GreenLED = NO;
  146. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  147. // break;
  148. // }
  149. // pLedConfig->RedLED = YES;
  150. //} else {
  151. pLedConfig->RedLED = NO;
  152. #ifdef DD360ComBox
  153. if (pLedConfig->YellowLED == YES) {
  154. pLedConfig->YellowLED = NO;
  155. } else {
  156. pLedConfig->YellowLED = YES;
  157. }
  158. #else
  159. pLedConfig->YellowLED = YES;
  160. #endif
  161. pLedConfig->GreenLED = NO;
  162. //}
  163. break;
  164. case S_MAINTAIN:
  165. case S_FAULT:
  166. case S_UPDATE:
  167. pLedConfig->YellowLED = NO;
  168. pLedConfig->GreenLED = NO;
  169. pLedConfig->RedLED = YES;
  170. //if (pSysWarning->Level == WARN_LV_ER) {
  171. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  172. // break;
  173. // }
  174. // pLedConfig->RedLED = YES;
  175. //}
  176. break;
  177. case S_BOOKING:
  178. case S_DEBUG:
  179. case S_NONE:
  180. break;
  181. }//switch
  182. }//for
  183. usleep(500000);
  184. }//while
  185. }//fork
  186. }
  187. //------------------------------------------------------------------------------
  188. static void checkChargingInfoByDC(uint8_t systemStatus)
  189. {
  190. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  191. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  192. struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  193. switch (systemStatus) {
  194. case S_IDLE:
  195. case S_RESERVATION:
  196. if (isDetectPlugin()) {
  197. _DetectPlugInTimeout();
  198. StopSystemTimeoutDet();
  199. destroySelGun(pSysInfo->CurGunSelected);
  200. } else {
  201. if( pSysConfig->isAuthrizeByEVCCID && pSysInfo->ConnectorPage == _LCM_PRE_CHARGE) {
  202. _evccidlinktimeout(pSysInfo->CurGunSelected);
  203. pDcChargingInfo->isEVCCIDVerify = true;
  204. break;
  205. }
  206. #if !defined DD360Audi
  207. break;
  208. #endif //!defined DD360Audi
  209. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  210. //printf("destroy gun = %d", pSysInfo->CurGunSelected);
  211. destroySelGun(pSysInfo->CurGunSelected);
  212. } else {
  213. confirmSelGun(pSysInfo->CurGunSelected);
  214. log_info("confirm select gun ............................... %d ",
  215. pSysInfo->CurGunSelected);
  216. }
  217. }
  218. break;
  219. case S_REASSIGN_CHECK:
  220. case S_REASSIGN:
  221. case S_PREPARNING:
  222. case S_PREPARING_FOR_EV:
  223. case S_PREPARING_FOR_EVSE:
  224. case S_CCS_PRECHARGE_ST0:
  225. case S_CCS_PRECHARGE_ST1:
  226. // 取消充電
  227. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  228. AcChargingTerminalProcess();
  229. } else {
  230. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  231. }
  232. break;
  233. case S_CHARGING:
  234. if (pSysConfig->StopChargingByButton == YES ||
  235. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  236. // 停止充電
  237. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  238. }
  239. break;
  240. case S_COMPLETE:
  241. break;
  242. }
  243. }
  244. static void checkChargingInfoByAC(void)
  245. {
  246. struct ChargingInfoData *pAcChargingInfo = NULL;
  247. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  248. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  249. if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  250. return;
  251. }
  252. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  253. switch (pAcChargingInfo->SystemStatus) {
  254. case S_IDLE:
  255. if (isDetectPlugin()) {
  256. _DetectPlugInTimeout();
  257. StopSystemTimeoutDet();
  258. }
  259. break;
  260. case S_REASSIGN_CHECK:
  261. case S_REASSIGN:
  262. case S_PREPARNING:
  263. case S_PREPARING_FOR_EV:
  264. case S_PREPARING_FOR_EVSE:
  265. case S_CCS_PRECHARGE_ST0:
  266. case S_CCS_PRECHARGE_ST1:
  267. // 取消充電
  268. AcChargingTerminalProcess();
  269. break;
  270. case S_CHARGING:
  271. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  272. // 停止充電
  273. AcChargingTerminalProcess();
  274. }
  275. break;
  276. case S_COMPLETE:
  277. break;
  278. }
  279. }
  280. void ChkPrimaryStatus(void)
  281. {
  282. static bool leftBtnPush = false;
  283. static bool rightBtnPush = false;
  284. uint8_t i = 0;
  285. uint8_t Rtn = 0;
  286. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  287. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  288. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  289. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  290. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  291. struct ChargingInfoData *pDcChargingInfo = NULL;
  292. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  293. if (pSysWarning->WarningCount > 0) {
  294. Rtn = 0;
  295. for (i = 0; i < pSysWarning->WarningCount; i++) {
  296. if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
  297. EmcOccureByString("042251");
  298. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
  299. Rtn = 1;
  300. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
  301. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
  302. EmcOccureByString("042252");
  303. Rtn = 1;
  304. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042327", 6) == 0) {
  305. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = YES;
  306. EmcOccureByString("042327");
  307. Rtn = 1;
  308. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042328", 6) == 0) {
  309. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = YES;
  310. EmcOccureByString("042328");
  311. Rtn = 1;
  312. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
  313. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
  314. EmcOccureByString("042200");
  315. Rtn = 1;
  316. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
  317. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
  318. EmcOccureByString("042201");
  319. Rtn = 1;
  320. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
  321. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
  322. EmcOccureByString("042202");
  323. Rtn = 1;
  324. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
  325. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
  326. EmcOccureByString("042267");
  327. Rtn = 1;
  328. } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  329. EmcOccureByString("012304");
  330. Rtn = 1;
  331. }
  332. }
  333. if (Rtn == 0) {
  334. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  335. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  336. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
  337. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
  338. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  339. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  340. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  341. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  342. ReleaseEmsOccureByString(0, "042251");
  343. ReleaseEmsOccureByString(0, "042252");
  344. ReleaseEmsOccureByString(0, "042327");
  345. ReleaseEmsOccureByString(0, "042328");
  346. ReleaseEmsOccureByString(0, "042200");
  347. ReleaseEmsOccureByString(0, "042201");
  348. ReleaseEmsOccureByString(0, "042202");
  349. ReleaseEmsOccureByString(0, "042267");
  350. ReleaseEmsOccureByString(0, "012304");
  351. }
  352. } else {
  353. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  354. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  355. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
  356. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
  357. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  358. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  359. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  360. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  361. ReleaseEmsOccureByString(0, "042251");
  362. ReleaseEmsOccureByString(0, "042252");
  363. ReleaseEmsOccureByString(0, "042327");
  364. ReleaseEmsOccureByString(0, "042328");
  365. ReleaseEmsOccureByString(0, "042200");
  366. ReleaseEmsOccureByString(0, "042201");
  367. ReleaseEmsOccureByString(0, "042202");
  368. ReleaseEmsOccureByString(0, "042267");
  369. ReleaseEmsOccureByString(0, "012304");
  370. }
  371. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
  372. pAlarmCode->AlarmEvents.bits.EmergencyStopTrip = YES;
  373. EmcOccureByString("012251");
  374. } else {
  375. ReleaseEmsOccureByString(0, "012251");
  376. }
  377. if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == ABNORMAL) {
  378. pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip = YES;
  379. EmcOccureByString("012238");
  380. } else {
  381. ReleaseEmsOccureByString(0, "012238");
  382. }
  383. if (ShmPrimaryMcuData->InputDet.bits.SpdDetec == ABNORMAL) {
  384. pAlarmCode->AlarmEvents.bits.SpdTrip = YES;
  385. } else {
  386. pAlarmCode->AlarmEvents.bits.SpdTrip = NO;
  387. }
  388. if (ShmPrimaryMcuData->InputDet.bits.DoorOpen == ABNORMAL) {
  389. pAlarmCode->AlarmEvents.bits.DoorOpen = YES;
  390. EmcOccureByString("012252");
  391. } else {
  392. ReleaseEmsOccureByString(0, "012252");
  393. }
  394. //DS60-120 add
  395. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  396. ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
  397. pSysConfig->ShowInformation = YES;
  398. showInfoTimer = time((time_t*)NULL);
  399. } else {
  400. if ( (time((time_t*)NULL) - showInfoTimer) > 3 )
  401. pSysConfig->ShowInformation = NO;
  402. }
  403. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  404. !leftBtnPush &&
  405. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  406. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  407. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL
  408. ) {
  409. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  410. if (!leftBtnPush) {
  411. leftBtnPush = true;
  412. log_info("left btn down...............................%x",
  413. pDcChargingInfo->SystemStatus);
  414. checkChargingInfoByAC();
  415. checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
  416. #if 0
  417. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  418. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  419. switch (pAcChargingInfo->SystemStatus) {
  420. case S_IDLE:
  421. if (isDetectPlugin()) {
  422. _DetectPlugInTimeout();
  423. StopSystemTimeoutDet();
  424. }
  425. break;
  426. case S_REASSIGN_CHECK:
  427. case S_REASSIGN:
  428. case S_PREPARNING:
  429. case S_PREPARING_FOR_EV:
  430. case S_PREPARING_FOR_EVSE:
  431. case S_CCS_PRECHARGE_ST0:
  432. case S_CCS_PRECHARGE_ST1:
  433. // 取消充電
  434. AcChargingTerminalProcess();
  435. break;
  436. case S_CHARGING:
  437. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  438. // 停止充電
  439. AcChargingTerminalProcess();
  440. }
  441. break;
  442. case S_COMPLETE:
  443. break;
  444. }
  445. }
  446. switch (pDcChargingInfo->SystemStatus) {
  447. case S_IDLE:
  448. if (isDetectPlugin()) {
  449. _DetectPlugInTimeout();
  450. StopSystemTimeoutDet();
  451. destroySelGun(pSysInfo->CurGunSelected);
  452. } else {
  453. #if defined DD360Audi
  454. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  455. //printf("destroy gun = %d", pSysInfo->CurGunSelected);
  456. destroySelGun(pSysInfo->CurGunSelected);
  457. } else {
  458. confirmSelGun(pSysInfo->CurGunSelected);
  459. log_info("confirm select gun ............................... %d ",
  460. pSysInfo->CurGunSelected);
  461. }
  462. #endif //defined DD360Audi
  463. }
  464. break;
  465. case S_REASSIGN_CHECK:
  466. case S_REASSIGN:
  467. case S_PREPARNING:
  468. case S_PREPARING_FOR_EV:
  469. case S_PREPARING_FOR_EVSE:
  470. case S_CCS_PRECHARGE_ST0:
  471. case S_CCS_PRECHARGE_ST1:
  472. // 取消充電
  473. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  474. AcChargingTerminalProcess();
  475. } else {
  476. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  477. }
  478. break;
  479. case S_CHARGING:
  480. if (pSysConfig->StopChargingByButton == YES ||
  481. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  482. // 停止充電
  483. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  484. }
  485. break;
  486. case S_COMPLETE:
  487. // 回 IDLE
  488. //log_info("right btn down.................S_COMPLETE ");
  489. //pDcChargingInfo->SystemStatus = S_IDLE;
  490. break;
  491. }
  492. #endif //0
  493. }
  494. } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
  495. if (leftBtnPush) {
  496. leftBtnPush = false;
  497. //log_info("left btn up............................... ");
  498. }
  499. }
  500. if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
  501. !rightBtnPush &&
  502. #if defined DD360Audi
  503. pSysInfo->SystemPage != _LCM_IDLE &&
  504. #endif
  505. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  506. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  507. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL &&
  508. pSysInfo->SystemPage != _LCM_WAIT_FOR_PLUG
  509. ) {
  510. if (!rightBtnPush) {
  511. rightBtnPush = true;
  512. //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
  513. if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
  514. pSysInfo->IsAlternatvieConf == NO) {
  515. pSysInfo->CurGunSelected++;
  516. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  517. } else if (pSysConfig->AcConnectorCount > 0 &&
  518. pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  519. pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
  520. } else if (pSysInfo->IsAlternatvieConf == YES) {
  521. for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
  522. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
  523. if (pDcChargingInfo->SystemStatus != S_BOOTING &&
  524. pDcChargingInfo->SystemStatus != S_IDLE &&
  525. pDcChargingInfo->SystemStatus != S_RESERVATION) {
  526. pSysInfo->CurGunSelected = _index;
  527. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  528. return;
  529. }
  530. }
  531. pSysInfo->CurGunSelected = 0;
  532. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  533. } else {
  534. pSysInfo->CurGunSelected = 0;
  535. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  536. }
  537. log_info("current select gun ............................... %d ",
  538. pSysInfo->CurGunSelected);
  539. }
  540. } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
  541. if (rightBtnPush) {
  542. rightBtnPush = false;
  543. //log_info("right btn up............................... ");
  544. }
  545. }
  546. }