ソースを参照

Merge branch 'BYTON-GB' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x into BYTON-GB

Edward Lien 5 年 前
コミット
cfc59705ff

+ 2 - 2
EVSE/Modularization/Makefile

@@ -48,8 +48,8 @@ Module_4g:
 
 WebServiceLib:
 	rm -f WebService
-	$(CC) -D $(Project) -I ../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c -I ../Projects -O0 -g3 -Wall -c -fmessage-length=0 -o WebService.o -ljson-c -w WebService.c
-	$(CC) -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -o WebService WebService.o -ljson-c
+	$(CC) -D $(Project) -I ../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c -I ../Projects -O0 -g3 -Wall -c -fmessage-length=0 -o WebService.o -ljson-c -lm -w WebService.c
+	$(CC) -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -o WebService WebService.o -ljson-c -lm
 	rm -f WebService.o
 	$(CC) -D $(Project) -O0 -g3 -Wall -c -fmessage-length=0 -o logPackTools.o logPackTools.c
 	$(CC) -o logPackTools logPackTools.o

+ 56 - 3
EVSE/Modularization/WebService.c

@@ -26,11 +26,11 @@
 #include	<time.h>
 #include	<ctype.h>
 #include 	<ifaddrs.h>
+#include	<math.h>
 #include	"define.h"
 #include	"json.h"
 
 
-#include <math.h>
 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
@@ -48,6 +48,7 @@ struct StatusCodeData		*ShmStatusCodeData;
 struct CHAdeMOData			*ShmCHAdeMOData;
 struct GBTData				*ShmGBTData;
 struct CcsData				*ShmCcsData;
+struct PsuData 				*ShmPsuData;
 
 void trim(char *s);
 int mystrcmp(char *p1, char *p2);
@@ -247,6 +248,21 @@ int InitShareMemory() {
 	} else {
 	}
 
+	//creat ShmPsuData
+	if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData),
+			0777)) < 0) {
+	#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmPsuData NG\n");
+	#endif
+		result = FAIL;
+	} else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
+	#ifdef SystemLogMessage
+		DEBUG_ERROR("shmat ShmPsuData NG\n");
+	#endif
+		result = FAIL;
+	} else {
+	}
+
 	return result;
 }
 
@@ -767,7 +783,7 @@ int main(int argc, char *argv[]) {
 		if (strcmp(argv[1], "aaa") == 0) {
 			//struct SysConfigData 	SysConfig;
 		//system
-		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "DSLU601U1JT1P0D");
+		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "DSLU601001T1P0D");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber, "SerialNumber");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemId, "1234567890");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemDateTime, "2019-12-31 23:59:59");
@@ -954,6 +970,11 @@ int main(int argc, char *argv[]) {
 		unsigned char connector1FwVer[32];
 		unsigned char connector2FwVer[32];
 		short gunQty;
+		char *RatedPower1[2];
+		char *RatedPower2[2];
+		char *RatedPower3[2];
+		short RatedPower;
+		short PsuQuantity = 0;
 		substr((char *)IsAcDc,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,0,1);
 		substr((char *)Connector1,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,7,1);
 		substr((char *)Connector2,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,9,1);
@@ -997,7 +1018,19 @@ int main(int argc, char *argv[]) {
 //				memcpy(connector2FwVer,ShmCHAdeMOData->evse[gunQty].version,ARRAY_SIZE(ShmCHAdeMOData->evse[gunQty].version));
 			}
 		}
-
+		substr((char *)RatedPower1,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,4,1);
+		substr((char *)RatedPower2,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,5,1);
+		substr((char *)RatedPower3,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,6,1);
+		int p1=atoi(RatedPower1);
+		int p2=atoi(RatedPower2);
+		int p3=atoi(RatedPower3);
+		if(strcmp(IsAcDc, "D") == 0){
+			RatedPower=(p1*10+p2)*pow(10,p3-1);
+			if(RatedPower>=30){
+				PsuQuantity = RatedPower/30;
+			}
+		}
+		
 		struct json_object *jobj1;
 		struct json_object *jobj2;
 		struct json_object *jobj3;
@@ -1058,6 +1091,10 @@ int main(int argc, char *argv[]) {
 		struct json_object *Ccs2PlugInTimes;
 		struct json_object *ChademoPlugInTimes;
 		struct json_object *FirmwareUpdate;
+		struct json_object *FwPrimaryVersion[PsuQuantity];
+		struct json_object *FwPrimaryVersionArr= json_object_new_array();
+		struct json_object *FwSecondVersion[PsuQuantity];
+		struct json_object *FwSecondVersionArr= json_object_new_array();
 		//charging
 		struct json_object *MaxChargingEnergy;
 		struct json_object *MaxChargingPower;
@@ -1197,6 +1234,13 @@ int main(int argc, char *argv[]) {
 		Ccs2PlugInTimes = json_object_new_int(ShmSysConfigAndInfo->SysConfig.Ccs2PlugInTimes);
 		ChademoPlugInTimes = json_object_new_int(ShmSysConfigAndInfo->SysConfig.ChademoPlugInTimes);
 		FirmwareUpdate = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate);
+		if(strcmp(IsAcDc, "D") == 0){
+			for(int i=0;i<PsuQuantity;i++){
+				FwPrimaryVersion[i] = json_object_new_string((char *)&ShmPsuData->PsuVersion->FwPrimaryVersion[i]);
+				FwSecondVersion[i] = json_object_new_string((char *)&ShmPsuData->PsuVersion->FwSecondVersion[i]);
+			}
+		}
+
 		//charging
 		int CcsGunQty=0;
 		int GbGunQty=0;
@@ -1618,6 +1662,15 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj1,"Ccs2PlugInTimes",Ccs2PlugInTimes);
 		json_object_object_add(jobj1,"ChademoPlugInTimes",ChademoPlugInTimes);
 		json_object_object_add(jobj1,"FirmwareUpdate",FirmwareUpdate);
+		if(IsAcDc == "D"){
+			for(int i=0;i<PsuQuantity;i++){
+				json_object_array_add(FwPrimaryVersionArr,FwPrimaryVersion[i]);
+				json_object_array_add(FwSecondVersionArr,FwSecondVersion[i]);
+			}
+			json_object_object_add(jobj1,"FwPrimaryVersion",FwPrimaryVersionArr);
+			json_object_object_add(jobj1,"FwSecondVersion",FwSecondVersionArr);
+		}
+
 		printf("%s\n", json_object_to_json_string(jobj1));
 		json_object_put(jobj1);
 		//charging

+ 147 - 200
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -1740,8 +1740,6 @@ int sendBootNotificationRequest(void)
     	return result;
     }
 
-
-
 	// Fill BootNotification fields
 	strcpy((char *)ShmOCPP16Data->BootNotification.CbSN,(const char *)ShmOCPP16Data->ChargeBoxId);
 	strcpy((char *)ShmOCPP16Data->BootNotification.CpModel,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName);
@@ -5333,7 +5331,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   			  		c = 0;
   			  		loc = strstr(SchedulePeriodList[i], "limit");
   			  		memset(sstr ,0, sizeof(sstr) );
-  			  		while (loc[strlen("limit")+2+c] != ',')
+  			  		while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
   			  		{
   			  			sstr[c] = loc[strlen("limit")+2+c];
   			  			//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -5346,14 +5344,24 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   			  		c = 0;
   			  		loc = strstr(SchedulePeriodList[i], "numberPhases");
   			  		memset(sstr ,0, sizeof(sstr) );
-  			  		while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+
+  			  		if(loc != NULL)
   			  		{
-  			  			sstr[c] = loc[strlen("numberPhases")+2+c];
-  			  			//printf("i=%d sstr=%c\n",c, sstr[c]);
-  			  			c++;
+  			  			while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+  			  		  	{
+  			  		  		sstr[c] = loc[strlen("numberPhases")+2+c];
+  			  		  		//printf("i=%d sstr=%c\n",c, sstr[c]);
+  			  		  		c++;
+  			  		  	}
+  			  		  	sstr[c] = '\0';
+  			  		  	tempNumberPhasesInt = atoi(sstr);
+
+  			  		}
+  			  		else
+  			  		{
+  			  			tempNumberPhasesInt = 0;
   			  		}
-  			  		sstr[c] = '\0';
-  			  		tempNumberPhasesInt = atoi(sstr);
+
 
   			    	ChargePointMaxProfile.Duration = durationInt;
   			    	ChargePointMaxProfile.TotalPeriod = n_SchedulePeriods;
@@ -5550,7 +5558,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   	  	  	  		c = 0;
   	  	  	  		loc = strstr(SchedulePeriodList[i], "limit");
   	  	  	  		memset(sstr ,0, sizeof(sstr) );
-  	  	  	  		while (loc[strlen("limit")+2+c] != ',')
+  	  	  	  		while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
   	  	  	  		{
   	  	  	  			sstr[c] = loc[strlen("limit")+2+c];
   	  	  	  			//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -5563,14 +5571,23 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   	  	  	  		c = 0;
   	  	  	  		loc = strstr(SchedulePeriodList[i], "numberPhases");
   	  	  	  		memset(sstr ,0, sizeof(sstr) );
-  	  	  	  		while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+
+  	  	  	  		if(loc != NULL)
   	  	  	  		{
-  	  	  	  			sstr[c] = loc[strlen("numberPhases")+2+c];
-  	  	  	  			//printf("i=%d sstr=%c\n",c, sstr[c]);
-  	  	  	  			c++;
+  	  	  	  			while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+  	  	  	  	  	  	{
+  	  	  	  				sstr[c] = loc[strlen("numberPhases")+2+c];
+  	  	  	  	  	  	  	//printf("i=%d sstr=%c\n",c, sstr[c]);
+  	  	  	  	  	  	  	c++;
+  	  	  	  	  	  	}
+  	  	  	  	  	  	sstr[c] = '\0';
+  	  	  	  	  	  	tempNumberPhasesInt = atoi(sstr);
+
+  	  	  	  		}
+  	  	  	  		else
+  	  	  	  		{
+  	  	  	  			tempNumberPhasesInt = 0;
   	  	  	  		}
-  	  	  	  		sstr[c] = '\0';
-  	  	  	  		tempNumberPhasesInt = atoi(sstr);
 
   	  	  	    	TxDefaultProfile.Duration = durationInt;
   	  	  	    	TxDefaultProfile.TotalPeriod = n_SchedulePeriods;
@@ -5712,6 +5729,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   			//*****************************ChargePointMaxProfile******************************************/
   			strcpy(fname, ChargePointMaxProfile_JSON);
   			ChargePointMaxProfileIsNull=TRUE;
+
   			if((access(ChargePointMaxProfile_JSON,F_OK))!=-1)
   			{
   				fptr1 = fopen(fname, "r");
@@ -5759,6 +5777,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   				  	sstr[c] = '\0';
   				  	tempconnectorIdInt = atoi(sstr);
 #endif
+
   				  	//***********validFrom**************/
   				  	c = 0;
   				  	loc = strstr(sLineWord, "validFrom");
@@ -5884,7 +5903,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   				  		c = 0;
   				  		loc = strstr(SchedulePeriodList[i], "limit");
   				  		memset(sstr ,0, sizeof(sstr) );
-  				  		while (loc[strlen("limit")+2+c] != ',')
+  				  		while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
   				  		{
   				  			sstr[c] = loc[strlen("limit")+2+c];
   				  			//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -5897,14 +5916,22 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   				  		c = 0;
   				  		loc = strstr(SchedulePeriodList[i], "numberPhases");
   				  		memset(sstr ,0, sizeof(sstr) );
-  				  		while (loc[strlen("numberPhases")+2+c] != '}')
+
+  				  		if(loc != NULL)
   				  		{
-  				  			sstr[c] = loc[strlen("numberPhases")+2+c];
-  				  			//printf("i=%d sstr=%c\n",c, sstr[c]);
-  				  			c++;
+  				  			while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+  				  	  		{
+  				  	  			sstr[c] = loc[strlen("numberPhases")+2+c];
+  				  	  			//printf("i=%d sstr=%c\n",c, sstr[c]);
+  				  	  			c++;
+  				  	  		}
+  				  	  		sstr[c] = '\0';
+  				  	  		tempNumberPhasesInt = atoi(sstr);
+  				  		}
+  				  		else
+  				  		{
+  				  			tempNumberPhasesInt = 0;
   				  		}
-  				  		sstr[c] = '\0';
-  				  		tempNumberPhasesInt = atoi(sstr);
 
   				  		if(j == 0)
   				  		{
@@ -5937,27 +5964,8 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
 
   			}// the end of access file ChargePointMaxProfile
 
-
   			//****************************TxDefaultProfile************************************************/
-#if 0
-  			switch(connectorIdInt)
-  			{
-  			  	case 0:
-  			  		break;
-
-  			  	case 1:
-  			  		strcpy(fname, TxDefaultProfile_1_JSON );
-  			  		break;
-
-  			  	case 2:
-  			  		strcpy(fname, TxDefaultProfile_2_JSON );
-  			  		break;
 
-  			  	default:
-  			  		strcpy(fname, TxDefaultProfile_1_JSON );
-  			  		break;
-  			}
-#endif
   			memset(fname, 0, sizeof fname);
   			sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
 
@@ -6137,7 +6145,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   	  			  	  	c = 0;
   	  			  	  	loc = strstr(SchedulePeriodList[i], "limit");
   	  			  	  	memset(sstr ,0, sizeof(sstr) );
-  	  			  	  	while (loc[strlen("limit")+2+c] != ',')
+  	  			  	  	while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
   	  			  	  	{
   	  			  	  		sstr[c] = loc[strlen("limit")+2+c];
   	  			  	  		//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -6150,14 +6158,22 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   	  			  	  	c = 0;
   	  			  	  	loc = strstr(SchedulePeriodList[i], "numberPhases");
   	  			  	  	memset(sstr ,0, sizeof(sstr) );
-  	  			  	  	while (loc[strlen("numberPhases")+2+c] != '}')
+
+  	  			  	  	if(loc != NULL)
   	  			  	  	{
-  	  			  	  		sstr[c] = loc[strlen("numberPhases")+2+c];
-  	  			  	  		//printf("i=%d sstr=%c\n",c, sstr[c]);
-  	  			  	  		c++;
+  	  			  	  		while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+  	  			  	  	  	{
+  	  			  	  	  		sstr[c] = loc[strlen("numberPhases")+2+c];
+  	  			  	  	  		//printf("i=%d sstr=%c\n",c, sstr[c]);
+  	  			  	  	  		c++;
+  	  			  	  	  	}
+  	  			  	  	  	sstr[c] = '\0';
+  	  			  	  	  	tempNumberPhasesInt = atoi(sstr);
+  	  			  	  	}
+  	  			  	  	else
+  	  			  	  	{
+  	  			  	  		tempNumberPhasesInt = 0;
   	  			  	  	}
-  	  			  	  	sstr[c] = '\0';
-  	  			  	  	tempNumberPhasesInt = atoi(sstr);
 
   	  			  	  	if(j == 0)
   	  			  	  	{
@@ -6241,25 +6257,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   			}// the end of ACCESS TxDefaultProfile
 
   			//****************************TxProfile************************************************/
-#if 0
-  			switch(connectorIdInt)
-  			{
-  			  	case 0:
-  			  		break;
 
-  			  	case 1:
-  			  		strcpy(fname, TxProfile_1_JSON );
-  			  		break;
-
-  			  	case 2:
-  			  		strcpy(fname, TxProfile_2_JSON );
-  			  		break;
-
-  			  	default:
-  			  		strcpy(fname, TxProfile_1_JSON );
-  			  		break;
-  			}
-#endif
   			memset(fname, 0, sizeof fname);
   			sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
 
@@ -6416,7 +6414,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   				  	  		c = 0;
   				  	  		loc = strstr(SchedulePeriodList[i], "limit");
   				  	  		memset(sstr ,0, sizeof(sstr) );
-  				  	  		while (loc[strlen("limit")+2+c] != ',')
+  				  	  		while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
   				  	  		{
   				  	  			sstr[c] = loc[strlen("limit")+2+c];
   				  	  			//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -6429,15 +6427,23 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   				  	  		c = 0;
   				  	  		loc = strstr(SchedulePeriodList[i], "numberPhases");
   				  	  		memset(sstr ,0, sizeof(sstr) );
-  				  	  		while (loc[strlen("numberPhases")+2+c] != '}')
+
+  				  	  		if(loc != NULL)
   				  	  		{
-  				  	  			sstr[c] = loc[strlen("numberPhases")+2+c];
-  				  	  			//printf("i=%d sstr=%c\n",c, sstr[c]);
-  				  	  			c++;
-  				  	  		}
-  				  	  		sstr[c] = '\0';
-  				  	  		tempNumberPhasesInt = atoi(sstr);
+  				  	  			while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+  				  	  		  	{
+  				  	  		  		sstr[c] = loc[strlen("numberPhases")+2+c];
+  				  	  		  		//printf("i=%d sstr=%c\n",c, sstr[c]);
+  				  	  		  		c++;
+  				  	  		  	}
+  				  	  		  	sstr[c] = '\0';
+  				  	  		  	tempNumberPhasesInt = atoi(sstr);
 
+  				  	  		}
+  				  	  		else
+  				  	  		{
+  				  	  			tempNumberPhasesInt = 0;
+  				  	  		}
 
   				  	  		TxProfile.Duration = durationInt;
   				  	  		TxProfile.TotalPeriod = n_SchedulePeriods;
@@ -6660,8 +6666,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   			}
 
   			confirmPeriods = period;
-  			//DEBUG_INFO("confirmPeriods=%d\n",confirmPeriods);
-
+  			DEBUG_INFO("confirmPeriods=%d\n",confirmPeriods);
   			//---- Define StartSchedule----/
   			struct tm *gtime;
   			time_t now;
@@ -6689,6 +6694,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
   		}
 
  end:
+
 	sendGetCompositeScheduleConfirmation(uuid,comfirmstr, connectorIdInt, confirmPeriods);
 
 	return result;
@@ -9474,26 +9480,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			goto end;
 		}
 
-#if 0
-		switch(connectorIdInt)
-		{
-			case 0:
-				strcpy(filename, TxDefaultProfile_0_JSON );
-			break;
-
-			case 1:
-				strcpy(filename, TxDefaultProfile_1_JSON );
-			break;
-
-			case 2:
-				strcpy(filename, TxDefaultProfile_2_JSON );
-				break;
-
-			default:
-				strcpy(filename, TxDefaultProfile_0_JSON );
-				break;
-		}
-#endif
 		memset(filename, 0, sizeof filename);
 		sprintf(filename, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
 
@@ -9576,6 +9562,23 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			}
 		}
 
+		for (int index = 0; index < AC_QUANTITY; index++)
+		{
+			if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == (connectorIdInt -1))
+			{
+				if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+				{
+					if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
+					{
+						meet = TRUE;
+						break;
+					}
+				}
+
+			}
+		}
+
+
 		if(meet == FALSE)
 		{
 			sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
@@ -9588,25 +9591,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			goto end;
 		}
 
-#if 0
-		switch(connectorIdInt)
-		{
-			case 0:
-				break;
-
-			case 1:
-				strcpy(filename, TxProfile_1_JSON);
-				break;
-
-			case 2:
-				strcpy(filename, TxProfile_2_JSON);
-				break;
-
-			default:
-				strcpy(filename, TxProfile_1_JSON);
-				break;
-		}
-#endif
 		sprintf(filename, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
 
 		fptr1 = fopen(filename, "r");
@@ -9632,7 +9616,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			}
 		}
 		fclose(fptr1);
-		DEBUG_INFO("n_chargingProfile_3=%d\n",n_chargingProfile);
 	}
 
 	// Check ChargeProfileMaxStackLevel
@@ -9786,18 +9769,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 		system(rmFileCmd);
 
 		rename(tempfile, filename);
-#if 0
-		resultRename = rename(tempfile, filename);
-
-		if(resultRename == 0)
-		{
-			DEBUG_INFO("File chargingProfile renamed successfully");
-		}
-		else
-		{
-			DEBUG_INFO("Error: unable to rename the chargingProfile file");
-		}
-#endif
 		//sprintf(rmFileCmd,"rm -f %s",tempfile);
 		//system(rmFileCmd);
 	}
@@ -9967,18 +9938,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 
 		rename(tempfile, filename);
 
-#if 0
-		resultRename = rename(tempfile, filename);
-
-		if(resultRename == 0)
-		{
-			DEBUG_INFO("File chargingProfile renamed successfully");
-		}
-		else
-		{
-			DEBUG_INFO("Error: unable to rename the chargingProfile file");
-		}
-#endif
 		result = TRUE;
 		sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Accepted] );
 	}
@@ -15378,6 +15337,7 @@ void GetChargingProfileRequest(int gunindex)
 	//*****************************ChargePointMaxProfile******************************************/
 	strcpy(fname, ChargePointMaxProfile_JSON);
 	ChargePointMaxProfileIsNull=TRUE;
+
 	if((access(ChargePointMaxProfile_JSON,F_OK))!=-1)
 	{
 	  	fptr1 = fopen(fname, "r");
@@ -15716,7 +15676,7 @@ void GetChargingProfileRequest(int gunindex)
 	  			c = 0;
 	  			loc = strstr(SchedulePeriodList[i], "limit");
 	  			memset(sstr ,0, sizeof(sstr) );
-	  			while (loc[strlen("limit")+2+c] != ',')
+	  			while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
 	  			{
 	  				sstr[c] = loc[strlen("limit")+2+c];
 	  				//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -15729,14 +15689,23 @@ void GetChargingProfileRequest(int gunindex)
 	  			c = 0;
 	  			loc = strstr(SchedulePeriodList[i], "numberPhases");
 	  			memset(sstr ,0, sizeof(sstr) );
-	  			while (loc[strlen("numberPhases")+2+c] != '}')
+
+	  			if(loc != NULL)
 	  			{
-	  				sstr[c] = loc[strlen("numberPhases")+2+c];
-	  				//printf("i=%d sstr=%c\n",c, sstr[c]);
-	  				c++;
+	  				while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+	  				{
+	  					sstr[c] = loc[strlen("numberPhases")+2+c];
+	  					//printf("i=%d sstr=%c\n",c, sstr[c]);
+	  					c++;
+	  				}
+	  				sstr[c] = '\0';
+	  				tempNumberPhasesInt = atoi(sstr);
+
+	  			}
+	  			else
+	  			{
+	  				tempNumberPhasesInt = 0;
 	  			}
-	  			sstr[c] = '\0';
-	  			tempNumberPhasesInt = atoi(sstr);
 
 	  			if(j == 0)
 	  			{
@@ -15784,26 +15753,7 @@ void GetChargingProfileRequest(int gunindex)
 
 
 	  //****************************TxDefaultProfile************************************************/
-#if 0
-	  switch(gunindex + 1)
-	  {
-	  	  case 0:
-	  		  strcpy(fname, TxDefaultProfile_0_JSON );
-	  		  break;
 
-	  	  case 1:
-	  		  strcpy(fname, TxDefaultProfile_1_JSON );
-	  		  break;
-
-	  	  case 2:
-	  		  strcpy(fname, TxDefaultProfile_2_JSON );
-	  		  break;
-
-	  	  default:
-	  		  strcpy(fname, TxDefaultProfile_1_JSON );
-	  		  break;
-	  }
-#endif
 	  memset(fname, 0, sizeof fname);
 	  sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", (gunindex + 1));
 
@@ -16112,7 +16062,7 @@ void GetChargingProfileRequest(int gunindex)
 	  	  		  c = 0;
 	  	  		  loc = strstr(SchedulePeriodList[i], "limit");
 	  	  		  memset(sstr ,0, sizeof(sstr) );
-	  	  		  while (loc[strlen("limit")+2+c] != ',')
+	  	  		  while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
 	  	  		  {
 	  	  			  sstr[c] = loc[strlen("limit")+2+c];
 	  	  			  //printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -16125,14 +16075,22 @@ void GetChargingProfileRequest(int gunindex)
 	  	  		  c = 0;
 	  	  		  loc = strstr(SchedulePeriodList[i], "numberPhases");
 	  	  		  memset(sstr ,0, sizeof(sstr) );
-	  	  		  while (loc[strlen("numberPhases")+2+c] != '}')
+
+	  	  		  if(loc != NULL)
 	  	  		  {
-	  	  			  sstr[c] = loc[strlen("numberPhases")+2+c];
-	  	  			  //printf("i=%d sstr=%c\n",c, sstr[c]);
-	  	  			  c++;
+	  	  			  while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+	  	  			  {
+	  	  			  	  sstr[c] = loc[strlen("numberPhases")+2+c];
+	  	  			  	  //printf("i=%d sstr=%c\n",c, sstr[c]);
+	  	  			  	  c++;
+	  	  			  }
+	  	  			  sstr[c] = '\0';
+	  	  			  tempNumberPhasesInt = atoi(sstr);
+	  	  		  }
+	  	  		  else
+	  	  		  {
+	  	  			tempNumberPhasesInt = 0;
 	  	  		  }
-	  	  		  sstr[c] = '\0';
-	  	  		  tempNumberPhasesInt = atoi(sstr);
 
 	  	  		  if(j == 0)
 	  	  		  {
@@ -16219,25 +16177,7 @@ void GetChargingProfileRequest(int gunindex)
 	  }// the end of ACCESS TxDefaultProfile
 
 	  	//****************************TxProfile************************************************/
-#if 0
-	  	switch(gunindex + 1)
-	  	{
-	  		case 0:
-	  		break;
-
-	  		case 1:
-	  			strcpy(fname, TxProfile_1_JSON );
-	  		break;
-
-	  		case 2:
-	  			strcpy(fname, TxProfile_2_JSON );
-	  		break;
 
-	  		default:
-	  			strcpy(fname, TxProfile_1_JSON );
-	  		break;
-	  	}
-#endif
 	  	memset(fname, 0, sizeof fname);
 	  	sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", (gunindex + 1));
 
@@ -16570,7 +16510,7 @@ void GetChargingProfileRequest(int gunindex)
 	  				c = 0;
 	  				loc = strstr(SchedulePeriodList[i], "limit");
 	  				memset(sstr ,0, sizeof(sstr) );
-	  				while (loc[strlen("limit")+2+c] != ',')
+	  				while ((loc[strlen("limit")+2+c] != ',')&&(loc[strlen("limit")+2+c] != '}'))
 	  				{
 	  				  	sstr[c] = loc[strlen("limit")+2+c];
 	  				  	//printf("i=%d sstr=%c\n",c, sstr[c]);
@@ -16583,15 +16523,22 @@ void GetChargingProfileRequest(int gunindex)
 	  				c = 0;
 	  				loc = strstr(SchedulePeriodList[i], "numberPhases");
 	  				memset(sstr ,0, sizeof(sstr) );
-	  				while (loc[strlen("numberPhases")+2+c] != '}')
+
+	  				if(loc != NULL)
 	  				{
-	  					sstr[c] = loc[strlen("numberPhases")+2+c];
-	  				  	//printf("i=%d sstr=%c\n",c, sstr[c]);
-	  				  	c++;
+	  					while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
+	  					{
+	  						sstr[c] = loc[strlen("numberPhases")+2+c];
+	  						 //printf("i=%d sstr=%c\n",c, sstr[c]);
+	  						c++;
+	  					}
+	  					sstr[c] = '\0';
+	  					tempNumberPhasesInt = atoi(sstr);
+	  				}
+	  				else
+	  				{
+	  					tempNumberPhasesInt = 0;
 	  				}
-	  				sstr[c] = '\0';
-	  				tempNumberPhasesInt = atoi(sstr);
-
 
 	  				//TxProfile.Duration = durationInt;
 	  				TxProfile.TotalPeriod = n_SchedulePeriods;

+ 15 - 6
EVSE/rootfs/var/www/set_system.php

@@ -23,6 +23,13 @@
 	$connectorType1=ConnectorType($Connector1);
 	$connectorType2=ConnectorType($Connector2);
 	$connectorType3=ConnectorType($Connector3);
+	$IsAcDc = substr($ModelName,0,1);
+	$PsuQuantity = 0;
+	if($IsAcDc == "D"){
+		if($RatingPower>=30){
+			$PsuQuantity = $RatingPower/30;
+		}
+	}
 	function ConnectorType($connector){
 		$result="";
 		if($connector == "0"){
@@ -214,16 +221,18 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'CsuPrimFwRev'};?>">
 											<input type="hidden" name="CsuPrimFwRev" id="CsuPrimFwRev" value="<?php echo $obj->{'CsuPrimFwRev'};?>">
 										</div>
+<?php									for($i=0;$i<$PsuQuantity;$i++){?>
 										<div class="form-group" style="display:<?php echo $am001;?>">
-											<label>Psu Prim Fw Rev</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'PsuPrimFwRev'};?>">
-											<input type="hidden" name="PsuPrimFwRev" id="PsuPrimFwRev" value="<?php echo $obj->{'PsuPrimFwRev'};?>">
+											<label>Psu Prim Fw Rev(<?php echo $i+1;?>)</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'FwPrimaryVersion'}[$i];?>">
+											<input type="hidden" name="PsuPrimFwRev<?php echo $i;?>" id="PsuPrimFwRev<?php echo $i;?>" value="<?php echo $obj->{'FwPrimaryVersion'}[$i];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am001;?>">
-											<label>Psu Sec Fw Rev</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'PsuSecFwRev'};?>">
-											<input type="hidden" name="PsuSecFwRev" id="PsuSecFwRev" value="<?php echo $obj->{'PsuSecFwRev'};?>">
+											<label>Psu Sec Fw Rev(<?php echo $i+1;?>)</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'FwSecondVersion'}[$i];?>">
+											<input type="hidden" name="PsuSecFwRev<?php echo $i;?>" id="PsuSecFwRev<?php echo $i;?>" value="<?php echo $obj->{'FwSecondVersion'}[$i];?>">
 										</div>
+<?php } ?>
 										<div class="form-group" style="display:<?php echo $am001;?>">
 											<label>Fan Module Fw Rev</label>
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'FanModuleFwRev'};?>">