Primary.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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. //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
  75. //printf("level = %d\r\n", 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. if (pLedConfig->YellowLED == YES) {
  123. pLedConfig->YellowLED = NO;
  124. } else {
  125. pLedConfig->YellowLED = YES;
  126. }
  127. #else
  128. pLedConfig->YellowLED = YES;
  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. pLedConfig->YellowLED = YES;
  153. #else
  154. if (pLedConfig->YellowLED == YES) {
  155. pLedConfig->YellowLED = NO;
  156. } else {
  157. pLedConfig->YellowLED = YES;
  158. }
  159. #endif
  160. pLedConfig->GreenLED = NO;
  161. //}
  162. break;
  163. case S_MAINTAIN:
  164. case S_FAULT:
  165. pLedConfig->YellowLED = NO;
  166. pLedConfig->GreenLED = NO;
  167. pLedConfig->RedLED = YES;
  168. //if (pSysWarning->Level == WARN_LV_ER) {
  169. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  170. // break;
  171. // }
  172. // pLedConfig->RedLED = YES;
  173. //}
  174. break;
  175. case S_BOOKING:
  176. case S_DEBUG:
  177. case S_UPDATE:
  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. switch (systemStatus) {
  192. case S_IDLE:
  193. if (isDetectPlugin()) {
  194. _DetectPlugInTimeout();
  195. StopSystemTimeoutDet();
  196. destroySelGun(pSysInfo->CurGunSelected);
  197. } else {
  198. #if !defined DD360Audi
  199. break;
  200. #endif //!defined DD360Audi
  201. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  202. //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
  203. destroySelGun(pSysInfo->CurGunSelected);
  204. } else {
  205. confirmSelGun(pSysInfo->CurGunSelected);
  206. log_info("confirm select gun ............................... %d \n",
  207. pSysInfo->CurGunSelected);
  208. }
  209. }
  210. break;
  211. case S_REASSIGN_CHECK:
  212. case S_REASSIGN:
  213. case S_PREPARNING:
  214. case S_PREPARING_FOR_EV:
  215. case S_PREPARING_FOR_EVSE:
  216. case S_CCS_PRECHARGE_ST0:
  217. case S_CCS_PRECHARGE_ST1:
  218. // 取消充電
  219. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  220. AcChargingTerminalProcess();
  221. } else {
  222. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  223. }
  224. break;
  225. case S_CHARGING:
  226. if (pSysConfig->StopChargingByButton == YES ||
  227. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  228. // 停止充電
  229. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  230. }
  231. break;
  232. case S_COMPLETE:
  233. break;
  234. }
  235. }
  236. static void checkChargingInfoByAC(void)
  237. {
  238. struct ChargingInfoData *pAcChargingInfo = NULL;
  239. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  240. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  241. if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  242. return;
  243. }
  244. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  245. switch (pAcChargingInfo->SystemStatus) {
  246. case S_IDLE:
  247. if (isDetectPlugin()) {
  248. _DetectPlugInTimeout();
  249. StopSystemTimeoutDet();
  250. }
  251. break;
  252. case S_REASSIGN_CHECK:
  253. case S_REASSIGN:
  254. case S_PREPARNING:
  255. case S_PREPARING_FOR_EV:
  256. case S_PREPARING_FOR_EVSE:
  257. case S_CCS_PRECHARGE_ST0:
  258. case S_CCS_PRECHARGE_ST1:
  259. // 取消充電
  260. AcChargingTerminalProcess();
  261. break;
  262. case S_CHARGING:
  263. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  264. // 停止充電
  265. AcChargingTerminalProcess();
  266. }
  267. break;
  268. case S_COMPLETE:
  269. break;
  270. }
  271. }
  272. void ChkPrimaryStatus(void)
  273. {
  274. static bool leftBtnPush = false;
  275. static bool rightBtnPush = false;
  276. uint8_t i = 0;
  277. uint8_t Rtn = 0;
  278. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  279. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  280. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  281. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  282. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  283. struct ChargingInfoData *pDcChargingInfo = NULL;
  284. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  285. if (pSysWarning->WarningCount > 0) {
  286. Rtn = 0;
  287. for (i = 0; i < pSysWarning->WarningCount; i++) {
  288. if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
  289. EmcOccureByString("042251");
  290. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
  291. Rtn = 1;
  292. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
  293. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
  294. EmcOccureByString("042252");
  295. Rtn = 1;
  296. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
  297. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
  298. EmcOccureByString("042200");
  299. Rtn = 1;
  300. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
  301. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
  302. EmcOccureByString("042201");
  303. Rtn = 1;
  304. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
  305. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
  306. EmcOccureByString("042202");
  307. Rtn = 1;
  308. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
  309. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
  310. EmcOccureByString("042267");
  311. Rtn = 1;
  312. } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  313. EmcOccureByString("012304");
  314. Rtn = 1;
  315. }
  316. }
  317. if (Rtn == 0) {
  318. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  319. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  320. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  321. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  322. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  323. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  324. ReleaseEmsOccureByString(0, "042251");
  325. ReleaseEmsOccureByString(0, "042252");
  326. ReleaseEmsOccureByString(0, "042200");
  327. ReleaseEmsOccureByString(0, "042201");
  328. ReleaseEmsOccureByString(0, "042202");
  329. ReleaseEmsOccureByString(0, "042267");
  330. ReleaseEmsOccureByString(0, "012304");
  331. }
  332. } else {
  333. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  334. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  335. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  336. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  337. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  338. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  339. ReleaseEmsOccureByString(0, "042251");
  340. ReleaseEmsOccureByString(0, "042252");
  341. ReleaseEmsOccureByString(0, "042200");
  342. ReleaseEmsOccureByString(0, "042201");
  343. ReleaseEmsOccureByString(0, "042202");
  344. ReleaseEmsOccureByString(0, "042267");
  345. ReleaseEmsOccureByString(0, "012304");
  346. }
  347. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
  348. pAlarmCode->AlarmEvents.bits.EmergencyStopTrip = YES;
  349. EmcOccureByString("012251");
  350. } else {
  351. ReleaseEmsOccureByString(0, "012251");
  352. }
  353. if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == ABNORMAL) {
  354. pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip = YES;
  355. EmcOccureByString("012238");
  356. } else {
  357. ReleaseEmsOccureByString(0, "012238");
  358. }
  359. if (ShmPrimaryMcuData->InputDet.bits.SpdDetec == ABNORMAL) {
  360. pAlarmCode->AlarmEvents.bits.SpdTrip = YES;
  361. } else {
  362. pAlarmCode->AlarmEvents.bits.SpdTrip = NO;
  363. }
  364. if (ShmPrimaryMcuData->InputDet.bits.DoorOpen == ABNORMAL) {
  365. pAlarmCode->AlarmEvents.bits.DoorOpen = YES;
  366. EmcOccureByString("012252");
  367. } else {
  368. ReleaseEmsOccureByString(0, "012252");
  369. }
  370. //DS60-120 add
  371. //if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  372. // ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
  373. // pSysConfig->ShowInformation = YES;
  374. //} else {
  375. // pSysConfig->ShowInformation = NO;
  376. //}
  377. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  378. !leftBtnPush
  379. #if defined DD360Audi
  380. &&
  381. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  382. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  383. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL
  384. #endif //defined DD360Audi
  385. ) {
  386. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  387. if (!leftBtnPush) {
  388. leftBtnPush = true;
  389. log_info("left btn down...............................%x\n",
  390. pDcChargingInfo->SystemStatus);
  391. checkChargingInfoByAC();
  392. checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
  393. #if 0
  394. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  395. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  396. switch (pAcChargingInfo->SystemStatus) {
  397. case S_IDLE:
  398. if (isDetectPlugin()) {
  399. _DetectPlugInTimeout();
  400. StopSystemTimeoutDet();
  401. }
  402. break;
  403. case S_REASSIGN_CHECK:
  404. case S_REASSIGN:
  405. case S_PREPARNING:
  406. case S_PREPARING_FOR_EV:
  407. case S_PREPARING_FOR_EVSE:
  408. case S_CCS_PRECHARGE_ST0:
  409. case S_CCS_PRECHARGE_ST1:
  410. // 取消充電
  411. AcChargingTerminalProcess();
  412. break;
  413. case S_CHARGING:
  414. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  415. // 停止充電
  416. AcChargingTerminalProcess();
  417. }
  418. break;
  419. case S_COMPLETE:
  420. break;
  421. }
  422. }
  423. switch (pDcChargingInfo->SystemStatus) {
  424. case S_IDLE:
  425. if (isDetectPlugin()) {
  426. _DetectPlugInTimeout();
  427. StopSystemTimeoutDet();
  428. destroySelGun(pSysInfo->CurGunSelected);
  429. } else {
  430. #if defined DD360Audi
  431. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  432. //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
  433. destroySelGun(pSysInfo->CurGunSelected);
  434. } else {
  435. confirmSelGun(pSysInfo->CurGunSelected);
  436. log_info("confirm select gun ............................... %d \n",
  437. pSysInfo->CurGunSelected);
  438. }
  439. #endif //defined DD360Audi
  440. }
  441. break;
  442. case S_REASSIGN_CHECK:
  443. case S_REASSIGN:
  444. case S_PREPARNING:
  445. case S_PREPARING_FOR_EV:
  446. case S_PREPARING_FOR_EVSE:
  447. case S_CCS_PRECHARGE_ST0:
  448. case S_CCS_PRECHARGE_ST1:
  449. // 取消充電
  450. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  451. AcChargingTerminalProcess();
  452. } else {
  453. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  454. }
  455. break;
  456. case S_CHARGING:
  457. if (pSysConfig->StopChargingByButton == YES ||
  458. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  459. // 停止充電
  460. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  461. }
  462. break;
  463. case S_COMPLETE:
  464. // 回 IDLE
  465. //log_info("right btn down.................S_COMPLETE \n");
  466. //pDcChargingInfo->SystemStatus = S_IDLE;
  467. break;
  468. }
  469. #endif //0
  470. }
  471. } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
  472. if (leftBtnPush) {
  473. leftBtnPush = false;
  474. //log_info("left btn up............................... \n");
  475. }
  476. }
  477. if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
  478. !rightBtnPush
  479. #if defined DD360Audi
  480. &&
  481. pSysInfo->SystemPage != _LCM_IDLE &&
  482. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  483. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  484. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL &&
  485. pSysInfo->SystemPage != _LCM_WAIT_FOR_PLUG
  486. #endif //defined DD360Audi
  487. ) {
  488. if (!rightBtnPush) {
  489. rightBtnPush = true;
  490. //log_info("right btn down............................... %d \n", pSysInfo->CurGunSelected);
  491. if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
  492. pSysInfo->IsAlternatvieConf == NO) {
  493. pSysInfo->CurGunSelected++;
  494. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  495. } else if (pSysConfig->AcConnectorCount > 0 &&
  496. pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  497. pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
  498. } else if (pSysInfo->IsAlternatvieConf == YES) {
  499. for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
  500. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
  501. if (pDcChargingInfo->SystemStatus != S_BOOTING &&
  502. pDcChargingInfo->SystemStatus != S_IDLE &&
  503. pDcChargingInfo->SystemStatus != S_RESERVATION) {
  504. pSysInfo->CurGunSelected = _index;
  505. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  506. return;
  507. }
  508. }
  509. pSysInfo->CurGunSelected = 0;
  510. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  511. } else {
  512. pSysInfo->CurGunSelected = 0;
  513. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  514. }
  515. }
  516. log_info("current select gun ............................... %d \n",
  517. pSysInfo->CurGunSelected);
  518. } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
  519. if (rightBtnPush) {
  520. rightBtnPush = false;
  521. //log_info("right btn up............................... \n");
  522. }
  523. }
  524. }