Primary.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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], "042200", 6) == 0) {
  303. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
  304. EmcOccureByString("042200");
  305. Rtn = 1;
  306. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
  307. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
  308. EmcOccureByString("042201");
  309. Rtn = 1;
  310. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
  311. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
  312. EmcOccureByString("042202");
  313. Rtn = 1;
  314. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
  315. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
  316. EmcOccureByString("042267");
  317. Rtn = 1;
  318. } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  319. EmcOccureByString("012304");
  320. Rtn = 1;
  321. }
  322. }
  323. if (Rtn == 0) {
  324. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  325. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  326. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  327. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  328. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  329. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  330. ReleaseEmsOccureByString(0, "042251");
  331. ReleaseEmsOccureByString(0, "042252");
  332. ReleaseEmsOccureByString(0, "042200");
  333. ReleaseEmsOccureByString(0, "042201");
  334. ReleaseEmsOccureByString(0, "042202");
  335. ReleaseEmsOccureByString(0, "042267");
  336. ReleaseEmsOccureByString(0, "012304");
  337. }
  338. } else {
  339. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  340. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  341. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  342. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  343. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  344. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  345. ReleaseEmsOccureByString(0, "042251");
  346. ReleaseEmsOccureByString(0, "042252");
  347. ReleaseEmsOccureByString(0, "042200");
  348. ReleaseEmsOccureByString(0, "042201");
  349. ReleaseEmsOccureByString(0, "042202");
  350. ReleaseEmsOccureByString(0, "042267");
  351. ReleaseEmsOccureByString(0, "012304");
  352. }
  353. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
  354. pAlarmCode->AlarmEvents.bits.EmergencyStopTrip = YES;
  355. EmcOccureByString("012251");
  356. } else {
  357. ReleaseEmsOccureByString(0, "012251");
  358. }
  359. if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == ABNORMAL) {
  360. pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip = YES;
  361. EmcOccureByString("012238");
  362. } else {
  363. ReleaseEmsOccureByString(0, "012238");
  364. }
  365. if (ShmPrimaryMcuData->InputDet.bits.SpdDetec == ABNORMAL) {
  366. pAlarmCode->AlarmEvents.bits.SpdTrip = YES;
  367. } else {
  368. pAlarmCode->AlarmEvents.bits.SpdTrip = NO;
  369. }
  370. if (ShmPrimaryMcuData->InputDet.bits.DoorOpen == ABNORMAL) {
  371. pAlarmCode->AlarmEvents.bits.DoorOpen = YES;
  372. EmcOccureByString("012252");
  373. } else {
  374. ReleaseEmsOccureByString(0, "012252");
  375. }
  376. //DS60-120 add
  377. //if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  378. // ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
  379. // pSysConfig->ShowInformation = YES;
  380. //} else {
  381. // pSysConfig->ShowInformation = NO;
  382. //}
  383. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  384. !leftBtnPush
  385. #if defined DD360Audi
  386. &&
  387. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  388. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  389. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL
  390. #endif //defined DD360Audi
  391. ) {
  392. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  393. if (!leftBtnPush) {
  394. leftBtnPush = true;
  395. log_info("left btn down...............................%x",
  396. pDcChargingInfo->SystemStatus);
  397. checkChargingInfoByAC();
  398. checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
  399. #if 0
  400. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  401. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  402. switch (pAcChargingInfo->SystemStatus) {
  403. case S_IDLE:
  404. if (isDetectPlugin()) {
  405. _DetectPlugInTimeout();
  406. StopSystemTimeoutDet();
  407. }
  408. break;
  409. case S_REASSIGN_CHECK:
  410. case S_REASSIGN:
  411. case S_PREPARNING:
  412. case S_PREPARING_FOR_EV:
  413. case S_PREPARING_FOR_EVSE:
  414. case S_CCS_PRECHARGE_ST0:
  415. case S_CCS_PRECHARGE_ST1:
  416. // 取消充電
  417. AcChargingTerminalProcess();
  418. break;
  419. case S_CHARGING:
  420. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  421. // 停止充電
  422. AcChargingTerminalProcess();
  423. }
  424. break;
  425. case S_COMPLETE:
  426. break;
  427. }
  428. }
  429. switch (pDcChargingInfo->SystemStatus) {
  430. case S_IDLE:
  431. if (isDetectPlugin()) {
  432. _DetectPlugInTimeout();
  433. StopSystemTimeoutDet();
  434. destroySelGun(pSysInfo->CurGunSelected);
  435. } else {
  436. #if defined DD360Audi
  437. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  438. //printf("destroy gun = %d", pSysInfo->CurGunSelected);
  439. destroySelGun(pSysInfo->CurGunSelected);
  440. } else {
  441. confirmSelGun(pSysInfo->CurGunSelected);
  442. log_info("confirm select gun ............................... %d ",
  443. pSysInfo->CurGunSelected);
  444. }
  445. #endif //defined DD360Audi
  446. }
  447. break;
  448. case S_REASSIGN_CHECK:
  449. case S_REASSIGN:
  450. case S_PREPARNING:
  451. case S_PREPARING_FOR_EV:
  452. case S_PREPARING_FOR_EVSE:
  453. case S_CCS_PRECHARGE_ST0:
  454. case S_CCS_PRECHARGE_ST1:
  455. // 取消充電
  456. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  457. AcChargingTerminalProcess();
  458. } else {
  459. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  460. }
  461. break;
  462. case S_CHARGING:
  463. if (pSysConfig->StopChargingByButton == YES ||
  464. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  465. // 停止充電
  466. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  467. }
  468. break;
  469. case S_COMPLETE:
  470. // 回 IDLE
  471. //log_info("right btn down.................S_COMPLETE ");
  472. //pDcChargingInfo->SystemStatus = S_IDLE;
  473. break;
  474. }
  475. #endif //0
  476. }
  477. } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
  478. if (leftBtnPush) {
  479. leftBtnPush = false;
  480. //log_info("left btn up............................... ");
  481. }
  482. }
  483. if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
  484. !rightBtnPush
  485. #if defined DD360Audi
  486. &&
  487. pSysInfo->SystemPage != _LCM_IDLE &&
  488. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  489. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  490. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL &&
  491. pSysInfo->SystemPage != _LCM_WAIT_FOR_PLUG
  492. #endif //defined DD360Audi
  493. ) {
  494. if (!rightBtnPush) {
  495. rightBtnPush = true;
  496. //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
  497. if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
  498. pSysInfo->IsAlternatvieConf == NO) {
  499. pSysInfo->CurGunSelected++;
  500. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  501. } else if (pSysConfig->AcConnectorCount > 0 &&
  502. pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  503. pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
  504. } else if (pSysInfo->IsAlternatvieConf == YES) {
  505. for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
  506. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
  507. if (pDcChargingInfo->SystemStatus != S_BOOTING &&
  508. pDcChargingInfo->SystemStatus != S_IDLE &&
  509. pDcChargingInfo->SystemStatus != S_RESERVATION) {
  510. pSysInfo->CurGunSelected = _index;
  511. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  512. return;
  513. }
  514. }
  515. pSysInfo->CurGunSelected = 0;
  516. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  517. } else {
  518. pSysInfo->CurGunSelected = 0;
  519. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  520. }
  521. }
  522. log_info("current select gun ............................... %d ",
  523. pSysInfo->CurGunSelected);
  524. } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
  525. if (rightBtnPush) {
  526. rightBtnPush = false;
  527. //log_info("right btn up............................... ");
  528. }
  529. }
  530. }