Primary.c 21 KB

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