123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- void _CcsPrechargeTimeout(uint8_t gunIndex)
- {
- log_info("*********** _CcsPrechargeTimeout ***********\n");
- setChargerMode(gunIndex, MODE_IDLE);
- }
- void _DetectEvseChargingEnableTimeout(uint8_t gunIndex)
- {
- log_info("*********** _DetectEvseChargingEnableTimeout (GFD timeout) ***********\n");
- //if (chargingInfo[gunIndex]->GroundFaultStatus != GFD_PASS)
- {
- setChargerMode(gunIndex, MODE_IDLE);
- _AutoReturnTimeout();
- }
- }
- void _DetectEvChargingEnableTimeout(uint8_t gunIndex)
- {
- if (chargingInfo[gunIndex]->Type == _Type_Chademo) {
- if (!isEvGunLocked_chademo(gunIndex)) {
- log_info("*********** _DetectEvChargingEnableTimeout (chademo) ***********\n");
- }
- } else if (chargingInfo[gunIndex]->Type == _Type_GB) {
- if (!isEvGunLocked_ccs(gunIndex)) {
- log_info("*********** _DetectEvChargingEnableTimeout (gb) ***********\n");
- }
- } else if (chargingInfo[gunIndex]->Type == _Type_CCS_2) {
- if (!isEvGunLocked_ccs(gunIndex)) {
- log_info("*********** _DetectEvChargingEnableTimeout (ccs) ***********\n");
- }
- }
- ChargingTerminalProcess(gunIndex);
- _AutoReturnTimeout();
- }
- void _PrepareTimeout(uint8_t gunIndex)
- {
- log_info("*********** _PrepareTimeout ***********\n");
- setChargerMode(gunIndex, MODE_IDLE);
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuNoResource = YES;
- _AutoReturnTimeout();
- }
- void ClearAuthorizedFlag()
- {
- ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
- ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = NO;
- }
- void DisplayChargingInfo()
- {
- log_info("*********** DisplayChargingInfo *********** \n");
- for (uint8_t i = 0; i < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; i++) {
- if (chargingInfo[i]->SystemStatus != S_IDLE &&
- chargingInfo[i]->SystemStatus != S_RESERVATION) {
- ChangeGunSelectByIndex(i);
- return;
- }
- }
- if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount > 0 &&
- ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE &&
- ac_chargingInfo[0]->SystemStatus >= S_PREPARNING && ac_chargingInfo[0]->SystemStatus <= S_COMPLETE) {
- ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
- }
- usleep(50000);
- #if defined DD360Audi
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
- #else
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
- #endif //defined DD360Audi
- }
- void _DetectPlugInTimeout()
- {
- log_info("*********** _DetectPlugInTimeout *********** \n");
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
- ClearDetectPluginFlag();
- //usleep(50000);
- sleep(1); //Jerry add
- #if defined DD360Audi
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
- #else
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
- #endif //defined DD360Audi
- }
- void _AutoReturnTimeout()
- {
- log_info("*********** _AutoReturnTimeout %d*********** \n", ShmSysConfigAndInfo->SysInfo.PageIndex);
- if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG) {
- ClearDetectPluginFlag();
- } else if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_AUTHORIZ_COMP) {
- DetectPluginStart();
- }
- usleep(50000);
- #if defined DD360Audi
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
- #else
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
- #endif //defined DD360Audi
- }
- void StopSystemTimeoutDet()
- {
- gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
- ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
- }
- void _SelfTestTimeout()
- {
- if (ShmSysConfigAndInfo->SysInfo.BootingStatus != BOOT_COMPLETE) {
- for (uint8_t gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++) {
- setChargerMode(gun_index, MODE_ALARM);
- }
- }
- ShmPsuData->Work_Step = _NO_WORKING;
- ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_FAIL;
- log_info("Self test timeout. \n");
- }
- void CheckConnectionTimeout(void)
- {
- #if defined DD360 || defined DD360Audi || defined DD360ComBox
- if (gAudiCustInfo->RemoteSetup.ConnectionTimeout != 0) { //Jerry add
- _connectionTimeout = gAudiCustInfo->RemoteSetup.ConnectionTimeout;
- } else {
- _connectionTimeout = CONN_PLUG_TIME_OUT;
- }
- return;
- #endif //defined DD360 || defined DD360Audi || defined DD360ComBox
- if (system("pidof -s OcppBackend > /dev/null") != 0) {
- _connectionTimeout = CONN_PLUG_TIME_OUT;
- } else {
- if (strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "") != 0) {
- _connectionTimeout = atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
- if (_connectionTimeout <= 0) {
- _connectionTimeout = CONN_PLUG_TIME_OUT;
- }
- } else {
- _connectionTimeout = CONN_PLUG_TIME_OUT;
- }
- }
- }
- void CreateTimeoutFork(void)
- {
- pid_t timeoutPid;
- timeoutPid = fork();
- log_info("CreateTimeoutFork = %d\r\n", timeoutPid);
- if (timeoutPid == 0) {
- gettimeofday(&_cmdSubPriority_time, NULL);
- CheckConnectionTimeout();
- while (1) {
- if ((GetTimeoutValue(_cmdSubPriority_time) / 1000) > 5000) {
- CheckConnectionTimeout();
- gettimeofday(&_cmdSubPriority_time, NULL);
- }
- //printf("Timeout ***********SystemTimeoutFlag = %d, ********\n", ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag);
- // 系統
- switch (ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag) {
- case Timeout_SelftestChk:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= SELFTEST_TIMEOUT) {
- _SelfTestTimeout();
- StopSystemTimeoutDet();
- destroySelGun(DESTROY_ALL_SEL); //jerry add
- }
- break;
- case Timeout_Authorizing:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_TIMEOUT) {
- _AuthorizedTimeout();
- StopSystemTimeoutDet();
- destroySelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
- if (gAudiCustInfo->AuthorStateFromCabinet[ShmSysConfigAndInfo->SysInfo.CurGunSelected] == YES) { //DoComm no ask cabinet balance
- gAudiCustInfo->AuthorStateFromCabinet[ShmSysConfigAndInfo->SysInfo.CurGunSelected] = NO;
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo = ABNORMAL;
- log_error("Author timeout restart DoComm\r\n");
- system("killall Module_DoComm");
- sleep(1);
- system("/root/Module_DoComm &");
- }
- }
- break;
- case Timeout_VerifyFail:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT) {
- _AutoReturnTimeout();
- StopSystemTimeoutDet();
- destroySelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
- if (gAudiCustInfo->AuthorStateFromCabinet[ShmSysConfigAndInfo->SysInfo.CurGunSelected] == YES) { //DoComm no ask cabinet balance
- gAudiCustInfo->AuthorStateFromCabinet[ShmSysConfigAndInfo->SysInfo.CurGunSelected] = NO;
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo = ABNORMAL;
- log_error("Author timeout restart DoComm\r\n");
- system("killall Module_DoComm");
- sleep(1);
- system("/root/Module_DoComm &");
- }
- }
- break;
- case Timeout_VerifyComp:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_COMP_TIMEOUT) {
- _AutoReturnTimeout();
- StopSystemTimeoutDet();
- }
- break;
- case Timeout_WaitPlug:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= _connectionTimeout) {
- _DetectPlugInTimeout();
- StopSystemTimeoutDet();
- destroySelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
- }
- break;
- case Timeout_ReturnToChargingGunDet:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= RETURN_TO_CHARGING_PAGE) {
- #if defined DD360Audi
- if (getCurLcmPage() != _LCM_PRE_CHARGE &&
- getCurLcmPage() != _LCM_CHARGING &&
- getCurLcmPage() != _LCM_COMPLETE) {
- destroySelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected); //jerry add
- }
- #endif //defined DD360Audi
- DisplayChargingInfo();
- StopSystemTimeoutDet();
- }
- break;
- case Timeout_AuthorizingForStop:
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_STOP_TIMEOUT) {
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
- ClearAuthorizedFlag();
- StopSystemTimeoutDet();
- }
- break;
- } //switch
- // 各槍
- for (uint8_t gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++) {
- //printf("Timeout ***********TimeoutFlag = %d, ********\n", chargingInfo[gun_index]->TimeoutFlag);
- switch (chargingInfo[gun_index]->TimeoutFlag) {
- case Timeout_Preparing:
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_PREPARE_TIMEOUT) {
- _PrepareTimeout(gun_index);
- StopGunInfoTimeoutDet(gun_index);
- destroySelGun(gun_index); //jerry add
- }
- break;
- case Timeout_EvChargingDet:
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT) {
- _DetectEvChargingEnableTimeout(gun_index);
- StopGunInfoTimeoutDet(gun_index);
- destroySelGun(gun_index); //jerry add
- }
- break;
- case Timeout_EvseChargingDet:
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT) {
- _DetectEvseChargingEnableTimeout(gun_index);
- StopGunInfoTimeoutDet(gun_index);
- destroySelGun(gun_index); //jerry add
- }
- break;
- case Timeout_EvseCompleteDet:
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT) {
- StopGunInfoTimeoutDet(gun_index);
- destroySelGun(gun_index); //jerry add
- }
- break;
- case Timeout_ForCcsPrechargeDet:
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT) {
- _CcsPrechargeTimeout(gun_index);
- StopGunInfoTimeoutDet(gun_index);
- destroySelGun(gun_index); //jerry add
- }
- break;
- case Timeout_SelectGun: //Jerry add
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
- StopGunInfoTimeoutDet(gun_index);
- destroySelGun(gun_index); //jerry add
- }
- break;
- } //switch
- } //for
- sleep(1);
- }//while
- }
- }
|