Browse Source

2020-02-10 / Kathy Yeh
1. add System Status SYS_MODE_UPDATE judgement

Kathy_Yeh 5 years ago
parent
commit
0dbfd45891
1 changed files with 20 additions and 17 deletions
  1. 20 17
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 20 - 17
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -45,6 +45,7 @@
 
 
 
+
 #define PASS				1
 #define FAIL				-1
 
@@ -2053,7 +2054,7 @@ int sendStartTransactionRequest(int gun_index)
 	char guid[37]={0};
 	struct timeval tmnow;
 	struct tm *tm;
-	char buf[30];//, usec_buf[6];
+	char buf[28];//, usec_buf[6];
 	char tempdata[65]={0};
 
 	DEBUG_INFO("sendStartTransactionRequest...");
@@ -2063,7 +2064,7 @@ int sendStartTransactionRequest(int gun_index)
 	t = time(NULL);
 	/*UTC time and date*/
 	tm = gmtime(&t);
-	strftime(buf,30,"%Y-%m-%dT%H:%M:%SZ", tm);
+	strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
 #if 0 // remove temporally
 	strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
 	strcat(buf,".");
@@ -2167,7 +2168,7 @@ int sendStatusNotificationRequest(int gun_index)
 	int currentStatus = 0;
 	struct timeval tmnow;
 	struct tm *tm;
-	char buf[30];//, usec_buf[6];
+	char buf[28];//, usec_buf[6];
 	char tempdata[65]={0};
 
 	gettimeofday(&tmnow, NULL);
@@ -2176,7 +2177,7 @@ int sendStatusNotificationRequest(int gun_index)
 	t = time(NULL);
 	/*UTC time and date*/
 	tm = gmtime(&t);
-	strftime(buf,30,"%Y-%m-%dT%H:%M:%SZ", tm);
+	strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
 #if 0 // remove temporally
 	strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
 	strcat(buf,".");
@@ -2244,7 +2245,7 @@ S_FAULT                 =12
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 4; //OCPP Status
 			}
-			else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG))) //S_TERMINATING   ---> Unavailable
+			else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE) )) //S_TERMINATING   ---> Unavailable
 			{
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 7; //OCPP Status: Unavailable
@@ -2290,7 +2291,7 @@ S_FAULT                 =12
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 4; //OCPP Status
 			}
-			else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG))) //S_TERMINATING   ---> Unavailable
+			else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE) )) //S_TERMINATING   ---> Unavailable
 			{
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 7; //OCPP Status
@@ -2336,7 +2337,7 @@ S_FAULT                 =12
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 4; //OCPP Status
 			}
-			else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG))) //S_TERMINATING   ---> Unavailable
+			else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE))) //S_TERMINATING   ---> Unavailable
 			{
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 7; //OCPP Status: Unavailable
@@ -2385,7 +2386,7 @@ S_FAULT                 =12
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 4; //OCPP Status
 			}
-			else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG))) //S_TERMINATING   ---> Unavailable
+			else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE) )) //S_TERMINATING   ---> Unavailable
 			{
 				//strcpy(ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[SuspendedEV]);
 				currentStatus = 7; //OCPP Status: Unavailable
@@ -7583,7 +7584,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 								ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
 							}
-							else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
+							else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
 							{
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 
@@ -7628,7 +7629,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 								ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
 							}
-							else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) ||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '9'))
+							else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) ||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '9'))
 							{
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 							}
@@ -7673,7 +7674,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 								ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
 							}
-							else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
+							else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
 							{
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 							}
@@ -7719,7 +7720,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 								ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
 							}
-							else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
+							else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
 							{
 								strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 
@@ -7761,7 +7762,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 			{
 				if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
+					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
 					{
 						strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 						goto end;
@@ -7789,7 +7790,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 			{
 			   if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
 			   {
-				   if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '9'))
+				   if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '9'))
 				   {
 					   strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 				   }
@@ -7812,7 +7813,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 			{
 				if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
+					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
 					{
 						strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 					}
@@ -7838,7 +7839,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 		  {
 		  	 if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
 		  	 {
-		  		if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
+		  		if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING  //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
 		  		{
 		  			strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
 		  			goto end;
@@ -10272,7 +10273,7 @@ void handleMeterValuesResponse(char *payload, int gun_index)
 void handleStartTransactionResponse(char *payload, int gun_index)
 {
 	mtrace();
-	char sstr[30]={ 0 };
+	char sstr[28]={ 0 };
 	int c = 0;
 	char *loc;
 	int transactionIdInt = 0;
@@ -10371,6 +10372,8 @@ DEBUG_INFO("transactionId: %d\n", ShmOCPP16Data->StartTransaction[gun_index].Res
 		SettingChargingRecord(gun_index, transactionIdInt);
 
 	}
+
+	DEBUG_INFO("Start Charging ErrorCode=%s\n", ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
 }
 
 void handleStatusNotificationResponse(char *payload, int gun_index)