Primary.c 23 KB

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