瀏覽代碼

[Improve][AX80][main]

2022.05.11 / Folus Wen

Actions:
1. Get EVCCID implement timeout logic.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 2 年之前
父節點
當前提交
d01fb3dd3a
共有 3 個文件被更改,包括 397 次插入277 次删除
  1. 370 268
      EVSE/Projects/AX80/Apps/Module_AlarmDetect.c
  2. 22 6
      EVSE/Projects/AX80/Apps/main.c
  3. 5 3
      EVSE/Projects/AX80/Apps/main.h

+ 370 - 268
EVSE/Projects/AX80/Apps/Module_AlarmDetect.c

@@ -58,12 +58,19 @@ struct{
 	unsigned short int	GMI;
 	unsigned short int	Short[3];
 	unsigned short int	Leakage;
-	unsigned short int	HandShakingTimeout;
 	unsigned short int	EmrgencyBTN;
 	unsigned short int	Relay_Welding;
 	unsigned short int	Relay_DrivingFault;
 	unsigned short int	CP_LevelFail;
 	unsigned short int	MCU_SelfTestFail;
+	unsigned short int  GetEvCCIDTimeout;
+	unsigned short int	Rotary_Switch;
+	unsigned short int  leak_module_fail;
+	unsigned short int  locker_fault;
+	unsigned short int  power_drop;
+	unsigned short int  meter_comm_timeout;
+	unsigned short int  meter_ic_comm_timeout;
+	unsigned short int  pilot_negative_error;
 }Alarm_Counter[3];
 
 void trim(char *s);
@@ -344,13 +351,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].OV[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
+				if(Alarm_Counter[gun_index].OV[0] > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_VOLTAGE;
-					DEBUG_INFO("ALARM_L1_OVER_VOLTAGE : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_VOLTAGE;
+						DEBUG_INFO("ALARM_L1_OVER_VOLTAGE : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].OV[0] = 0;
 			}
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -373,13 +383,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].OV[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
+					if(Alarm_Counter[gun_index].OV[1] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_VOLTAGE;
-						DEBUG_INFO("ALARM_L2_OVER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_VOLTAGE;
+							DEBUG_INFO("ALARM_L2_OVER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OV[1] = 0;
 				}
 
 				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3 == ON)
@@ -400,13 +413,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].OV[2] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
+					if(Alarm_Counter[gun_index].OV[2] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_VOLTAGE;
-						DEBUG_INFO("ALARM_L3_OVER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_VOLTAGE;
+							DEBUG_INFO("ALARM_L3_OVER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OV[2] = 0;
 				}
 			}
 
@@ -431,13 +447,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].UV[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
+				if(Alarm_Counter[gun_index].UV[0] > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_UNDER_VOLTAGE;
-					DEBUG_INFO("ALARM_L1_UNDER_VOLTAGE : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_UNDER_VOLTAGE;
+						DEBUG_INFO("ALARM_L1_UNDER_VOLTAGE : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].UV[0] = 0;
 			}
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -460,13 +479,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].UV[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
+					if(Alarm_Counter[gun_index].UV[1] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_UNDER_VOLTAGE;
-						DEBUG_INFO("ALARM_L2_UNDER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_UNDER_VOLTAGE;
+							DEBUG_INFO("ALARM_L2_UNDER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].UV[1] = 0;
 				}
 
 				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3 == ON)
@@ -487,15 +509,17 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].UV[2] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
+					if(Alarm_Counter[gun_index].UV[2] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_UNDER_VOLTAGE;
-						DEBUG_INFO("ALARM_L3_UNDER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_UNDER_VOLTAGE;
+							DEBUG_INFO("ALARM_L3_UNDER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].UV[2] = 0;
 				}
-							
 			}
 
 			//=====================================
@@ -523,13 +547,16 @@ int main(void)
 					((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) ? (getDiffSecNow(startTime[ALARM_TMR_IDX_OCP_L1]) >= 60) : TRUE) &&
 			        (ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0] <= (ShmCharger->gun_info[gun_index].targetCurrent<=20?(ShmCharger->gun_info[gun_index].targetCurrent):((int)((ShmCharger->gun_info[gun_index].targetCurrent*((ShmSysConfigAndInfo->SysConfig.ModelName[3]=='E') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='T') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='Z')?1.25:1.1))-2)))))
 			{
-				Alarm_Counter[gun_index].OC[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
+				if(Alarm_Counter[gun_index].OC[0] > 500)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_CURRENT;
-					DEBUG_INFO("ALARM_L1_OVER_CURRENT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_CURRENT;
+						DEBUG_INFO("ALARM_L1_OVER_CURRENT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].OC[0] = 0;
 			}
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -556,13 +583,16 @@ int main(void)
 						((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) ? (getDiffSecNow(startTime[ALARM_TMR_IDX_OCP_L2]) >= 60) : TRUE) &&
 						(ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0] <= (ShmCharger->gun_info[gun_index].targetCurrent<=20?(ShmCharger->gun_info[gun_index].targetCurrent):((int)((ShmCharger->gun_info[gun_index].targetCurrent*((ShmSysConfigAndInfo->SysConfig.ModelName[3]=='E') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='T') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='Z')?1.25:1.1))-2)))))
 				{
-					Alarm_Counter[gun_index].OC[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
+					if(Alarm_Counter[gun_index].OC[1] > 500)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_CURRENT;
-						DEBUG_INFO("ALARM_L2_OVER_CURRENT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_CURRENT;
+							DEBUG_INFO("ALARM_L2_OVER_CURRENT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OC[1] = 0;
 				}
 
 				if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3 == ON) ||
@@ -587,12 +617,16 @@ int main(void)
 						((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) ? (getDiffSecNow(startTime[ALARM_TMR_IDX_OCP_L3]) >= 60) : TRUE) &&
 						(ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0] <= (ShmCharger->gun_info[gun_index].targetCurrent<=20?(ShmCharger->gun_info[gun_index].targetCurrent):((int)((ShmCharger->gun_info[gun_index].targetCurrent*((ShmSysConfigAndInfo->SysConfig.ModelName[3]=='E') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='T') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='Z')?1.25:1.1))-2)))))
 				{
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
+					if(Alarm_Counter[gun_index].OC[2] > 500)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_CURRENT;
-						DEBUG_INFO("ALARM_L3_OVER_CURRENT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_CURRENT;
+							DEBUG_INFO("ALARM_L3_OVER_CURRENT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OC[2] = 0;
 				}
 			}
 
@@ -617,13 +651,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].OT_AMB = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == ON)
+				if(Alarm_Counter[gun_index].OT_AMB > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_OVER_TEMPERATURE;
-					DEBUG_INFO("ALARM_OVER_TEMPERATURE : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_OVER_TEMPERATURE;
+						DEBUG_INFO("ALARM_OVER_TEMPERATURE : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].OT_AMB = 0;
 			}
 
 			//=====================================
@@ -647,13 +684,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].GMI = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == ON)
+				if(Alarm_Counter[gun_index].GMI > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GROUND_FAIL;
-					DEBUG_INFO("ALARM_GROUND_FAIL : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GROUND_FAIL;
+						DEBUG_INFO("ALARM_GROUND_FAIL : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].GMI = 0;
 			}
 
 			//=====================================
@@ -677,13 +717,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].CP_LevelFail= 0;
-				if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == ON)
+				if(Alarm_Counter[gun_index].CP_LevelFail > FILTER_SPEC)
 				{
-					ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_ERROR;
-					DEBUG_INFO("ALARM_CP_ERROR : recover \n");
+					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == ON)
+					{
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_ERROR;
+						DEBUG_INFO("ALARM_CP_ERROR : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].CP_LevelFail= 0;
 			}
 
 			//=====================================
@@ -718,23 +761,26 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Leakage = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == ON)
+				if(Alarm_Counter[gun_index].Leakage > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = OFF;
-					if(ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage == ON)
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == ON)
 					{
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_AC;
-						ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = OFF;
-						DEBUG_INFO("ALARM_CURRENT_LEAK_AC : recover \n");
-					}
-					else if(ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage == ON)
-					{
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_DC;
-						ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = OFF;
-						DEBUG_INFO("ALARM_CURRENT_LEAK_DC : recover \n");
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = OFF;
+						if(ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage == ON)
+						{
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_AC;
+							ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = OFF;
+							DEBUG_INFO("ALARM_CURRENT_LEAK_AC : recover \n");
+						}
+						else if(ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage == ON)
+						{
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_DC;
+							ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = OFF;
+							DEBUG_INFO("ALARM_CURRENT_LEAK_DC : recover \n");
+						}
 					}
 				}
+				Alarm_Counter[gun_index].Leakage = 0;
 			}
 
 			//=====================================
@@ -758,36 +804,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].MCU_SelfTestFail = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == ON)
-				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_MCU_TESTFAIL;
-					DEBUG_INFO("ALARM_MCU_TESTFAIL : recover \n");
-				}
-			}
-
-			//=====================================
-			// Hand shaking timeout detection
-			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout == ON)
-			{
-				if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == OFF)
-				{
-					ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut  = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_HANDSHAKE_TIMEOUT;
-					DEBUG_INFO("ALARM_HANDSHAKE_TIMEOUT : alarm \n");
-				}
-
-			}
-			else
-			{
-				if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == ON)
+				if(Alarm_Counter[gun_index].MCU_SelfTestFail > FILTER_SPEC)
 				{
-					ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut  = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_HANDSHAKE_TIMEOUT;
-					DEBUG_INFO("ALARM_HANDSHAKE_TIMEOUT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_MCU_TESTFAIL;
+						DEBUG_INFO("ALARM_MCU_TESTFAIL : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].MCU_SelfTestFail = 0;
 			}
 
 			//=====================================
@@ -811,13 +837,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].EmrgencyBTN = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == ON)
+				if(Alarm_Counter[gun_index].EmrgencyBTN > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_EMERGENCY_STOP;
-					DEBUG_INFO("ALARM_EMERGENCY_STOP : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_EMERGENCY_STOP;
+						DEBUG_INFO("ALARM_EMERGENCY_STOP : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].EmrgencyBTN = 0;
 			}
 
 			//=====================================
@@ -841,13 +870,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Relay_Welding = 0;
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == ON)
+				if(Alarm_Counter[gun_index].Relay_Welding > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_WELDING;
-					DEBUG_INFO("ALARM_RELAY_STATUS : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_WELDING;
+						DEBUG_INFO("ALARM_RELAY_STATUS : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Relay_Welding = 0;
 			}
 
 			//=====================================
@@ -871,13 +903,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Relay_DrivingFault = 0;
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == ON)
+				if(Alarm_Counter[gun_index].Relay_DrivingFault > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_DRIVE_FAULT;
-					DEBUG_INFO("ALARM_RELAY_DRIVE_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_DRIVE_FAULT;
+						DEBUG_INFO("ALARM_RELAY_DRIVE_FAULT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Relay_DrivingFault = 0;
 			}
 
 			//=====================================
@@ -901,13 +936,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Short[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
+				if(Alarm_Counter[gun_index].Short[0] > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_CIRCUIT_SHORT;
-					DEBUG_INFO("ALARM_L1_CIRCUIT_SHORT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_CIRCUIT_SHORT;
+						DEBUG_INFO("ALARM_L1_CIRCUIT_SHORT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Short[0] = 0;
 			}
 			
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -930,13 +968,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].Short[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
+					if(Alarm_Counter[gun_index].Short[1] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_CIRCUIT_SHORT;
-						DEBUG_INFO("ALARM_L2_CIRCUIT_SHORT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_CIRCUIT_SHORT;
+							DEBUG_INFO("ALARM_L2_CIRCUIT_SHORT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].Short[1] = 0;
 				}
 
 				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3 == ON)
@@ -957,13 +998,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].Short[2] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
+					if(Alarm_Counter[gun_index].Short[2] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_CIRCUIT_SHORT;
-						DEBUG_INFO("ALARM_L3_CIRCUIT_SHORT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_CIRCUIT_SHORT;
+							DEBUG_INFO("ALARM_L3_CIRCUIT_SHORT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].Short[2] = 0;
 				}
 			}
 
@@ -972,21 +1016,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault == ON)
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == OFF)
+				if(Alarm_Counter[gun_index].Rotary_Switch > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_ROTATORY_SWITCH_FAULT;
-					DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : alarm \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == OFF)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_ROTATORY_SWITCH_FAULT;
+						DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].Rotary_Switch += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == ON)
+				if(Alarm_Counter[gun_index].Rotary_Switch > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_ROTATORY_SWITCH_FAULT;
-					DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_ROTATORY_SWITCH_FAULT;
+						DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Rotary_Switch = 0;
 			}
 
 			//=====================================
@@ -994,43 +1049,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail == ON)
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == OFF)
+				if(Alarm_Counter[gun_index].leak_module_fail > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LEAK_MODULE_FAIL;
-					DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : alarm \n");
-				}
-			}
-			else
-			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == ON)
-				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LEAK_MODULE_FAIL;
-					DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == OFF)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LEAK_MODULE_FAIL;
+						DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : alarm \n");
+					}
 				}
-			}
-
-			//=====================================
-			// Shutter detection
-			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault == ON)
-			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == OFF)
+				else
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_SHUTTER_FAULT;
-					DEBUG_INFO("ALARM_SHUTTER_FAULT : alarm \n");
+					Alarm_Counter[gun_index].leak_module_fail += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == ON)
+				if(Alarm_Counter[gun_index].leak_module_fail > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_SHUTTER_FAULT;
-					DEBUG_INFO("ALARM_SHUTTER_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LEAK_MODULE_FAIL;
+						DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].leak_module_fail = 0;
 			}
 
 			//=====================================
@@ -1038,21 +1082,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault == ON)
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == OFF)
+				if(Alarm_Counter[gun_index].locker_fault > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == OFF)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LOCKER_FAULT;
+						DEBUG_INFO("ALARM_LOCKER_FAULT : alarm \n");
+					}
+				}
+				else
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LOCKER_FAULT;
-					DEBUG_INFO("ALARM_LOCKER_FAULT : alarm \n");
+					Alarm_Counter[gun_index].locker_fault += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == ON)
+				if(Alarm_Counter[gun_index].locker_fault > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LOCKER_FAULT;
-					DEBUG_INFO("ALARM_LOCKER_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LOCKER_FAULT;
+						DEBUG_INFO("ALARM_LOCKER_FAULT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].locker_fault = 0;
 			}
 
 			//=====================================
@@ -1060,21 +1115,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == OFF)
+				if(Alarm_Counter[gun_index].power_drop > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_POWER_DROP;
+						DEBUG_INFO("ALARM_POWER_DROP : alarm \n");
+					}
+				}
+				else
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_POWER_DROP;
-					DEBUG_INFO("ALARM_POWER_DROP : alarm \n");
+					Alarm_Counter[gun_index].power_drop += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
+				if(Alarm_Counter[gun_index].power_drop > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_POWER_DROP;
-					DEBUG_INFO("ALARM_POWER_DROP : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_POWER_DROP;
+						DEBUG_INFO("ALARM_POWER_DROP : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].power_drop = 0;
 			}
 
 			//=====================================
@@ -1082,21 +1148,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == OFF)
+				if(Alarm_Counter[gun_index].meter_comm_timeout > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_TIMEOUT : alarm \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_TIMEOUT : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].meter_comm_timeout += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == ON)
+				if(Alarm_Counter[gun_index].meter_comm_timeout > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_TIMEOUT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_TIMEOUT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].meter_comm_timeout = 0;
 			}
 
 			//=====================================
@@ -1104,21 +1181,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == OFF)
+				if(Alarm_Counter[gun_index].meter_ic_comm_timeout > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_IC_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_IC_TIMEOUT : alarm \n");
+					}
+				}
+				else
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_IC_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_IC_TIMEOUT : alarm \n");
+					Alarm_Counter[gun_index].meter_ic_comm_timeout += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == ON)
+				if(Alarm_Counter[gun_index].meter_ic_comm_timeout > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_IC_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_IC_TIMEOUT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_IC_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_IC_TIMEOUT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].meter_ic_comm_timeout = 0;
 			}
 
 			//=====================================
@@ -1126,21 +1214,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.pilot_negative_error == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == OFF)
+				if(Alarm_Counter[gun_index].pilot_negative_error > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CP_NEG_ERROR;
-					DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : alarm \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CP_NEG_ERROR;
+						DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].pilot_negative_error += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == ON)
+				if(Alarm_Counter[gun_index].pilot_negative_error > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_NEG_ERROR;
-					DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_NEG_ERROR;
+						DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].pilot_negative_error = 0;
 			}
 
 			//=====================================
@@ -1172,6 +1271,39 @@ int main(void)
 				isCheckQca7000[gun_index] = TRUE;
 			}
 
+			//=====================================
+			// EVCCID get timeout
+			//=====================================
+			if(ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout == ON)
+			{
+				if(Alarm_Counter[gun_index].GetEvCCIDTimeout > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail== OFF)
+					{
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_GET_EVCCID_TIMEOUT;
+						DEBUG_INFO("ALARM_GET_EVCCID_TIMEOUT : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].GetEvCCIDTimeout++;
+				}
+			}
+			else
+			{
+				if(Alarm_Counter[gun_index].GetEvCCIDTimeout > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == ON)
+					{
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GET_EVCCID_TIMEOUT;
+						DEBUG_INFO("ALARM_GET_EVCCID_TIMEOUT : recover \n");
+					}
+				}
+				Alarm_Counter[gun_index].GetEvCCIDTimeout = 0;
+			}
+
 			//=====================================
 			// OCPP error code message
 			//=====================================
@@ -1250,12 +1382,6 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012257");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "McuTestFail");
 				}
-				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
-				{
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "HandshakeTimeout");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "HandshakeTimeout");
-				}
 				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
@@ -1274,12 +1400,6 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011004");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "LeakageModuleFail");
 				}
-				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
-				{
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011034");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "ShutterFault");
-				}
 				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "ConnectorLockFailure");
@@ -1347,6 +1467,12 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012284");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "QCA Self test Failed");
 				}
+				else if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "023701");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "CCS EV communication Fail");
+				}
 				else
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "NoError");
@@ -1719,30 +1845,6 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_MCU_TESTFAIL;
 				}
 
-				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_HANDSHAKE_TIMEOUT))
-				{
-					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)?"true":"false"));
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)?OFF:ON);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "HandshakeTimeout");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "HandshakeTimeout");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Operation");
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
-
-					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
-
-					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
-						previousAlarmCode[gun_index] |= ALARM_HANDSHAKE_TIMEOUT;
-					else
-						previousAlarmCode[gun_index] &= ~ALARM_HANDSHAKE_TIMEOUT;
-				}
-
 				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP) != (previousAlarmCode[gun_index] & ALARM_EMERGENCY_STOP))
 				{
 					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
@@ -1815,30 +1917,6 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_LEAK_MODULE_FAIL;
 				}
 
-				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT) != (previousAlarmCode[gun_index] & ALARM_SHUTTER_FAULT))
-				{
-					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)?"true":"false"));
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)?OFF:ON);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011034");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Shutter fault");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Shutter");
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
-
-					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
-
-					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
-						previousAlarmCode[gun_index] |= ALARM_SHUTTER_FAULT;
-					else
-						previousAlarmCode[gun_index] &= ~ALARM_SHUTTER_FAULT;
-				}
-
 				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT) != (previousAlarmCode[gun_index] & ALARM_LOCKER_FAULT))
 				{
 					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
@@ -2117,6 +2195,30 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_QCA_FLASH_FAIL;
 				}
 
+				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_GET_EVCCID_TIMEOUT))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT)?"true":"false"));
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT)?OFF:ON);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "023701");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "CCS EV communication Fail");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "PCBA");
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
+
+					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
+
+					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT)
+						previousAlarmCode[gun_index] |= ALARM_GET_EVCCID_TIMEOUT;
+					else
+						previousAlarmCode[gun_index] &= ~ALARM_GET_EVCCID_TIMEOUT;
+				}
+
 				if(idxEvent > 0)
 					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
 			}

+ 22 - 6
EVSE/Projects/AX80/Apps/main.c

@@ -5289,6 +5289,7 @@ int main(void)
 				{
 					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
 					{
+						ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout = OFF;
 						refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
 					}
 
@@ -5447,7 +5448,10 @@ int main(void)
 				if(ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus != SYS_MODE_BOOTING)
 				{
 					// Alarm event check
-					if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0) || ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail || ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP)
+					if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0) ||
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail ||
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP ||
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail)
 					{
 						if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus != SYS_MODE_ALARM)
 						{
@@ -5689,19 +5693,28 @@ int main(void)
 						 *	TODO:
 						 *	1. Try to get EVCCID if plug first
 						 */
-						if(ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID &&
-						   ShmCharger->isCcsEnable &&
-						  (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B))
+						if((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE) &&
+						    ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID &&
+						    ShmCharger->isCcsEnable &&
+						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
+						    !ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout)
 						{
 							if(!getRequest(gun_index))
 							{
 								DEBUG_INFO("Try to get EVCCID.\n");
+								refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
 								setRequest(gun_index, ON);
 							}
 
+							if(getDiffSecNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
+							{
+								ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout = ON;
+								DEBUG_WARN("Try to get EVCCID timeout.\n");
+							}
+
 							if(ShmCharger->gun_info[gun_index].ccsHandshakeState == HANDSHAKE_CCS)
 							{
-								if((16 < ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus) && (ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus < 254))
+								if((19 <= ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus) && (ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus < 254))
 								{
 									if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 									{
@@ -6465,7 +6478,10 @@ int main(void)
 							}
 						}
 
-						if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0) && !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail && !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP)
+						if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0) &&
+						   !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail &&
+						   !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP &&
+						   !ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail)
 						{
 							if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING)) &&
 								!ShmCharger->gun_info[gun_index].isEmergencyStopReport)

+ 5 - 3
EVSE/Projects/AX80/Apps/main.h

@@ -54,18 +54,18 @@
 #define ALARM_CURRENT_LEAK_DC                   0x00000080
 
 #define ALARM_MCU_TESTFAIL						0x00000100
-#define ALARM_HANDSHAKE_TIMEOUT                 0x00000200
+#define ALARM_GET_EVCCID_TIMEOUT                0x00000200
 #define ALARM_EMERGENCY_STOP                    0x00000400
 #define ALARM_RELAY_WELDING                     0x00000800
 #define ALARM_LEAK_MODULE_FAIL                  0x00001000
-#define ALARM_SHUTTER_FAULT                     0x00002000
+#define ALARM_RESERVE_1 	                    0x00002000
 #define ALARM_LOCKER_FAULT                      0x00004000
 #define ALARM_POWER_DROP                        0x00008000
   
 #define ALARM_L1_CIRCUIT_SHORT                  0x00010000
 #define ALARM_ROTATORY_SWITCH_FAULT             0x00020000
 #define ALARM_RELAY_DRIVE_FAULT                 0x00040000
-#define ALARM_BLE_MODULE_BROKEN                 0x00080000
+#define ALARM_RESERVE_2			                0x00080000
 #define ALARM_L2_OVER_VOLTAGE                   0x00100000
 #define ALARM_L3_OVER_VOLTAGE                   0x00200000
 #define ALARM_L2_UNDER_VOLTAGE                  0x00400000
@@ -80,6 +80,7 @@
 #define ALARM_CP_NEG_ERROR 						0x40000000
 #define ALARM_QCA_FLASH_FAIL					0x80000000
 
+
 //=================================
 //CCS related define
 //=================================
@@ -798,6 +799,7 @@ typedef struct GUN_INFO
 	uint32_t										isGunUnpluggedBefore:1;
 	uint32_t										isEmergencyStopReport:1;
 	uint32_t										isGetEvCCID:1;
+	uint32_t										isGetEvCCIDTimeout:1;
 }Gun_Info;
 
 struct Charger