Explorar o código

2022-11-21/Jerry Wang
[OCPP 1.6]
Action:
1. Modify logic for DW series to reject the RemoteStart.req when one of the connectors is in charging.
2. Fix the problem of sending Heartbeat anytime once HeartbeatInterval is set to 0.
3. Fix the problem that charger cannot clear all ChargingProfiles when it recieved the ClearChargingProfile command with connectorId 0.

File:
1. EVSE/Modularization/ocppfiles/MessageHandler.c
--> Action 1-3

Jerry Wang %!s(int64=2) %!d(string=hai) anos
pai
achega
544345b0d4
Modificáronse 1 ficheiros con 43 adicións e 89 borrados
  1. 43 89
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 43 - 89
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -5458,7 +5458,7 @@ void CheckSystemValue(void)
 	//===============================
 	//===============================
 	// send Heartbeat
 	// send Heartbeat
 	//===============================
 	//===============================
-	if((server_sign == TRUE) && (getDiffSecNow(clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
+	if((server_sign == TRUE) && (HeartBeatWaitTime > 0) && (getDiffSecNow(clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
 	{
 	{
 		//parameter for test
 		//parameter for test
 		sendHeartbeatRequest(0);
 		sendHeartbeatRequest(0);
@@ -10456,97 +10456,49 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
 	json_object_put(ClearChargingProfile);
 	json_object_put(ClearChargingProfile);
 
 
 
 
-	if(connectorIsNULL == FALSE)
+	if(connectorIdInt > 0)
 	{
 	{
-		switch(connectorIdInt)
+		if(chargingProfilePurposeIsNULL == TRUE)
 		{
 		{
-			case 0:
+			int m = 0;
-
+			memset(fname, 0, ARRAY_SIZE(fname));
-			    if(chargingProfilePurposeIsNULL == TRUE)
+			sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
-				{
+			if((access(fname,F_OK))!=-1)
-			    	int l = 0;
+			{
-			    	strcpy(fname, ChargePointMaxProfile_JSON);
+				strcpy(chargingProfiles[m], fname);
-			    	if((access(fname,F_OK))!=-1)
+				m = m + 1;
-			    	{
+			}
-			    		strcpy(chargingProfiles[l], fname);
-			    		l = l + 1;
-			    	}
-
-			    	strcpy(fname, TxDefaultProfile_0_JSON);
-			    	if((access(fname,F_OK))!=-1)
-			    	{
-			    		strcpy(chargingProfiles[l], fname);
-			    		l = l + 1;
-			    	}
-			    	ChargeProfileCount = l;
-
-				}
-				else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
-				{
-					strcpy(fname, ChargePointMaxProfile_JSON);
-					if((access(fname,F_OK))!=-1)
-					{
-						strcpy(chargingProfiles[0], fname);
-						ChargeProfileCount = 1;
-					}
-				}
-				else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
-				{
-					strcpy(fname, TxDefaultProfile_0_JSON);
-					if((access(fname,F_OK))!=-1)
-					{
-						strcpy(chargingProfiles[0], fname);
-						ChargeProfileCount = 1;
-					}
-				}
 
 
-				break;
+			memset(fname, 0, ARRAY_SIZE(fname));
+			sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
+			if((access(fname,F_OK))!=-1)
+			{
+				strcpy(chargingProfiles[m], fname);
+				m = m + 1;
+			}
 
 
-			default:
+			ChargeProfileCount = m;
-			    if(chargingProfilePurposeIsNULL == TRUE)
+		}
-			    {
+		else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
-			    	int m = 0;
+		{
-			    	memset(fname, 0, ARRAY_SIZE(fname));
+			//strcpy(fname, TxDefaultProfile_1_JSON);
-			    	sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
+			sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
-			    	if((access(fname,F_OK))!=-1)
+			if((access(fname,F_OK))!=-1)
-			    	{
+			{
-			    		strcpy(chargingProfiles[m], fname);
+				strcpy(chargingProfiles[0], fname);
-			    		m = m + 1;
+				ChargeProfileCount = 1;
-			    	}
+			}
-
-			    	memset(fname, 0, ARRAY_SIZE(fname));
-			    	sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
-			    	if((access(fname,F_OK))!=-1)
-			    	{
-			    		strcpy(chargingProfiles[m], fname);
-			    		m = m + 1;
-			    	}
-
-			    	ChargeProfileCount = m;
-			    }
-				else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
-				{
-					//strcpy(fname, TxDefaultProfile_1_JSON);
-					sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
-					if((access(fname,F_OK))!=-1)
-					{
-						strcpy(chargingProfiles[0], fname);
-						ChargeProfileCount = 1;
-					}
 
 
-				}
+		}
-				else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
+		else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
-				{
+		{
-					sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
+			sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
-					if((access(fname,F_OK))!=-1)
+			if((access(fname,F_OK))!=-1)
-					{
+			{
-						strcpy(chargingProfiles[0], fname);
+				strcpy(chargingProfiles[0], fname);
-						ChargeProfileCount = 1;
+				ChargeProfileCount = 1;
-					}
+			}
-					//strcpy(fname, TxProfile_1_JSON);
+			//strcpy(fname, TxProfile_1_JSON);
-				}
-				//strcpy(fname, ChargePointMaxProfile_JSON );
-				break;
 		}
 		}
 	}
 	}
 	else // Check all Charging Profiles
 	else // Check all Charging Profiles
@@ -13024,20 +12976,22 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 				ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileId = -1;
 				ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileId = -1;
 			}
 			}
 
 
-			if((ShmSysConfigAndInfo->SysConfig.ModelName[0] != 'D') && (ShmSysConfigAndInfo->SysConfig.ModelName[1] != 'W'))
+			if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'W'))
 			{
 			{
+				DEBUG_INFO("Checking charging status for DW series...\n");
 				for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
 				for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
 				{
 				{
 					if(cpinitateMsg.bits[gun_index].isOnCharging ||
 					if(cpinitateMsg.bits[gun_index].isOnCharging ||
 					   (strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Preparing") != NULL) ||
 					   (strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Preparing") != NULL) ||
 					   (strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Finishing") != NULL))
 					   (strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Finishing") != NULL))
 					{
 					{
+						DEBUG_INFO("Found gun-%d is in charging.\n", gun_index);
 						if(connectorIdInt != (gun_index+1))
 						if(connectorIdInt != (gun_index+1))
 						{
 						{
 							DEBUG_WARN("DWseries--> Other connector is in charging.\n");
 							DEBUG_WARN("DWseries--> Other connector is in charging.\n");
 							result = FAIL;
 							result = FAIL;
+							break;
 						}
 						}
-						break;
 					}
 					}
 				}
 				}
 			}
 			}