Primary.c 23 KB

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