Quellcode durchsuchen

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 vor 2 Jahren
Ursprung
Commit
544345b0d4
1 geänderte Dateien mit 43 neuen und 89 gelöschten Zeilen
  1. 43 89
      EVSE/Modularization/ocppfiles/MessageHandler.c

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

@@ -5458,7 +5458,7 @@ void CheckSystemValue(void)
 	//===============================
 	// 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
 		sendHeartbeatRequest(0);
@@ -10456,97 +10456,49 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
 	json_object_put(ClearChargingProfile);
 
 
-	if(connectorIsNULL == FALSE)
+	if(connectorIdInt > 0)
 	{
-		switch(connectorIdInt)
+		if(chargingProfilePurposeIsNULL == TRUE)
 		{
-			case 0:
-
-			    if(chargingProfilePurposeIsNULL == TRUE)
-				{
-			    	int l = 0;
-			    	strcpy(fname, ChargePointMaxProfile_JSON);
-			    	if((access(fname,F_OK))!=-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;
-					}
-				}
+			int m = 0;
+			memset(fname, 0, ARRAY_SIZE(fname));
+			sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
+			if((access(fname,F_OK))!=-1)
+			{
+				strcpy(chargingProfiles[m], fname);
+				m = m + 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:
-			    if(chargingProfilePurposeIsNULL == TRUE)
-			    {
-			    	int m = 0;
-			    	memset(fname, 0, ARRAY_SIZE(fname));
-			    	sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
-			    	if((access(fname,F_OK))!=-1)
-			    	{
-			    		strcpy(chargingProfiles[m], fname);
-			    		m = m + 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;
-					}
+			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))
-				{
-					sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
-					if((access(fname,F_OK))!=-1)
-					{
-						strcpy(chargingProfiles[0], fname);
-						ChargeProfileCount = 1;
-					}
-					//strcpy(fname, TxProfile_1_JSON);
-				}
-				//strcpy(fname, ChargePointMaxProfile_JSON );
-				break;
+		}
+		else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
+		{
+			sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
+			if((access(fname,F_OK))!=-1)
+			{
+				strcpy(chargingProfiles[0], fname);
+				ChargeProfileCount = 1;
+			}
+			//strcpy(fname, TxProfile_1_JSON);
 		}
 	}
 	else // Check all Charging Profiles
@@ -13024,20 +12976,22 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 				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++)
 				{
 					if(cpinitateMsg.bits[gun_index].isOnCharging ||
 					   (strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Preparing") != 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))
 						{
 							DEBUG_WARN("DWseries--> Other connector is in charging.\n");
 							result = FAIL;
+							break;
 						}
-						break;
 					}
 				}
 			}