Primary.c 24 KB

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