Primary.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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. time_t showInfoTimer;
  24. //------------------------------------------------------------------------------
  25. static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
  26. {
  27. uint8_t ret = NO;
  28. LedConfig *pLedConfig = (LedConfig *)ledConfig;
  29. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  30. if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
  31. ret = YES;
  32. if (pLedConfig->RedLED == YES ||
  33. pLedConfig->YellowLED == YES ||
  34. pLedConfig->GreenLED == YES) {
  35. pLedConfig->RedLED = NO;
  36. pLedConfig->YellowLED = NO;
  37. pLedConfig->GreenLED = NO;
  38. } else {
  39. pLedConfig->RedLED = YES;
  40. pLedConfig->YellowLED = YES;
  41. pLedConfig->GreenLED = YES;
  42. }
  43. }
  44. return ret;
  45. }
  46. void PrimaryLedIndicatorCtrlFork(void)
  47. {
  48. #if !defined DD360ComBox
  49. return;
  50. #endif //!defined DD360ComBox
  51. pid_t pid = fork();
  52. if (pid == 0) {
  53. uint8_t gunIndex = 0;
  54. int isContinue = 1;
  55. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  56. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  57. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  58. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  59. struct ChargingInfoData *pDcChargingInfo = NULL;
  60. LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
  61. while (isContinue) {
  62. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  63. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  64. if (pSysWarning->Level == WARN_LV_ER) {
  65. if (checkCabinetEthConnectState(pLedConfig) == YES) {
  66. usleep(500000);
  67. continue;
  68. }
  69. pLedConfig->YellowLED = NO;
  70. pLedConfig->GreenLED = NO;
  71. pLedConfig->RedLED = YES;
  72. usleep(500000);
  73. continue;
  74. }
  75. //log_info("led indicator status = %d", pDcChargingInfo->SystemStatus);
  76. //printf("level = %d", pSysWarning->Level);
  77. switch (pDcChargingInfo->SystemStatus) {
  78. case S_BOOTING:
  79. if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
  80. //Module_DoComm tcp disconnect
  81. if (pLedConfig->RedLED == YES ||
  82. pLedConfig->YellowLED == YES ||
  83. pLedConfig->GreenLED == YES) {
  84. pLedConfig->RedLED = NO;
  85. pLedConfig->YellowLED = NO;
  86. pLedConfig->GreenLED = NO;
  87. } else {
  88. pLedConfig->RedLED = YES;
  89. pLedConfig->YellowLED = YES;
  90. pLedConfig->GreenLED = YES;
  91. }
  92. break;
  93. }
  94. pLedConfig->RedLED = YES;
  95. pLedConfig->YellowLED = YES;
  96. pLedConfig->GreenLED = YES;
  97. break;
  98. case S_IDLE:
  99. //Module_DoComm connected and system idle
  100. pLedConfig->RedLED = NO;
  101. pLedConfig->YellowLED = NO;
  102. pLedConfig->GreenLED = YES;
  103. break;
  104. case S_RESERVATION:
  105. case S_AUTHORIZING:
  106. case S_REASSIGN_CHECK:
  107. case S_REASSIGN:
  108. case S_PREPARNING:
  109. case S_PREPARING_FOR_EV:
  110. case S_PREPARING_FOR_EVSE:
  111. case S_CCS_PRECHARGE_ST0:
  112. case S_CCS_PRECHARGE_ST1:
  113. //precharging status
  114. if (pLedConfig->GreenLED == YES) {
  115. pLedConfig->GreenLED = NO;
  116. } else {
  117. pLedConfig->GreenLED = YES;
  118. }
  119. break;
  120. case S_CHARGING:
  121. pLedConfig->RedLED = NO;
  122. #ifdef DD360ComBox
  123. pLedConfig->YellowLED = YES;
  124. #else
  125. if (pLedConfig->YellowLED == YES) {
  126. pLedConfig->YellowLED = NO;
  127. } else {
  128. pLedConfig->YellowLED = YES;
  129. }
  130. #endif
  131. pLedConfig->GreenLED = NO;
  132. break;
  133. case S_ALARM:
  134. pLedConfig->YellowLED = NO;
  135. pLedConfig->GreenLED = NO;
  136. if (checkCabinetEthConnectState(pLedConfig) == YES) {
  137. break;
  138. }
  139. pLedConfig->RedLED = YES;
  140. break;
  141. case S_TERMINATING:
  142. case S_COMPLETE:
  143. //if (pSysWarning->Level == WARN_LV_ER) {
  144. // pLedConfig->YellowLED = NO;
  145. // pLedConfig->GreenLED = NO;
  146. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  147. // break;
  148. // }
  149. // pLedConfig->RedLED = YES;
  150. //} else {
  151. pLedConfig->RedLED = NO;
  152. #ifdef DD360ComBox
  153. if (pLedConfig->YellowLED == YES) {
  154. pLedConfig->YellowLED = NO;
  155. } else {
  156. pLedConfig->YellowLED = YES;
  157. }
  158. #else
  159. pLedConfig->YellowLED = YES;
  160. #endif
  161. pLedConfig->GreenLED = NO;
  162. //}
  163. break;
  164. case S_MAINTAIN:
  165. case S_FAULT:
  166. case S_UPDATE:
  167. pLedConfig->YellowLED = NO;
  168. pLedConfig->GreenLED = NO;
  169. pLedConfig->RedLED = YES;
  170. //if (pSysWarning->Level == WARN_LV_ER) {
  171. // if (checkCabinetEthConnectState(pLedConfig) == YES) {
  172. // break;
  173. // }
  174. // pLedConfig->RedLED = YES;
  175. //}
  176. break;
  177. case S_BOOKING:
  178. case S_DEBUG:
  179. case S_NONE:
  180. break;
  181. }//switch
  182. }//for
  183. usleep(500000);
  184. }//while
  185. }//fork
  186. }
  187. //------------------------------------------------------------------------------
  188. static void checkChargingInfoByDC(uint8_t systemStatus)
  189. {
  190. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  191. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  192. struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  193. switch (systemStatus) {
  194. case S_IDLE:
  195. case S_RESERVATION:
  196. if (isDetectPlugin(pSysInfo->CurGunSelected)) {
  197. _DetectPlugInTimeout(pSysInfo->CurGunSelected);
  198. destroySelGun(pSysInfo->CurGunSelected);
  199. } else {
  200. if( pSysConfig->isAuthrizeByEVCCID && pSysInfo->ConnectorPage == _LCM_PRE_CHARGE) {
  201. _evccidlinktimeout(pSysInfo->CurGunSelected);
  202. pDcChargingInfo->isEVCCIDVerify = true;
  203. break;
  204. }
  205. #if !defined DD360Audi
  206. break;
  207. #endif //!defined DD360Audi
  208. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  209. //printf("destroy gun = %d", pSysInfo->CurGunSelected);
  210. destroySelGun(pSysInfo->CurGunSelected);
  211. } else {
  212. confirmSelGun(pSysInfo->CurGunSelected);
  213. log_info("confirm select gun ............................... %d ",
  214. pSysInfo->CurGunSelected);
  215. }
  216. }
  217. break;
  218. case S_REASSIGN_CHECK:
  219. case S_REASSIGN:
  220. case S_PREPARNING:
  221. case S_PREPARING_FOR_EV:
  222. case S_PREPARING_FOR_EVSE:
  223. case S_CCS_PRECHARGE_ST0:
  224. case S_CCS_PRECHARGE_ST1:
  225. // 取消充電
  226. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  227. AcChargingTerminalProcess();
  228. } else {
  229. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  230. }
  231. break;
  232. case S_CHARGING:
  233. if (pSysConfig->StopChargingByButton == YES ||
  234. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE ||
  235. pSysConfig->isAuthrizeByEVCCID) {
  236. // 停止充電
  237. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  238. }
  239. break;
  240. case S_COMPLETE:
  241. break;
  242. }
  243. }
  244. static void checkChargingInfoByAC(void)
  245. {
  246. struct ChargingInfoData *pAcChargingInfo = NULL;
  247. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  248. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  249. if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  250. return;
  251. }
  252. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  253. switch (pAcChargingInfo->SystemStatus) {
  254. case S_IDLE:
  255. if (isDetectPlugin(pSysInfo->CurGunSelected)) {
  256. _DetectPlugInTimeout(pSysInfo->CurGunSelected);
  257. }
  258. break;
  259. case S_REASSIGN_CHECK:
  260. case S_REASSIGN:
  261. case S_PREPARNING:
  262. case S_PREPARING_FOR_EV:
  263. case S_PREPARING_FOR_EVSE:
  264. case S_CCS_PRECHARGE_ST0:
  265. case S_CCS_PRECHARGE_ST1:
  266. // 取消充電
  267. AcChargingTerminalProcess();
  268. break;
  269. case S_CHARGING:
  270. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  271. // 停止充電
  272. AcChargingTerminalProcess();
  273. }
  274. break;
  275. case S_COMPLETE:
  276. break;
  277. }
  278. }
  279. void ChkPrimaryStatus(void)
  280. {
  281. static bool leftBtnPush = false;
  282. static bool rightBtnPush = false;
  283. uint8_t i = 0;
  284. uint8_t Rtn = 0;
  285. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  286. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  287. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  288. struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  289. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  290. struct ChargingInfoData *pDcChargingInfo = NULL;
  291. DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  292. if (pSysWarning->WarningCount > 0) {
  293. Rtn = 0;
  294. for (i = 0; i < pSysWarning->WarningCount; i++) {
  295. if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
  296. EmcOccureByString("042251");
  297. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
  298. Rtn = 1;
  299. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
  300. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
  301. EmcOccureByString("042252");
  302. Rtn = 1;
  303. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042327", 6) == 0) {
  304. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = YES;
  305. EmcOccureByString("042327");
  306. Rtn = 1;
  307. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042328", 6) == 0) {
  308. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = YES;
  309. EmcOccureByString("042328");
  310. Rtn = 1;
  311. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
  312. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
  313. EmcOccureByString("042200");
  314. Rtn = 1;
  315. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
  316. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
  317. EmcOccureByString("042201");
  318. Rtn = 1;
  319. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
  320. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
  321. EmcOccureByString("042202");
  322. Rtn = 1;
  323. } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
  324. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
  325. EmcOccureByString("042267");
  326. Rtn = 1;
  327. } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
  328. EmcOccureByString("012304");
  329. Rtn = 1;
  330. }
  331. }
  332. if (Rtn == 0) {
  333. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  334. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  335. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
  336. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
  337. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  338. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  339. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  340. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  341. ReleaseEmsOccureByString(0, "042251");
  342. ReleaseEmsOccureByString(0, "042252");
  343. ReleaseEmsOccureByString(0, "042327");
  344. ReleaseEmsOccureByString(0, "042328");
  345. ReleaseEmsOccureByString(0, "042200");
  346. ReleaseEmsOccureByString(0, "042201");
  347. ReleaseEmsOccureByString(0, "042202");
  348. ReleaseEmsOccureByString(0, "042267");
  349. ReleaseEmsOccureByString(0, "012304");
  350. }
  351. } else {
  352. ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
  353. ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
  354. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
  355. ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
  356. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
  357. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
  358. ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
  359. ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
  360. ReleaseEmsOccureByString(0, "042251");
  361. ReleaseEmsOccureByString(0, "042252");
  362. ReleaseEmsOccureByString(0, "042327");
  363. ReleaseEmsOccureByString(0, "042328");
  364. ReleaseEmsOccureByString(0, "042200");
  365. ReleaseEmsOccureByString(0, "042201");
  366. ReleaseEmsOccureByString(0, "042202");
  367. ReleaseEmsOccureByString(0, "042267");
  368. ReleaseEmsOccureByString(0, "012304");
  369. }
  370. if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
  371. pAlarmCode->AlarmEvents.bits.EmergencyStopTrip = YES;
  372. EmcOccureByString("012251");
  373. } else {
  374. ReleaseEmsOccureByString(0, "012251");
  375. }
  376. if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == ABNORMAL) {
  377. pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip = YES;
  378. EmcOccureByString("012238");
  379. } else {
  380. ReleaseEmsOccureByString(0, "012238");
  381. }
  382. if (ShmPrimaryMcuData->InputDet.bits.SpdDetec == ABNORMAL) {
  383. pAlarmCode->AlarmEvents.bits.SpdTrip = YES;
  384. } else {
  385. pAlarmCode->AlarmEvents.bits.SpdTrip = NO;
  386. }
  387. if (ShmPrimaryMcuData->InputDet.bits.DoorOpen == ABNORMAL) {
  388. pAlarmCode->AlarmEvents.bits.DoorOpen = YES;
  389. EmcOccureByString("012252");
  390. } else {
  391. ReleaseEmsOccureByString(0, "012252");
  392. }
  393. //DS60-120 add
  394. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  395. ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
  396. pSysConfig->ShowInformation = YES;
  397. showInfoTimer = time((time_t*)NULL);
  398. } else {
  399. if ( (time((time_t*)NULL) - showInfoTimer) > 3 )
  400. pSysConfig->ShowInformation = NO;
  401. }
  402. if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
  403. !leftBtnPush &&
  404. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  405. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  406. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL
  407. ) {
  408. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  409. if (!leftBtnPush) {
  410. leftBtnPush = true;
  411. log_info("left btn down...............................%x",
  412. pDcChargingInfo->SystemStatus);
  413. checkChargingInfoByAC();
  414. checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
  415. #if 0
  416. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  417. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  418. switch (pAcChargingInfo->SystemStatus) {
  419. case S_IDLE:
  420. if (isDetectPlugin()) {
  421. _DetectPlugInTimeout();
  422. StopSystemTimeoutDet();
  423. }
  424. break;
  425. case S_REASSIGN_CHECK:
  426. case S_REASSIGN:
  427. case S_PREPARNING:
  428. case S_PREPARING_FOR_EV:
  429. case S_PREPARING_FOR_EVSE:
  430. case S_CCS_PRECHARGE_ST0:
  431. case S_CCS_PRECHARGE_ST1:
  432. // 取消充電
  433. AcChargingTerminalProcess();
  434. break;
  435. case S_CHARGING:
  436. if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  437. // 停止充電
  438. AcChargingTerminalProcess();
  439. }
  440. break;
  441. case S_COMPLETE:
  442. break;
  443. }
  444. }
  445. switch (pDcChargingInfo->SystemStatus) {
  446. case S_IDLE:
  447. if (isDetectPlugin()) {
  448. _DetectPlugInTimeout();
  449. StopSystemTimeoutDet();
  450. destroySelGun(pSysInfo->CurGunSelected);
  451. } else {
  452. #if defined DD360Audi
  453. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
  454. //printf("destroy gun = %d", pSysInfo->CurGunSelected);
  455. destroySelGun(pSysInfo->CurGunSelected);
  456. } else {
  457. confirmSelGun(pSysInfo->CurGunSelected);
  458. log_info("confirm select gun ............................... %d ",
  459. pSysInfo->CurGunSelected);
  460. }
  461. #endif //defined DD360Audi
  462. }
  463. break;
  464. case S_REASSIGN_CHECK:
  465. case S_REASSIGN:
  466. case S_PREPARNING:
  467. case S_PREPARING_FOR_EV:
  468. case S_PREPARING_FOR_EVSE:
  469. case S_CCS_PRECHARGE_ST0:
  470. case S_CCS_PRECHARGE_ST1:
  471. // 取消充電
  472. if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
  473. AcChargingTerminalProcess();
  474. } else {
  475. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  476. }
  477. break;
  478. case S_CHARGING:
  479. if (pSysConfig->StopChargingByButton == YES ||
  480. pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
  481. // 停止充電
  482. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  483. }
  484. break;
  485. case S_COMPLETE:
  486. // 回 IDLE
  487. //log_info("right btn down.................S_COMPLETE ");
  488. //pDcChargingInfo->SystemStatus = S_IDLE;
  489. break;
  490. }
  491. #endif //0
  492. }
  493. } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
  494. if (leftBtnPush) {
  495. leftBtnPush = false;
  496. //log_info("left btn up............................... ");
  497. }
  498. }
  499. if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
  500. !rightBtnPush &&
  501. #if defined DD360Audi
  502. pSysInfo->SystemPage != _LCM_IDLE &&
  503. #endif
  504. pSysInfo->SystemPage != _LCM_AUTHORIZING &&
  505. pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
  506. pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL &&
  507. pSysInfo->SystemPage != _LCM_WAIT_FOR_PLUG
  508. ) {
  509. if (!rightBtnPush) {
  510. rightBtnPush = true;
  511. //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
  512. if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
  513. pSysInfo->IsAlternatvieConf == NO) {
  514. pSysInfo->CurGunSelected++;
  515. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  516. } else if (pSysConfig->AcConnectorCount > 0 &&
  517. pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
  518. pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
  519. } else if (pSysInfo->IsAlternatvieConf == YES) {
  520. for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
  521. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
  522. if (pDcChargingInfo->SystemStatus != S_BOOTING &&
  523. pDcChargingInfo->SystemStatus != S_IDLE &&
  524. pDcChargingInfo->SystemStatus != S_RESERVATION) {
  525. pSysInfo->CurGunSelected = _index;
  526. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  527. return;
  528. }
  529. }
  530. pSysInfo->CurGunSelected = 0;
  531. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  532. } else {
  533. pSysInfo->CurGunSelected = 0;
  534. ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
  535. }
  536. log_info("current select gun ............................... %d ",
  537. pSysInfo->CurGunSelected);
  538. }
  539. } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
  540. if (rightBtnPush) {
  541. rightBtnPush = false;
  542. //log_info("right btn up............................... ");
  543. }
  544. }
  545. }