|
@@ -2511,41 +2511,35 @@ void InitEthernet()
|
|
|
DEBUG_INFO("Initial Ethernet OK\n");
|
|
|
}
|
|
|
|
|
|
-int SpawnTask(uint8_t gun_index)
|
|
|
+int SpawnTask()
|
|
|
{
|
|
|
- if(gun_index == 0)
|
|
|
+ system ("pkill Module_");
|
|
|
+ system ("pkill OcppBackend");
|
|
|
+
|
|
|
+ /*
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
{
|
|
|
- system ("pkill Module_");
|
|
|
- system ("pkill OcppBackend");
|
|
|
+ system("/root/Module_4g &");
|
|
|
+ }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
- {
|
|
|
- system("/root/Module_4g &");
|
|
|
- }
|
|
|
- else if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W')
|
|
|
- {
|
|
|
- system("/root/Module_Wifi &");
|
|
|
- }
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W' || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ {
|
|
|
+ system("/root/Module_Wifi &");
|
|
|
+ }*/
|
|
|
|
|
|
- system("/root/Module_EventLogging &");
|
|
|
+ system("/root/Module_EventLogging &");
|
|
|
|
|
|
- if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0)
|
|
|
- {
|
|
|
- ocpp_process_start();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_INFO("OCPP URL is empty, need to create a configuration table !!!\n");
|
|
|
- ocpp_process_start();
|
|
|
- }
|
|
|
- system ("/root/Module_AlarmDetect &");
|
|
|
- system ("/root/Module_InternalComm &");
|
|
|
- system ("/root/Module_Speaker &");
|
|
|
- system ("/root/Module_ProduceUtils &");
|
|
|
- system ("/root/Module_LcmControl &");
|
|
|
- system ("/root/Module_Cabinet &");
|
|
|
- system ("/root/Module_Dispenser &");
|
|
|
- }
|
|
|
+ ocpp_process_start();
|
|
|
+ if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0)
|
|
|
+ DEBUG_INFO("OCPP URL is empty, need to create a configuration table !!!\n");
|
|
|
+
|
|
|
+ //system ("/root/Module_AlarmDetect &");
|
|
|
+ system ("/root/Module_InternalComm &");
|
|
|
+ //system ("/root/Module_Speaker &");
|
|
|
+ system ("/root/Module_ProduceUtils &");
|
|
|
+ //system ("/root/Module_LcmControl &");
|
|
|
+ system ("/root/Module_Cabinet &");
|
|
|
+ system ("/root/Module_Dispenser &");
|
|
|
|
|
|
return PASS;
|
|
|
}
|
|
@@ -2571,42 +2565,39 @@ int Initialization(uint8_t gun_index)
|
|
|
{
|
|
|
int result = PASS;
|
|
|
|
|
|
- if(gun_index == 0)
|
|
|
- {
|
|
|
- InitGPIO();
|
|
|
-
|
|
|
- InitEthernet();
|
|
|
+ InitGPIO();
|
|
|
|
|
|
- if(InitQca7000() != PASS)
|
|
|
- {
|
|
|
- DEBUG_ERROR("QCA7000 initial fail.\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
+ InitEthernet();
|
|
|
|
|
|
- if(DB_Open(localDb) != PASS)
|
|
|
- {
|
|
|
- DEBUG_ERROR("Local database initial fail.\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
+ if(InitQca7000() != PASS)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("QCA7000 initial fail.\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
|
|
|
- if((rfidFd = InitRfidPort()) == FAIL)
|
|
|
- {
|
|
|
- DEBUG_ERROR("RFID port initial fail.\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
+ if(DB_Open(localDb) != PASS)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("Local database initial fail.\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
|
|
|
- if((wtdFd = InitWatchDog()) == FAIL)
|
|
|
- {
|
|
|
- DEBUG_ERROR("Watchdog initial fail.\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
+ if((rfidFd = InitRfidPort()) == FAIL)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("RFID port initial fail.\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
|
|
|
- if(result == PASS)
|
|
|
- DEBUG_INFO("Initialization OK.\n");
|
|
|
- else
|
|
|
- DEBUG_INFO("Initialization Fail.\n");
|
|
|
+ if((wtdFd = InitWatchDog()) == FAIL)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("Watchdog initial fail.\n");
|
|
|
+ result = FAIL;
|
|
|
}
|
|
|
|
|
|
+ if(result == PASS)
|
|
|
+ DEBUG_INFO("Initialization OK.\n");
|
|
|
+ else
|
|
|
+ DEBUG_INFO("Initialization Fail.\n");
|
|
|
+
|
|
|
ShmCharger->gun_info[gun_index].isOperactive = DB_Get_Operactive(localDb, gun_index);
|
|
|
|
|
|
return result;
|
|
@@ -3930,72 +3921,107 @@ int isValidLocalWhiteCard()
|
|
|
//==========================================
|
|
|
void checkTask()
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ /*
|
|
|
+ * TODO:
|
|
|
+ * 1. Rotary switch define change with system specification
|
|
|
+ */
|
|
|
+ // Task run only on cabinet
|
|
|
+ if(ShmDispenser->gun_info.primaryMcuState.rotatory_switch != ROTARY_SWITCH_E_DISPENSER)
|
|
|
{
|
|
|
- if(system("pidof -s Module_4g > /dev/null") != 0)
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
{
|
|
|
- DEBUG_INFO("Module_4g not running, restart it.\n");
|
|
|
- system("/root/Module_4g &");
|
|
|
+ if(system("pidof -s Module_4g > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_4g not running, restart it.\n");
|
|
|
+ system("/root/Module_4g &");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
- {
|
|
|
- if(system("pidof -s Module_Wifi > /dev/null") != 0)
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
{
|
|
|
- DEBUG_INFO("Module_Wifi not running, restart it.\n");
|
|
|
- system("/root/Module_Wifi &");
|
|
|
+ if(system("pidof -s Module_Wifi > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_Wifi not running, restart it.\n");
|
|
|
+ system("/root/Module_Wifi &");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(system("pidof -s Module_EventLogging > /dev/null") != 0)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_EventLogging not running, restart it.\n");
|
|
|
- system("/root/Module_EventLogging &");
|
|
|
- }
|
|
|
-
|
|
|
- if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) && !ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) && !ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging)
|
|
|
{
|
|
|
- if((time((time_t*)NULL) - ShmOCPP16Data->procDogTime) > 180)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
- DEBUG_WARN("OcppBackend watch dog timeout task restart.\n");
|
|
|
- ShmOCPP16Data->procDogTime = time((time_t*)NULL);
|
|
|
- system("pkill OcppBackend");
|
|
|
- sleep(3);
|
|
|
- ocpp_process_start();
|
|
|
- }
|
|
|
+ if((time((time_t*)NULL) - ShmOCPP16Data->procDogTime) > 180)
|
|
|
+ {
|
|
|
+ DEBUG_WARN("OcppBackend watch dog timeout task restart.\n");
|
|
|
+ ShmOCPP16Data->procDogTime = time((time_t*)NULL);
|
|
|
+ system("pkill OcppBackend");
|
|
|
+ sleep(3);
|
|
|
+ ocpp_process_start();
|
|
|
+ }
|
|
|
|
|
|
- if(system("pidof -s OcppBackend > /dev/null") != 0)
|
|
|
+ if(system("pidof -s OcppBackend > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("OcppBackend not running, restart it.\n");
|
|
|
+ ocpp_process_start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
{
|
|
|
- DEBUG_INFO("OcppBackend not running, restart it.\n");
|
|
|
- ocpp_process_start();
|
|
|
+ if((time((time_t*)NULL) - ShmOCPP20Data->procDogTime) > 180)
|
|
|
+ {
|
|
|
+ DEBUG_WARN("OcppBackend20 watch dog timeout task restart.\n");
|
|
|
+ ShmOCPP20Data->procDogTime = time((time_t*)NULL);
|
|
|
+ system("pkill OcppBackend20");
|
|
|
+ sleep(3);
|
|
|
+ ocpp_process_start();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(system("pidof -s OcppBackend20 > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("OcppBackend20 not running, restart it.\n");
|
|
|
+ ocpp_process_start();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
+
|
|
|
+ if(system("pidof -s Module_Speaker > /dev/null") != 0)
|
|
|
{
|
|
|
- if((time((time_t*)NULL) - ShmOCPP20Data->procDogTime) > 180)
|
|
|
- {
|
|
|
- DEBUG_WARN("OcppBackend20 watch dog timeout task restart.\n");
|
|
|
- ShmOCPP20Data->procDogTime = time((time_t*)NULL);
|
|
|
- system("pkill OcppBackend20");
|
|
|
- sleep(3);
|
|
|
- ocpp_process_start();
|
|
|
- }
|
|
|
+ DEBUG_INFO("Module_Speaker not running, restart it.\n");
|
|
|
+ system("/root/Module_Speaker &");
|
|
|
+ }
|
|
|
|
|
|
- if(system("pidof -s OcppBackend20 > /dev/null") != 0)
|
|
|
- {
|
|
|
- DEBUG_INFO("OcppBackend20 not running, restart it.\n");
|
|
|
- ocpp_process_start();
|
|
|
- }
|
|
|
+ if(system("pidof -s Module_LcmControl > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_LcmControl not running, restart it.\n");
|
|
|
+ system ("/root/Module_LcmControl &");
|
|
|
+ }
|
|
|
+
|
|
|
+ if((system("pidof -s Module_PowerSharing > /dev/null") != 0) &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
|
|
|
+ system ("/root/Module_PowerSharing &");
|
|
|
+ }
|
|
|
+
|
|
|
+ if((system("pidof -s Module_InitUpgrade > /dev/null") != 0) &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.isReqFirstUpgrade)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_InitUpgrade not running, restart it.\n");
|
|
|
+ system ("/root/Module_InitUpgrade &");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(system("pidof -s Module_AlarmDetect > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_AlarmDetect not running, restart it.\n");
|
|
|
+ system("/root/Module_AlarmDetect &");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(system("pidof -s Module_AlarmDetect > /dev/null") != 0)
|
|
|
+ // Task run both on cabinet and dispenser
|
|
|
+ if(system("pidof -s Module_EventLogging > /dev/null") != 0)
|
|
|
{
|
|
|
- DEBUG_INFO("Module_AlarmDetect not running, restart it.\n");
|
|
|
- system("/root/Module_AlarmDetect &");
|
|
|
+ DEBUG_INFO("Module_EventLogging not running, restart it.\n");
|
|
|
+ system("/root/Module_EventLogging &");
|
|
|
}
|
|
|
|
|
|
if(system("pidof -s Module_InternalComm > /dev/null") != 0)
|
|
@@ -4004,38 +4030,12 @@ void checkTask()
|
|
|
system("/root/Module_InternalComm &");
|
|
|
}
|
|
|
|
|
|
- if(system("pidof -s Module_Speaker > /dev/null") != 0)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_Speaker not running, restart it.\n");
|
|
|
- system("/root/Module_Speaker &");
|
|
|
- }
|
|
|
-
|
|
|
if(system("pidof -s Module_ProduceUtils > /dev/null") != 0)
|
|
|
{
|
|
|
DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
|
|
|
system ("/root/Module_ProduceUtils &");
|
|
|
}
|
|
|
|
|
|
- if(system("pidof -s Module_LcmControl > /dev/null") != 0)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_LcmControl not running, restart it.\n");
|
|
|
- system ("/root/Module_LcmControl &");
|
|
|
- }
|
|
|
-
|
|
|
- if((system("pidof -s Module_PowerSharing > /dev/null") != 0) &&
|
|
|
- ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
|
|
|
- system ("/root/Module_PowerSharing &");
|
|
|
- }
|
|
|
-
|
|
|
- if((system("pidof -s Module_InitUpgrade > /dev/null") != 0) &&
|
|
|
- ShmSysConfigAndInfo->SysConfig.isReqFirstUpgrade)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_InitUpgrade not running, restart it.\n");
|
|
|
- system ("/root/Module_InitUpgrade &");
|
|
|
- }
|
|
|
-
|
|
|
if((system("pidof -s Module_Cabinet > /dev/null") != 0))
|
|
|
{
|
|
|
DEBUG_INFO("Module_Cabinet not running, restart it.\n");
|
|
@@ -4809,6 +4809,12 @@ int main(void)
|
|
|
DEBUG_INFO("CreatShareMemory OK\n");
|
|
|
}
|
|
|
|
|
|
+ if(SpawnTask() != PASS)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = ON;
|
|
|
+ DEBUG_ERROR("Task spawn fail.\n");
|
|
|
+ }
|
|
|
+
|
|
|
for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus = 0xff;
|
|
@@ -4852,10 +4858,14 @@ int main(void)
|
|
|
//==============================================
|
|
|
// Connector loop
|
|
|
//==============================================
|
|
|
- for(int gun_index = 0;gun_index<modelnameInfo.GetGunCount;gun_index++)
|
|
|
+ /*
|
|
|
+ * TODO:
|
|
|
+ * 1. Rotary switch define change with system specification
|
|
|
+ */
|
|
|
+ // Only process main logic on cabinet
|
|
|
+ if(ShmDispenser->gun_info.primaryMcuState.rotatory_switch != ROTARY_SWITCH_E_DISPENSER)
|
|
|
{
|
|
|
- // Only process main logic on cabinet
|
|
|
- if(gun_index == 0)
|
|
|
+ for(int gun_index = 0;gun_index<modelnameInfo.GetGunCount;gun_index++)
|
|
|
{
|
|
|
//==============================================
|
|
|
// Synchronize share memory from OCPP struct
|
|
@@ -4926,121 +4936,124 @@ int main(void)
|
|
|
//==========================================
|
|
|
// Power saving logic
|
|
|
//==========================================
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus > SYS_MODE_BOOTING)
|
|
|
{
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
|
|
|
- }
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
+ {
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
|
|
|
+ }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_ALARM) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_FAULT) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_MAINTAIN) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
- {
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if((gpio_get_value(GPIO_IN_WAKEUP) == OFF) ||
|
|
|
- (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus != ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus) ||
|
|
|
- (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_RESERVATION)) &&
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
|
|
|
- (getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]) < 10)))
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_ALARM) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_FAULT) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_MAINTAIN) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
{
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
-
|
|
|
- if(((gpio_get_value(GPIO_IN_WAKEUP) == OFF) || (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON)) &&
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) &&
|
|
|
- (getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_CHECK_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
- {
|
|
|
- ShmCharger->gun_info[gun_index].isCheckPowerConsumption = YES;
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
|
|
|
- }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- refreshStartTimer(&startTime[gun_index][TMR_IDX_CHECK_POWER_CONSUMPTION]);
|
|
|
- if((getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_LCM_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
+ if((gpio_get_value(GPIO_IN_WAKEUP) == OFF) ||
|
|
|
+ (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus != ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus) ||
|
|
|
+ (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_RESERVATION)) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
|
|
|
+ (getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]) < 10)))
|
|
|
{
|
|
|
- ShmCharger->gun_info[gun_index].isCheckPowerConsumption = NO;
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
+
|
|
|
+ if(((gpio_get_value(GPIO_IN_WAKEUP) == OFF) || (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON)) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) &&
|
|
|
+ (getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_CHECK_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isCheckPowerConsumption = YES;
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_CHECK_POWER_CONSUMPTION]);
|
|
|
+ if((getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_LCM_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isCheckPowerConsumption = NO;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_LCD]) > TIMEOUT_SPEC_POWERSAVING_LCD)
|
|
|
- {
|
|
|
- if(ShmCharger->isLcdOn == ON)
|
|
|
+ if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_LCD]) > TIMEOUT_SPEC_POWERSAVING_LCD)
|
|
|
{
|
|
|
- DEBUG_INFO("LCD into power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_LCD]));
|
|
|
- ShmCharger->isLcdOn = OFF;
|
|
|
+ if(ShmCharger->isLcdOn == ON)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("LCD into power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_LCD]));
|
|
|
+ ShmCharger->isLcdOn = OFF;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ShmCharger->isLcdOn == OFF)
|
|
|
+ else
|
|
|
{
|
|
|
- DEBUG_INFO("LCD exit power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_LCD]));
|
|
|
- ShmCharger->isLcdOn = ON;
|
|
|
+ if(ShmCharger->isLcdOn == OFF)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("LCD exit power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_LCD]));
|
|
|
+ ShmCharger->isLcdOn = ON;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]) > TIMEOUT_SPEC_POWERSAVING_RFID)
|
|
|
- {
|
|
|
- if(gpio_get_value(GPIO_OUT_RST_RFID) == ON)
|
|
|
+ if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]) > TIMEOUT_SPEC_POWERSAVING_RFID)
|
|
|
{
|
|
|
- DEBUG_INFO("RFID into power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
- gpio_set_value(GPIO_OUT_RST_RFID, OFF);
|
|
|
+ if(gpio_get_value(GPIO_OUT_RST_RFID) == ON)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("RFID into power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
+ gpio_set_value(GPIO_OUT_RST_RFID, OFF);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(gpio_get_value(GPIO_OUT_RST_RFID) == OFF)
|
|
|
+ else
|
|
|
{
|
|
|
- DEBUG_INFO("RFID exit power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
- gpio_set_value(GPIO_OUT_RST_RFID, ON);
|
|
|
+ if(gpio_get_value(GPIO_OUT_RST_RFID) == OFF)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("RFID exit power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
+ gpio_set_value(GPIO_OUT_RST_RFID, ON);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]) > TIMEOUT_SPEC_POWERSAVING_METER)
|
|
|
- {
|
|
|
- if(ShmCharger->gun_info[gun_index].isMeterOn)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]) > TIMEOUT_SPEC_POWERSAVING_METER)
|
|
|
{
|
|
|
- DEBUG_INFO("Meter into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
- ShmCharger->gun_info[gun_index].isMeterOn = OFF;
|
|
|
+ if(ShmCharger->gun_info[gun_index].isMeterOn)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Meter into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
+ ShmCharger->gun_info[gun_index].isMeterOn = OFF;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(!ShmCharger->gun_info[gun_index].isMeterOn)
|
|
|
+ else
|
|
|
{
|
|
|
- DEBUG_INFO("Meter exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
- ShmCharger->gun_info[gun_index].isMeterOn = ON;
|
|
|
+ if(!ShmCharger->gun_info[gun_index].isMeterOn)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Meter exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
+ ShmCharger->gun_info[gun_index].isMeterOn = ON;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]) > TIMEOUT_SPEC_POWERSAVING_LED_STATUS)
|
|
|
- {
|
|
|
- if(ShmCharger->gun_info[gun_index].isSleepOn == NO)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]) > TIMEOUT_SPEC_POWERSAVING_LED_STATUS)
|
|
|
{
|
|
|
- DEBUG_INFO("LED status into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
- ShmCharger->gun_info[gun_index].isSleepOn = YES;
|
|
|
+ if(ShmCharger->gun_info[gun_index].isSleepOn == NO)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("LED status into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
+ ShmCharger->gun_info[gun_index].isSleepOn = YES;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ShmCharger->gun_info[gun_index].isSleepOn == YES)
|
|
|
+ else
|
|
|
{
|
|
|
- DEBUG_INFO("LED status exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
- ShmCharger->gun_info[gun_index].isSleepOn = NO;
|
|
|
+ if(ShmCharger->gun_info[gun_index].isSleepOn == YES)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("LED status exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
+ ShmCharger->gun_info[gun_index].isSleepOn = NO;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5137,8 +5150,7 @@ int main(void)
|
|
|
setLedMotion(gun_index,LED_ACTION_INIT);
|
|
|
|
|
|
//CSU Initialization & task spawn
|
|
|
- if((Initialization(gun_index) != PASS) ||
|
|
|
- (SpawnTask(gun_index) != PASS))
|
|
|
+ if(Initialization(gun_index) != PASS)
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = ON;
|
|
|
}
|
|
@@ -5432,6 +5444,7 @@ int main(void)
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
setLedMotion(gun_index, LED_ACTION_AUTHED);
|
|
|
ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
|
|
|
+ if(ShmCharger->isCcsEnable)refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
|
|
|
}
|
|
|
|
|
|
// If control pilot detect Bx, skip watch dog time out.
|
|
@@ -5449,7 +5462,6 @@ int main(void)
|
|
|
switch(ShmCharger->gun_info[gun_index].ccsHandshakeState)
|
|
|
{
|
|
|
case HANDSHAKE_DUTY_5:
|
|
|
- break;
|
|
|
case HANDSHAKE_DUTY_5_CHECK:
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
|
|
|
DEBUG_INFO("HLC slac handshake start.\n");
|
|
@@ -6262,7 +6274,6 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// System watch dog reset
|
|
|
write(wtdFd, "a", 1);
|
|
|
|