Primary.c 22 KB

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