소스 검색

2020-06-10 /Edward Lien

Actions:
1.Add HLC charging routine.
2.Add timeout in check EVChargeProgress = HLC_START_MODE.
3.Add timeout in no CCS socket received.

Files:
1. As follow commit history

Image version: D0.12.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
Edward Lien 4 년 전
부모
커밋
180b427080

+ 124 - 63
EVSE/Projects/AW-CCS/Apps/main.c

@@ -21,19 +21,21 @@
 #define TMR_IDX_AUTH					1
 #define TMR_IDX_LOGPPRINTOUT			2
 #define TMR_IDX_PROFILE_PREPARE			3
-#define TMR_IDX_CCS_HANDSHAKE			4
-#define TMR_IDX_5						5
+#define TMR_IDX_BS_HLC_HANDSHAKE		4
+#define TMR_IDX_CCS_SOCKET_COUNT_RESET	5
 #define TMR_IDX_6						6
 #define TMR_IDX_7						7
 #define TMR_IDX_8						8
 #define TMR_IDX_9 						9
 
-#define TIMEOUT_SPEC_HANDSHAKING		180000
-#define TIMEOUT_SPEC_AUTH				15000
-#define TIMEOUT_SPEC_HANDSHAKING_LED	185000
-#define TIMEOUT_SPEC_LOGPPRINTOUT		30000
-#define TIMEOUT_SPEC_PROFILE_PREPARE	5000
-#define TIMEOUT_SPEC_CCS_HANDSHAKE		2000
+#define TIMEOUT_SPEC_HANDSHAKING				180000
+#define TIMEOUT_SPEC_AUTH						15000
+#define TIMEOUT_SPEC_HANDSHAKING_LED			185000
+#define TIMEOUT_SPEC_LOGPPRINTOUT				30000
+#define TIMEOUT_SPEC_PROFILE_PREPARE			5000
+#define TIMEOUT_SPEC_BS_HLC_HANDSHAKE			2000
+#define TIMEOUT_SPEC_CCS_SOCKET_COUNT_RESET		10000
+#define TIMEOUT_SPEC_CCS_HANDSHAKE				120000
 
 #define MtdBlockSize 					0x600000
 
@@ -1202,7 +1204,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.11.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.12.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -2307,7 +2309,10 @@ int main(void)
 						ShmCharger->gun_info[gun_index].isInitialPass = YES;
 
 						// Set max current to rating current
-						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
+						//ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
+						ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
+						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;							
 
 						// If rotate switch equal zero, the system needs to change Debug mode
 						if(ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch == 0)
@@ -2346,6 +2351,9 @@ int main(void)
 						
 						ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;
 						ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_BS;
+						
+						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;							
 					}
 
 					if(((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)) ||
@@ -2557,7 +2565,7 @@ int main(void)
 								if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF)
 								{						
 									//2 secs timeout
-									ftime(&startTime[gun_index][TMR_IDX_CCS_HANDSHAKE]);
+									ftime(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CCS;
 									//Let CCS task start to negotiate
 									ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = ON;	
@@ -2565,22 +2573,27 @@ int main(void)
 								break;
 							case HANDSHAKE_CCS:
 								//CCS handshake timeout
-								if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_CCS_HANDSHAKE]) > TIMEOUT_SPEC_CCS_HANDSHAKE)
+								if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
 								{
 									
 									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STAT_E;
 									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;						
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CP_STATE_E;
 									ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_BS;
-									DEBUG_INFO("CCS 2 secs handshake timeout.\r\n");
+									DEBUG_INFO("BS/HLC 2 secs handshake timeout.\r\n");
 								}	
 								
+#ifdef	CCS_SIMULATION_DATA				
+								ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus = 1;						
+#endif	//CCS_SIMULATION_DATA								
+								
 								//CCS status check
 								if(ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus > 0)
 								{
 									ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_HLC;
 									DEBUG_INFO("Enter HLC Mode charging.\r\n");										
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_HLC_MODE;
+									ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 								}
 								
 								// Use RFID card to stop handshaking
@@ -2631,9 +2644,6 @@ int main(void)
 							case HANDSHAKE_SET_MAX_CURRENT:
 								if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF)
 								{			
-									//refresh 180 secs timeout
-									ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
-									DEBUG_INFO("Refresh handshake 180 secs timeout.\r\n");	
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_BS_MODE;
 									DEBUG_INFO("Enter BS Mode charging.\r\n");		
 
@@ -2668,23 +2678,10 @@ int main(void)
 								}						
 								break;		
 							case HANDSHAKE_HLC_MODE:	
-								if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
-								{
-									setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
-
-									if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5000))
-									{
-										DEBUG_INFO("Handshaking timeout...\r\n");
-										//Cancel CCS task negotiating
-										ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-										ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
-						
 #ifdef	CCS_SIMULATION_DATA				
-										ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty = CCS_PWM_DUTY_100;						
-#endif	//CCS_SIMULATION_DATA
-									}
-								}
-								else if(ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress == HLC_START_MODE)
+								ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress = HLC_START_MODE;						
+#endif	//CCS_SIMULATION_DATA	
+								if(ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress == HLC_START_MODE)
 								{
 									setRelay(gun_index,ON);
 									ShmCharger->gun_info[gun_index].isCCSStartTransation = ON;
@@ -2707,7 +2704,34 @@ int main(void)
 									ShmCharger->gun_info[gun_index].isCCSStartTransation = OFF;
 									
 									setChargerMode(gun_index, SYS_MODE_CHARGING);
-								}															
+									
+									ftime(&startTime[gun_index][TMR_IDX_CCS_SOCKET_COUNT_RESET]);
+								}	
+
+								//120 sec timeout
+								if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE)
+								{	
+									setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
+									
+									if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE+5000)
+									{
+										DEBUG_INFO("CCS 120 secs handshake timeout.\r\n");
+										//Cancel CCS task negotiating
+										ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
+										ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
+#ifdef	CCS_SIMULATION_DATA				
+										ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty = CCS_PWM_DUTY_100;						
+#endif	//CCS_SIMULATION_DATA		
+									}
+								}
+								if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty == CCS_PWM_DUTY_100)
+								{
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;	
+									ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = OFF;
+									
+									setChargerMode(gun_index, SYS_MODE_IDLE);
+								}								
 								break;
 							default:
 								break;
@@ -2985,6 +3009,26 @@ int main(void)
 							}						
 							break;
 						case CHARGING_MODE_HLC:
+							//if time up, clear CCS socket count
+							if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_CCS_SOCKET_COUNT_RESET]) > TIMEOUT_SPEC_CCS_SOCKET_COUNT_RESET)
+							{
+									ftime(&startTime[gun_index][TMR_IDX_CCS_SOCKET_COUNT_RESET]);
+									if(ShmCharger->gun_info[gun_index].acCcsInfo.CCSSocketCount > 0)
+									{
+										ShmCharger->gun_info[gun_index].acCcsInfo.CCSSocketCount = 0;
+									}
+									else
+									{
+										DEBUG_INFO("CCS could not get socket from car.\r\n");
+										
+										//setChargerMode(gun_index, SYS_MODE_TERMINATING);
+										//setRelay(gun_index, OFF);	
+#ifdef	CCS_SIMULATION_DATA				
+										//ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress = HLC_STOP_MODE;
+#endif	//CCS_SIMULATION_DATA	
+									}
+							}							
+							
 							if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
 							   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
 							   (ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq == ON)||
@@ -2995,14 +3039,8 @@ int main(void)
 							   (ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress == HLC_RENEGOTIATE_MODE) ||
 							   (ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress == HLC_STANDBY_MODE))
 							{
-								//Cancel CCS task negotiating
-								ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-								setRelay(gun_index,OFF);
-								ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
-						
-#ifdef	CCS_SIMULATION_DATA				
-								ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty = CCS_PWM_DUTY_100;						
-#endif	//CCS_SIMULATION_DATA	
+								setChargerMode(gun_index, SYS_MODE_TERMINATING);
+								setRelay(gun_index, OFF);
 							}
 							else
 							{
@@ -3137,8 +3175,9 @@ int main(void)
 									ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
 									if(ShmCharger->gun_info[gun_index].targetCurrent != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
 									{
-										ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
-										ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+										//ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+										//ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+										ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
 									}
 								}
 								else
@@ -3146,8 +3185,9 @@ int main(void)
 									ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
 									if(ShmCharger->gun_info[gun_index].targetCurrent != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
 									{
-										ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
-										ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+										//ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+										//ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+										ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
 									}
 								}
 
@@ -3168,16 +3208,18 @@ int main(void)
 									if((ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60)))
 									{
 										setChargerMode(gun_index, SYS_MODE_TERMINATING);
+										setRelay(gun_index, OFF);
 										DEBUG_INFO("Connector-%d charging duration(%d) already over max duration(%d) in second.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration, (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60));
 									}
 									else if((ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)))
 									{
 										setChargerMode(gun_index, SYS_MODE_TERMINATING);
+										setRelay(gun_index, OFF);
 										DEBUG_INFO("Connector-%d charging energy(%.2f) already over max energy(%.2f) in KWH.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy, ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy));
 									}
 									else
 									{
-										setRequest(gun_index, ON);
+										setRelay(gun_index, ON);
 									}
 								}
 								else
@@ -3190,33 +3232,27 @@ int main(void)
 										if(((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration*60)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60))))
 										{
 											setChargerMode(gun_index, SYS_MODE_TERMINATING);
+											setRelay(gun_index, OFF);
 											DEBUG_INFO("Connector-%d charging duration(%d) already over off-line max duration(%d) in second.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration, (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60));
 										}
 										else if(((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy))))
 										{
 											setChargerMode(gun_index, SYS_MODE_TERMINATING);
+											setRelay(gun_index, OFF);
 											DEBUG_INFO("Connector-%d charging energy(%.2f) already over off-line max energy(%.2f) in KWH.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy, ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy));
 										}
 										else
 										{
-											setRequest(gun_index, ON);
+											setRelay(gun_index, ON);
 										}
 									}
 									else
 									{
-										setRequest(gun_index, OFF);
+										setRelay(gun_index, OFF);
 										DEBUG_INFO("Connector-%d can not charging in off line\r\n", gun_index);
 									}
 								}
 							}
-							if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty == CCS_PWM_DUTY_100)
-							{
-								ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
-								ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;	
-								ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = OFF;
-								
-								setChargerMode(gun_index, SYS_MODE_TERMINATING);
-							}								
 							break;
 						default:
 							break;
@@ -3398,7 +3434,7 @@ int main(void)
 
 									if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
 									{
-										setChargerMode(gun_index, SYS_MODE_COMPLETE);
+										setChargerMode(gun_index, SYS_MODE_COMPLETE);									
 									}
 								}
 								else
@@ -3553,7 +3589,8 @@ int main(void)
 								   (ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq == ON) ||
 								   ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData, "TRUE") == 0)) ||
 								   (ShmOCPP16Data->MsMsg.bits.ResetReq) ||
-								   (ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor == ON))
+								   (ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor == ON) ||
+								   (ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress == HLC_STOP_MODE))
 								{
 									if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON)
 									{
@@ -3569,12 +3606,23 @@ int main(void)
 									else
 									{}
 
-									setRequest(gun_index, OFF);
+									setRelay(gun_index, OFF);
 									setLedMotion(gun_index, LED_ACTION_STOP);
-
+#ifdef	CCS_SIMULATION_DATA										
+									//for CCS testing
+									setRequest(gun_index, OFF);
+#endif	//CCS_SIMULATION_DATA
 									if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
 									{
-										setChargerMode(gun_index, SYS_MODE_COMPLETE);
+										//setChargerMode(gun_index, SYS_MODE_COMPLETE);
+										//Cancel CCS task negotiating
+										ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
+										setRelay(gun_index,OFF);
+										ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
+						
+#ifdef	CCS_SIMULATION_DATA				
+										ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty = CCS_PWM_DUTY_100;						
+#endif	//CCS_SIMULATION_DATA											
 									}
 								}
 								else
@@ -3587,11 +3635,22 @@ int main(void)
 									   !(ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60))) &&
 									   !(ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy))) &&
 									   !(!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE) && ((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration*60)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60)))) &&
-									   !(!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE) && ((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)))))
+									   !(!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE) && ((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)))) &&
+									   (ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress != HLC_STOP_MODE))
 									{
 										setChargerMode(gun_index, SYS_MODE_CHARGING);
 									}
-								}						
+								}
+								if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.SetCPPWMDuty == CCS_PWM_DUTY_100)
+								{
+									DEBUG_INFO("Set PWM duty 100% go to SYS_MODE_TERMINATING.\r\n");
+									
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;	
+									ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = OFF;
+									
+									setChargerMode(gun_index, SYS_MODE_COMPLETE);
+								}								
 								break;
 						default:
 								break;
@@ -3649,6 +3708,7 @@ int main(void)
 								setChargerMode(gun_index, SYS_MODE_IDLE);
 								break;
 						case CHARGING_MODE_HLC:
+								setRequest(gun_index, OFF);
 								if(ShmOCPP16Data->MsMsg.bits.ResetReq)
 								{
 									if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard")==0)
@@ -3694,6 +3754,7 @@ int main(void)
 						default:
 								break;
 					}
+					ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_BS;
 					break;
 				case SYS_MODE_ALARM:
 

+ 2 - 1
EVSE/Projects/AW-CCS/Apps/main.h

@@ -144,7 +144,7 @@
 //=================================
 //CCS related define
 //=================================
-#define CCS_SIMULATION_DATA
+//#define CCS_SIMULATION_DATA
 
 #define CCS_PWM_DUTY_CP_STAT_E			0			
 #define CCS_PWM_DUTY_5					5
@@ -598,6 +598,7 @@ typedef struct GUN_INFO
 	uint8_t											PreviousEVChargeProgress;	
 	uint8_t											chargingMode;
 	uint16_t										targetCurrent;
+	
 	uint16_t										isAuthPassEnd:1;
 	uint16_t										rfidReq:1;
 	uint16_t										isGunPlugged:1;

BIN
EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/AW-CCS/Images/ramdisk.gz


BIN
EVSE/Projects/AW-CCS/Images/ramdisk_merged.gz