Prechádzať zdrojové kódy

[Improve][Modularization / AW-CCS][Module_OcppBackend20 / Module_Alarm]

2021.09.13 / Folus Wen

Actions:
1. Fix function name from hanlde to handle.
2. TransactionEvent off line logic fix.
3. When task send TransactionEvent call storeTempStopTransaction().
4. GetLogProcess() pck log depend on logType.
5. AW-CCS implement NotificationEvent if alarm occur.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 rokov pred
rodič
commit
1325d971a3

+ 15 - 15
EVSE/Modularization/ocpp20/JsonParser.c

@@ -85,25 +85,25 @@ static FunPtr funs[] = {handleAuthorizeResponse,
 						handleDataTransferResponse,
 						handleFirmwareStatusNotificationResponse,
 						handleGet15118EVCertificateResponse,
-						hanldeGetCertificateStatusResponse,
+						handleGetCertificateStatusResponse,
 						handleHeartbeatResponse,
-						hanldeLogStatusNotificationResponse,
+						handleLogStatusNotificationResponse,
 						handleMeterValuesResponse,
 						handleNotifyChargingLimitResponse,
-						hanldeNotifyCustomerInformationResponse,
-						hanldeNotifyDisplayMessagesResponse,
-						hanldeNotifyEVChargingNeedsResponse,
-						hanldeNotifyEVChargingScheduleResponse,
-						hanldeNotifyEventResponse,
-						hanldeNotifyMonitoringReportResponse,
-						hanldeNotifyReportResponse,
-						hanldePublishFirmwareStatusNotificationResponse,
-						hanldeReportChargingProfilesResponse,
-						hanldeReservationStatusUpdateResponse,
-						hanldeSecurityEventNotificationResponse,
-						hanldeSignCertificateResponse,
+						handleNotifyCustomerInformationResponse,
+						handleNotifyDisplayMessagesResponse,
+						handleNotifyEVChargingNeedsResponse,
+						handleNotifyEVChargingScheduleResponse,
+						handleNotifyEventResponse,
+						handleNotifyMonitoringReportResponse,
+						handleNotifyReportResponse,
+						handlePublishFirmwareStatusNotificationResponse,
+						handleReportChargingProfilesResponse,
+						handleReservationStatusUpdateResponse,
+						handleSecurityEventNotificationResponse,
+						handleSignCertificateResponse,
 						handleStatusNotificationResponse,
-						hanldeTransactionEvenResponse};
+						handleTransactionEvenResponse};
 
 static FunCallPtr funcalls[] = {handleCancelReservationRequest,
 								handleCertificateSignedRequest,

+ 128 - 121
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -6500,20 +6500,23 @@ void CheckSystemValue(void)
 			clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
 		}
 
-		//===============================
-		// CSU Trigger Smart Charging Profilw
-		//===============================
+		//==============================================
+		// CSU Trigger Smart Charging Profile
+		//==============================================
 		if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
 		{
 			checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
 			ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
 		}
 
-		if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
+		//==============================================
+		// CSU transaction event
+		//==============================================
+		if(cpinitateMsg.bits[gun_index].TransactionEventReq == ON)
 		{
 			sendTransactionEventRequest(gun_index);
 			cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
-
+			storeTempStopTransaction(gun_index);
 			memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
 		}
 
@@ -6750,7 +6753,6 @@ void CheckSystemValue(void)
 				if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
 					sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
 
-				storeTempStopTransaction(gun_index);
 				cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
 			}
 
@@ -8018,7 +8020,6 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 		}
 	}
 
-
 	//********************************(7)Current.Import L2************************************************/
 	if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
 	   ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
@@ -8044,12 +8045,12 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				}
 			}
 			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
+			ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
 		}
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
-		ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
 	}
 
 	//********************************(8)Current.Import L3************************************************/
@@ -8077,12 +8078,12 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				}
 			}
 			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
+			ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
 		}
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
-		ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
 	}
 
 
@@ -8111,13 +8112,12 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			}
 
 			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
+			ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
 		}
-
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
-		ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
 	}
 
 	//***********************************************(10)VOLTAGE L3******************************************************/
@@ -8145,13 +8145,12 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			}
 
 			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
+			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
+			ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
 		}
-
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
-		strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
-		ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
 	}
 
 	//***********************************************(11)Current.Offered******************************************************/
@@ -8361,7 +8360,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 
 		for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
 		{
-			if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
+			if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
 			{
 				json_object *sampledValue = json_object_new_object();
 
@@ -8398,17 +8397,15 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 	json_object_object_add(MeterValueReq, "meterValue", meterValues);
 	json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
 
-	sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
-					,gun_index + 1
-					,MESSAGE_TYPE_CALL
-					,guid
-					,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
+	sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",%s]"
+					 ,MESSAGE_TYPE_CALL
+					 ,guid
+					 ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
 
 	json_object_put(MeterValueReq);
 
-	if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
-	   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
-	   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
+	if((dataType != ReadingContextEnumType_Trigger) &&
+	   (dataType != ReadingContextEnumType_Sample_Clock))
 	{
 		// Transaction meter value send by TransactionEvent message
 		memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
@@ -13595,69 +13592,79 @@ void* GetLogProcess(void* data)
 
 	ShmOCPP20Data->GetLog.requestId = requestId;
 
-	// Pack log to compress file
-	if((sscanf((char*)oldestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStart.tm_year, &tmStart.tm_mon, &tmStart.tm_mday, &tmStart.tm_hour, &tmStart.tm_min, &tmStart.tm_sec) == 6) &&
-	   (sscanf((char*)latestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStop.tm_year, &tmStop.tm_mon, &tmStop.tm_mday, &tmStop.tm_hour, &tmStop.tm_min, &tmStop.tm_sec) == 6))
+	if(strstr(logType, LogEnumTypeStr[LogEnumType_SecurityLog]))
 	{
-		// Pack system log
-		memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
-		sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
-		targetYear = tmStart.tm_year;
-		targetMonth = tmStart.tm_mon;
-
-		do
+		/*
+		 * TODO:
+		 * 	1. Pack security log
+		 */
+	}
+	else
+	{
+		// Pack log to compress file
+		if((sscanf((char*)oldestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStart.tm_year, &tmStart.tm_mon, &tmStart.tm_mday, &tmStart.tm_hour, &tmStart.tm_min, &tmStart.tm_sec) == 6) &&
+		   (sscanf((char*)latestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStop.tm_year, &tmStop.tm_mon, &tmStop.tm_mday, &tmStop.tm_hour, &tmStop.tm_min, &tmStop.tm_sec) == 6))
 		{
-			sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
-			sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
+			// Pack system log
+			memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
+			sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
+			targetYear = tmStart.tm_year;
+			targetMonth = tmStart.tm_mon;
 
-			if(targetMonth+1>=13)
+			do
 			{
-				targetYear += 1;
-				targetMonth = 1;
-			}
-			else
-			{
-				targetMonth += 1;
-			}
-		}while((targetYear < (tmNow->tm_year+1900)) ||
-			   ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
+				sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
+				sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
 
-		sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
-		system(cmdBuf);
+				if(targetMonth+1>=13)
+				{
+					targetYear += 1;
+					targetMonth = 1;
+				}
+				else
+				{
+					targetMonth += 1;
+				}
+			}while((targetYear < (tmNow->tm_year+1900)) ||
+				   ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
 
-		// Pack charging & event log
-		memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
-		sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
-		targetYear = tmStart.tm_year;
-		targetMonth = tmStart.tm_mon;
+			sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
+			system(cmdBuf);
 
-		do
-		{
-			sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
+			// Pack charging & event log
+			memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
+			sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
+			targetYear = tmStart.tm_year;
+			targetMonth = tmStart.tm_mon;
 
-			if(targetMonth+1>=13)
-			{
-				targetYear += 1;
-				targetMonth = 1;
-			}
-			else
+			do
 			{
-				targetMonth += 1;
-			}
-		}while((targetYear < (tmNow->tm_year+1900)) ||
-			   ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
+				sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
 
-		sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
-		sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
-		system(cmdBuf);
+				if(targetMonth+1>=13)
+				{
+					targetYear += 1;
+					targetMonth = 1;
+				}
+				else
+				{
+					targetMonth += 1;
+				}
+			}while((targetYear < (tmNow->tm_year+1900)) ||
+				   ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
 
-		// Combine log file
-		system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
-		system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
-	}
-	else
-	{
-		system("exec /root/logPackTools 'log' 6");
+			sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
+			sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
+			system(cmdBuf);
+
+			// Combine log file
+			system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
+			system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
+		}
+		else
+		{
+			system("exec /root/logPackTools 'log' 6");
+		}
 	}
 
 	sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
@@ -17180,12 +17187,12 @@ void handleGet15118EVCertificateResponse(char *payload, int gun_index)
 	ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
 }
 
-void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
+void handleGetCertificateStatusResponse(char *payload, int gun_index)
 {
 	mtrace();
 	json_object *GetCertificateStatus;
 
-	DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
+	DEBUG_INFO("handleGetCertificateStatusResponse...\n");
 	GetCertificateStatus = json_tokener_parse(payload);
 	if(!is_error(GetCertificateStatus))
 	{
@@ -17229,11 +17236,11 @@ void handleHeartbeatResponse(char *payload, int gun_index)
 	syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
 }
 
-void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
+void handleLogStatusNotificationResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
+	DEBUG_INFO("handleLogStatusNotificationResponse...\n");
 
 	ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
@@ -17256,29 +17263,29 @@ void handleNotifyChargingLimitResponse(char *payload, int gun_index)
 	ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
 }
 
-void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
+void handleNotifyCustomerInformationResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
+	DEBUG_INFO("handleNotifyCustomerInformationResponse...\n");
 }
 
-void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
+void handleNotifyDisplayMessagesResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
+	DEBUG_INFO("handleNotifyDisplayMessagesResponse...\n");
 
 	ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
 }
 
-void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
+void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
 {
 	mtrace();
 	json_object *NotifyEVChargingNeeds;
 
-	DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
+	DEBUG_INFO("handleNotifyEVChargingNeedsResponse...\n");
 	NotifyEVChargingNeeds = json_tokener_parse(payload);
 	if(!is_error(NotifyEVChargingNeeds))
 	{
@@ -17292,12 +17299,12 @@ void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
 	ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
 }
 
-void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
+void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
 {
 	mtrace();
 	json_object *NotifyEVChargingSchedule;
 
-	DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
+	DEBUG_INFO("handleNotifyEVChargingScheduleResponse...\n");
 	NotifyEVChargingSchedule = json_tokener_parse(payload);
 	if(!is_error(NotifyEVChargingSchedule))
 	{
@@ -17311,80 +17318,80 @@ void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
 	ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
 }
 
-void hanldeNotifyEventResponse(char *payload, int gun_index)
+void handleNotifyEventResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeNotifyEventResponse...\n");
+	DEBUG_INFO("handleNotifyEventResponse...\n");
 
 	ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
 }
 
-void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
+void handleNotifyMonitoringReportResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
+	DEBUG_INFO("handleNotifyMonitoringReportResponse...\n");
 
 	ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
 }
 
-void hanldeNotifyReportResponse(char *payload, int gun_index)
+void handleNotifyReportResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeNotifyReportResponse...\n");
+	DEBUG_INFO("handleNotifyReportResponse...\n");
 	ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
 }
 
-void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
+void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
+	DEBUG_INFO("handlePublishFirmwareStatusNotificationResponse...\n");
 
 	ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
 	ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
 }
 
-void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
+void handleReportChargingProfilesResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
+	DEBUG_INFO("handleReportChargingProfilesResponse...gun_index: %d\n", gun_index);
 
 	ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
 }
 
-void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
+void handleReservationStatusUpdateResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
+	DEBUG_INFO("handleReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
 
 	ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
 	ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
 }
 
-void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
+void handleSecurityEventNotificationResponse(char *payload, int gun_index)
 {
 	mtrace();
 
-	DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
+	DEBUG_INFO("handleSecurityEventNotificationResponse...\n");
 	ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
 	ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
 }
 
-void hanldeSignCertificateResponse(char *payload, int gun_index)
+void handleSignCertificateResponse(char *payload, int gun_index)
 {
 	mtrace();
 	json_object *SignCertificate;
 
-	DEBUG_INFO("hanldeSignCertificateResponse...\n");
+	DEBUG_INFO("handleSignCertificateResponse...\n");
 	SignCertificate = json_tokener_parse(payload);
 	if(!is_error(SignCertificate))
 	{
@@ -17417,12 +17424,12 @@ void handleStatusNotificationResponse(char *payload, int gun_index)
 	cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
 }
 
-void hanldeTransactionEvenResponse(char *payload, int gun_index)
+void handleTransactionEvenResponse(char *payload, int gun_index)
 {
 	mtrace();
 	json_object *TransactionEven;
 
-	DEBUG_INFO("hanldeTransactionEvenResponse...\n");
+	DEBUG_INFO("handleTransactionEvenResponse...\n");
 	TransactionEven = json_tokener_parse(payload);
 	if(!is_error(TransactionEven))
 	{
@@ -18114,7 +18121,7 @@ void storeTempStopTransaction(int gun_index)
 	json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
 	json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
 	json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
-	json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
+	json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo+1));
 	json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
 
 	if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)

+ 15 - 15
EVSE/Modularization/ocpp20/MessageHandler.h

@@ -956,25 +956,25 @@ void handleClearedChargingLimitResponse(char *payload, int gun_index);
 void handleDataTransferResponse(char *payload, int gun_index);
 void handleFirmwareStatusNotificationResponse(char *payload, int gun_index);
 void handleGet15118EVCertificateResponse(char *payload, int gun_index);
-void hanldeGetCertificateStatusResponse(char *payload, int gun_index);
+void handleGetCertificateStatusResponse(char *payload, int gun_index);
 void handleHeartbeatResponse(char *payload, int gun_index);
-void hanldeLogStatusNotificationResponse(char *payload, int gun_index);
+void handleLogStatusNotificationResponse(char *payload, int gun_index);
 void handleMeterValuesResponse(char *payload, int gun_index);
 void handleNotifyChargingLimitResponse(char *payload, int gun_index);
-void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index);
-void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index);
-void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index);
-void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index);
-void hanldeNotifyEventResponse(char *payload, int gun_index);
-void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index);
-void hanldeNotifyReportResponse(char *payload, int gun_index);
-void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index);
-void hanldeReportChargingProfilesResponse(char *payload, int gun_index);
-void hanldeReservationStatusUpdateResponse(char *payload, int gun_index);
-void hanldeSecurityEventNotificationResponse(char *payload, int gun_index);
-void hanldeSignCertificateResponse(char *payload, int gun_index);
+void handleNotifyCustomerInformationResponse(char *payload, int gun_index);
+void handleNotifyDisplayMessagesResponse(char *payload, int gun_index);
+void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index);
+void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index);
+void handleNotifyEventResponse(char *payload, int gun_index);
+void handleNotifyMonitoringReportResponse(char *payload, int gun_index);
+void handleNotifyReportResponse(char *payload, int gun_index);
+void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index);
+void handleReportChargingProfilesResponse(char *payload, int gun_index);
+void handleReservationStatusUpdateResponse(char *payload, int gun_index);
+void handleSecurityEventNotificationResponse(char *payload, int gun_index);
+void handleSignCertificateResponse(char *payload, int gun_index);
 void handleStatusNotificationResponse(char *payload, int gun_index);
-void hanldeTransactionEvenResponse(char *payload, int gun_index);
+void handleTransactionEvenResponse(char *payload, int gun_index);
 
 //==========================================
 // Handle Error routine

+ 581 - 136
EVSE/Projects/AW-CCS/Apps/Module_AlarmDetect.c

@@ -71,6 +71,7 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
 struct OCPP16Data				*ShmOCPP16Data;
+struct OCPP20Data				*ShmOCPP20Data;
 struct Charger					*ShmCharger;
 
 
@@ -210,6 +211,20 @@ int InitShareMemory()
 	else
 	{}
 
+   	//creat ShmOCPP20Data
+   	if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data),  0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
     return result;
 }
 
@@ -241,6 +256,14 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
 	dest[cnt] = 0;
 }
 
+void getNowDatetime(uint8_t *data)
+{
+	time_t t = time(NULL);
+	struct tm tm = *localtime(&t);
+
+	sprintf((char*)data, "%04d-%02d-%02dT%02d:%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+}
+
 //==========================================
 // Main process
 //==========================================
@@ -1008,150 +1031,572 @@ int main(void)
 			//=====================================
 			// OCPP error code message
 			//=====================================
-			if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE) ||
-				(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE) ||
-				(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE))
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012200");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012201");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012202");
-				
-			}
-			else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE) ||
-					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE) ||
-					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE))
-			{	
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012203");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012204");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012205");
+				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE) ||
+					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE) ||
+					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE))
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012200");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012201");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012202");
 
-			}
-			else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT) ||
-					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT) ||
-					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT))
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012216");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012299");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012300");
-				
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012223");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012256");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "023703");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012233");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012233");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012257");
-			}
-			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");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012251");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011009");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011004");
-			}
-			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");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011027");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012212");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012213");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012214");
+				}
+				else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE))
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012203");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012204");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012205");
 
-			}
-			else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT) ||
-					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT) ||
-					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT))
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012262");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012301");
-				else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012302");
+				}
+				else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT))
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012216");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012299");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012300");
 
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012223");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012256");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "023703");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012233");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012233");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012257");
+				}
+				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");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012251");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011009");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011004");
+				}
+				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");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011027");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012212");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012213");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012214");
+
+				}
+				else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT))
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012262");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012301");
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
+						sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012302");
+
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011036");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011010");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012305");
+				}
+				else
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "NoError");
+					memset(ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode, 0x00, ARRAY_SIZE(ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode));
+				}
 			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011036");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011010");
-			}
-			else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)
-			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012305");
-			}
-			else
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "NoError");
-				memset(ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode, 0x00, ARRAY_SIZE(ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode));
+				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE) ||
+					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE) ||
+					(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012200");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L1 input OVP");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012201");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L2 input OVP");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012202");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L3 input OVP");
+					}
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Voltage");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012203");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L1 input UVP");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012204");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L2 input UVP");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012205");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L3 input UVP");
+					}
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Voltage");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012216");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System AC output OCP L1");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012299");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System AC output OCP L2");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012300");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System AC output OCP L3");
+					}
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Current");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012223");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System ambient/inlet OTP");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Temperature");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012256");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "AC Ground Fault");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Ground(PE)");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "023703");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "pilot fault");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Control pilot");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012233");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "RCD/CCID trip");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "CCID");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012233");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "RCD/CCID trip");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "CCID");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012257");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "MCU self-test Fault");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "MCU");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "HandshakeTimeout");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "HandshakeTimeout");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Operation");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012251");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Emergency stop");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Button");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "011009");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "AC output relay welding");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Relay");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "011004");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "RCD/CCID self-test fail");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "CCID");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "011034");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Shutter fault");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Shutter");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "011027");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "AC connector lock fail");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Locker");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012212");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L1 input drop");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012213");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L2 input drop");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012214");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "System L3 input drop");
+					}
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Voltage");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT) ||
+						(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012262");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Circuit Short L1");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012301");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Circuit Short L2");
+					}
+					else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
+					{
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012302");
+						sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Circuit Short L3");
+					}
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Current");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "011036");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Rotary switch fault");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Rotary switch");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "011010");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "AC output relay driving fault");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Relay");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[0].timestamp);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].actualValue, "true");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techcode, "012305");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].techInfo, "Meter communication timeout");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].component.name, "Meter");
+					ShmOCPP20Data->NotifyEvent.eventData[0].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[0].variable.name, "Problem");
+
+					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
+				}
+				else
+				{}
 			}
 
+
 			//=====================================
 			// Latch alarm recover in state A
 			//=====================================