|
@@ -6258,19 +6258,18 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
- {
|
|
|
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
- if((access(filenmae,F_OK))!=-1)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_IDLE)))
|
|
|
{
|
|
|
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
+ sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ if((access(filenmae,F_OK))!=-1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
|
|
|
- sprintf(str,"rm -f %s",filenmae);
|
|
|
- system(str);
|
|
|
+ sprintf(str,"rm -f %s",filenmae);
|
|
|
+ system(str);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
|
|
@@ -6313,16 +6312,16 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
- {
|
|
|
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
- if((access(filenmae,F_OK))!=-1)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_IDLE)))
|
|
|
{
|
|
|
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
- sprintf(str,"rm -f %s",filenmae);
|
|
|
- system(str);
|
|
|
+ sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ if((access(filenmae,F_OK))!=-1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
+ sprintf(str,"rm -f %s",filenmae);
|
|
|
+ system(str);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -6366,16 +6365,16 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
- {
|
|
|
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
- if((access(filenmae,F_OK))!=-1)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_IDLE)))
|
|
|
{
|
|
|
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
- sprintf(str,"rm -f %s",filenmae);
|
|
|
- system(str);
|
|
|
+ sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ if((access(filenmae,F_OK))!=-1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
+ sprintf(str,"rm -f %s",filenmae);
|
|
|
+ system(str);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -6412,16 +6411,16 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE))
|
|
|
- {
|
|
|
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
- if((access(filenmae,F_OK))!=-1)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_IDLE)))
|
|
|
{
|
|
|
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
- sprintf(str,"rm -f %s",filenmae);
|
|
|
- system(str);
|
|
|
+ sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ if((access(filenmae,F_OK))!=-1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
+ sprintf(str,"rm -f %s",filenmae);
|
|
|
+ system(str);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -6464,17 +6463,17 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
- {
|
|
|
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
- if((access(filenmae,F_OK))!=-1)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_IDLE)))
|
|
|
{
|
|
|
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
+ sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ if((access(filenmae,F_OK))!=-1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
|
|
|
- sprintf(str,"rm -f %s",filenmae);
|
|
|
- system(str);
|
|
|
+ sprintf(str,"rm -f %s",filenmae);
|
|
|
+ system(str);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -15524,13 +15523,14 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
|
int result = FAIL;
|
|
|
- int8_t gun_index = -1;
|
|
|
+ struct SetChargingProfile_20 SetProfileReq = {0};
|
|
|
+ uint8_t isLostConnectorId = FALSE;
|
|
|
uint8_t isPeriodOverMax = FALSE;
|
|
|
uint8_t isProfileOverMax = FALSE;
|
|
|
uint8_t isConnectorMismatch = FALSE;
|
|
|
uint8_t existProfileQuantity = 0;
|
|
|
uint8_t filename[128]={0};
|
|
|
- uint8_t word[2048]={0};
|
|
|
+ uint8_t dataLine[4096]={0};
|
|
|
FILE *filePtr;
|
|
|
json_object *SetChargingProfile;
|
|
|
|
|
@@ -15540,12 +15540,17 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
|
|
|
if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
|
|
|
- {
|
|
|
- gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
|
|
|
- }
|
|
|
+ SetProfileReq.evseId = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
|
|
|
+ else
|
|
|
+ isLostConnectorId = TRUE;
|
|
|
+
|
|
|
+ if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id") != NULL)
|
|
|
+ SetProfileReq.chargingProfile.id = json_object_get_int((json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id")));
|
|
|
|
|
|
if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
|
|
|
{
|
|
|
+ sprintf((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
|
|
|
+
|
|
|
|
|
|
if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
|
|
|
{
|
|
@@ -15555,7 +15560,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
|
|
|
if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
|
|
|
{
|
|
|
- if(gun_index == 0)
|
|
|
+ if(SetProfileReq.evseId == 0)
|
|
|
{
|
|
|
sprintf((char*)filename, ChargePointMaxProfile_JSON);
|
|
|
filePtr = fopen((char*)filename, "r");
|
|
@@ -15567,10 +15572,10 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- while(fscanf(filePtr, "%s", word) != EOF)
|
|
|
+ while(fscanf(filePtr, "%s", dataLine) != EOF)
|
|
|
{
|
|
|
|
|
|
- if(strstr((char*)word, "chargingProfileId")!= NULL)
|
|
|
+ if(strstr((char*)dataLine, "chargingProfileId")!= NULL)
|
|
|
{
|
|
|
existProfileQuantity += 1;
|
|
|
}
|
|
@@ -15583,38 +15588,70 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
|
|
|
{
|
|
|
- if(gun_index < 5)
|
|
|
- sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
|
|
|
- else
|
|
|
+ if((0 < SetProfileReq.evseId) && (SetProfileReq.evseId > gunTotalNumber))
|
|
|
isConnectorMismatch = TRUE;
|
|
|
|
|
|
if(!isConnectorMismatch)
|
|
|
{
|
|
|
- filePtr = fopen((char*)filename, "r");
|
|
|
- if (!filePtr)
|
|
|
+ if(SetProfileReq.evseId == 0)
|
|
|
{
|
|
|
- DEBUG_INFO("%s not exist, create it.\n", filename);
|
|
|
- filePtr = fopen((char*)filename, "w+");
|
|
|
+ int tmpExistProfileQuantity;
|
|
|
+
|
|
|
+ for(int idxCon=1;idxCon<=gunTotalNumber;idxCon++)
|
|
|
+ {
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
|
|
|
+ filePtr = fopen((char*)filename, "r");
|
|
|
+ if (!filePtr)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("%s not exist, create it.\n", filename);
|
|
|
+ filePtr = fopen((char*)filename, "w+");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ while(fscanf(filePtr, "%s", dataLine) != EOF)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(strstr((char*)dataLine, "chargingProfileId")!= NULL)
|
|
|
+ {
|
|
|
+ tmpExistProfileQuantity += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fclose(filePtr);
|
|
|
+
|
|
|
+ existProfileQuantity = (existProfileQuantity < tmpExistProfileQuantity) ? tmpExistProfileQuantity : existProfileQuantity;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- while(fscanf(filePtr, "%s", word) != EOF)
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
|
|
|
+ filePtr = fopen((char*)filename, "r");
|
|
|
+ if (!filePtr)
|
|
|
{
|
|
|
-
|
|
|
- if(strstr((char*)word, "chargingProfileId")!= NULL)
|
|
|
+ DEBUG_INFO("%s not exist, create it.\n", filename);
|
|
|
+ filePtr = fopen((char*)filename, "w+");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ while(fscanf(filePtr, "%s", dataLine) != EOF)
|
|
|
{
|
|
|
- existProfileQuantity += 1;
|
|
|
+
|
|
|
+ if(strstr((char*)dataLine, "chargingProfileId")!= NULL)
|
|
|
+ {
|
|
|
+ existProfileQuantity += 1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ fclose(filePtr);
|
|
|
}
|
|
|
- fclose(filePtr);
|
|
|
}
|
|
|
}
|
|
|
else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
|
|
|
{
|
|
|
- if(gun_index>0)
|
|
|
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
|
|
|
+ if((SetProfileReq.evseId > 0) && (SetProfileReq.evseId <= gunTotalNumber))
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
|
|
|
else
|
|
|
isConnectorMismatch = TRUE;
|
|
|
|
|
@@ -15629,10 +15666,10 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- while(fscanf(filePtr, "%s", word) != EOF)
|
|
|
+ while(fscanf(filePtr, "%s", dataLine) != EOF)
|
|
|
{
|
|
|
|
|
|
- if(strstr((char*)word, "chargingProfileId")!= NULL)
|
|
|
+ if(strstr((char*)dataLine, "chargingProfileId")!= NULL)
|
|
|
{
|
|
|
existProfileQuantity += 1;
|
|
|
}
|
|
@@ -15643,188 +15680,139 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
+ * TODO:
|
|
|
+ *
|
|
|
+ */
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
+ {}
|
|
|
|
|
|
if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
|
|
|
isProfileOverMax = TRUE;
|
|
|
}
|
|
|
|
|
|
|
|
|
- if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
|
|
|
+ if(!isLostConnectorId && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
|
|
|
{
|
|
|
FILE *infile;
|
|
|
FILE *outfile;
|
|
|
- char tmpProfileName[32];
|
|
|
+ char tmpProfileName[] = "/Storage/OCPP/SetChargingProfiletemp_OCPP20.json";
|
|
|
char rmFileCmd[128];
|
|
|
- char tempchargingProfilePurposeStr[30]={0};
|
|
|
- int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
|
|
|
-
|
|
|
- sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
|
|
|
- infile = fopen ((char*)filename, "r");
|
|
|
- outfile = fopen ((char*)tmpProfileName, "w");
|
|
|
+ int tempchargingProfileIdInt;
|
|
|
+ int chkChar;
|
|
|
|
|
|
- int d = fgetc(infile);
|
|
|
- rewind(infile);
|
|
|
-
|
|
|
- if(d == EOF)
|
|
|
+ for(int idxCon=1; idxCon <= (SetProfileReq.evseId==0?gunTotalNumber:1); idxCon++)
|
|
|
{
|
|
|
-
|
|
|
- fprintf(outfile,"%s\n", payload);
|
|
|
-
|
|
|
- fclose(infile);
|
|
|
- fclose(outfile);
|
|
|
+ if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == 0)
|
|
|
+ {
|
|
|
+ sprintf((char*)filename, "%s", ChargePointMaxProfile_JSON);
|
|
|
+ }
|
|
|
+ else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0)
|
|
|
+ {
|
|
|
+ if(SetProfileReq.evseId==0)
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
|
|
|
+ else
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
|
|
|
+ }
|
|
|
+ else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) == 0)
|
|
|
+ {
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ * TODO:
|
|
|
+ *
|
|
|
+ */
|
|
|
+ }
|
|
|
|
|
|
- sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
- system(rmFileCmd);
|
|
|
|
|
|
- rename((char*)tmpProfileName, (char*)filename);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- char buf[2048]={0};
|
|
|
- int ChargingProfileAdded = FALSE;
|
|
|
+ infile = fopen ((char*)filename, "r");
|
|
|
+ outfile = fopen ((char*)tmpProfileName, "w");
|
|
|
|
|
|
- while (fgets(buf, sizeof(buf), infile) != NULL)
|
|
|
+ chkChar = fgetc(infile);
|
|
|
+ rewind(infile);
|
|
|
+ if(chkChar == EOF)
|
|
|
{
|
|
|
- buf[strlen(buf) - 1] = '\0';
|
|
|
+
|
|
|
+ if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
|
|
|
+ json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
|
|
|
+ fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
|
|
|
|
|
|
- json_object *tmpChargingProfile;
|
|
|
- tmpChargingProfile = json_tokener_parse(buf);
|
|
|
- if(!is_error(tmpChargingProfile))
|
|
|
- {
|
|
|
- if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
|
|
|
- {
|
|
|
- tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
|
|
|
- }
|
|
|
+ fclose(infile);
|
|
|
+ fclose(outfile);
|
|
|
|
|
|
- if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
|
|
|
- {
|
|
|
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
|
|
|
- {
|
|
|
- tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
|
|
|
- }
|
|
|
+ sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
+ system(rmFileCmd);
|
|
|
|
|
|
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
|
|
|
- {
|
|
|
- tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
|
|
|
- {
|
|
|
- strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- json_object_put(tmpChargingProfile);
|
|
|
+ rename((char*)tmpProfileName, (char*)filename);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ int ChargingProfileAdded = FALSE;
|
|
|
|
|
|
- if((tempconnectorIdInt == gun_index) &&
|
|
|
- (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
|
|
|
+ while (fgets((char*)dataLine, ARRAY_SIZE(dataLine), infile) != NULL)
|
|
|
{
|
|
|
- if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
|
|
|
- (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
|
|
|
- {
|
|
|
-
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ dataLine[strlen((char*)dataLine) - 1] = '\0';
|
|
|
+
|
|
|
+ json_object *tmpChargingProfile;
|
|
|
+ tmpChargingProfile = json_tokener_parse((char*)dataLine);
|
|
|
+ if(!is_error(tmpChargingProfile))
|
|
|
{
|
|
|
- if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if(json_object_object_get(tmpChargingProfile, "chargingProfile") != NULL)
|
|
|
{
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
+ if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id") != NULL)
|
|
|
{
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
+ tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id"));
|
|
|
+ DEBUG_INFO("tempchargingProfileIdInt: %d\n", tempchargingProfileIdInt);
|
|
|
+ DEBUG_INFO("SetProfileReq.chargingProfile.id: %d\n", SetProfileReq.chargingProfile.id);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
|
|
|
+ json_object_put(tmpChargingProfile);
|
|
|
+
|
|
|
+ if((tempchargingProfileIdInt == SetProfileReq.chargingProfile.id))
|
|
|
{
|
|
|
if(ChargingProfileAdded == FALSE)
|
|
|
{
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
+ if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
|
|
|
+ json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
|
|
|
+ fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
|
|
|
ChargingProfileAdded = TRUE;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ fprintf(outfile,"%s\n",dataLine);
|
|
|
if(ChargingProfileAdded == FALSE)
|
|
|
{
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
+ if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
|
|
|
+ json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
|
|
|
+ fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
|
|
|
ChargingProfileAdded = TRUE;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- fclose(infile);
|
|
|
- fclose(outfile);
|
|
|
+ fclose(infile);
|
|
|
+ fclose(outfile);
|
|
|
|
|
|
- sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
- system(rmFileCmd);
|
|
|
+ sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
+ system(rmFileCmd);
|
|
|
|
|
|
- rename((char*)tmpProfileName, (char*)filename);
|
|
|
+ rename((char*)tmpProfileName, (char*)filename);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
|
|
|
+ sleep(1);
|
|
|
+ sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
|
|
|
result = PASS;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(gun_index == -1)
|
|
|
+ if(isLostConnectorId)
|
|
|
DEBUG_WARN("Connector id is wrong.\n");
|
|
|
|
|
|
if(isConnectorMismatch)
|
|
@@ -15836,14 +15824,14 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
if(isProfileOverMax)
|
|
|
DEBUG_WARN("Profile quantity is over spec.\n");
|
|
|
|
|
|
- sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
|
|
|
+ sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
|
|
|
}
|
|
|
}
|
|
|
json_object_put(SetChargingProfile);
|
|
|
|
|
|
- if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
|
|
|
+ if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
|
|
|
{
|
|
|
- if(gun_index == 0)
|
|
|
+ if(SetProfileReq.evseId == 0)
|
|
|
{
|
|
|
for(uint8_t idx=0;idx<gunTotalNumber;idx++)
|
|
|
{
|
|
@@ -15851,10 +15839,10 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1], 0, TRUE);
|
|
|
+ checkCompositeSchedule(SetProfileReq.evseId, 86400, &ShmOCPP20Data->SmartChargingProfile[SetProfileReq.evseId-1], 0, TRUE);
|
|
|
}
|
|
|
|
|
|
- sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
|
|
|
+ sendSetChargingProfileConfirmation(uuid, (SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1));
|
|
|
system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
|
|
|
return result;
|
|
|
}
|