|
@@ -48,22 +48,22 @@
|
|
|
#define TRUE 1 // Option 1
|
|
|
|
|
|
//ChargePointMaxProfile
|
|
|
-#define ChargePointMaxProfile_JSON "../Storage/OCPP/ChargePointMaxProfile.json"
|
|
|
+#define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile.json"
|
|
|
|
|
|
//TxDefaultProfile
|
|
|
-#define TxDefaultProfile_0_JSON "../Storage/OCPP/TxDefaultProfile_0.json"
|
|
|
-#define TxDefaultProfile_1_JSON "../Storage/OCPP/TxDefaultProfile_1.json"
|
|
|
-#define TxDefaultProfile_2_JSON "../Storage/OCPP/TxDefaultProfile_2.json"
|
|
|
+#define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0.json"
|
|
|
+#define TxDefaultProfile_1_JSON "/Storage/OCPP/TxDefaultProfile_1.json"
|
|
|
+#define TxDefaultProfile_2_JSON "/Storage/OCPP/TxDefaultProfile_2.json"
|
|
|
|
|
|
//TxProfile
|
|
|
-#define TxProfile_1_JSON "../Storage/OCPP/TxProfile_1.json"
|
|
|
-#define TxProfile_2_JSON "../Storage/OCPP/TxProfile_2.json"
|
|
|
+#define TxProfile_1_JSON "/Storage/OCPP/TxProfile_1.json"
|
|
|
+#define TxProfile_2_JSON "/Storage/OCPP/TxProfile_2.json"
|
|
|
|
|
|
-#define ChargingProfile_0_JSON "../Storage/OCPP/chargingprofile_0.json"
|
|
|
-#define ChargingProfile_1_JSON "../Storage/OCPP/chargingprofile_1.json"
|
|
|
-#define ChargingProfile_2_JSON "../Storage/OCPP/chargingprofile_2.json"
|
|
|
-#define AuthorizationCache_JSON "../Storage/OCPP/AuthorizationCache.json"
|
|
|
-#define LocalAuthorizationList_JSON "../Storage/OCPP/LocalAuthorizationList.json"
|
|
|
+#define ChargingProfile_0_JSON "/Storage/OCPP/chargingprofile_0.json"
|
|
|
+#define ChargingProfile_1_JSON "/Storage/OCPP/chargingprofile_1.json"
|
|
|
+#define ChargingProfile_2_JSON "/Storage/OCPP/chargingprofile_2.json"
|
|
|
+#define AuthorizationCache_JSON "/Storage/OCPP/AuthorizationCache.json"
|
|
|
+#define LocalAuthorizationList_JSON "/Storage/OCPP/LocalAuthorizationList.json"
|
|
|
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
@@ -1280,7 +1280,7 @@ void CheckSystemValue(void)
|
|
|
//==============================================
|
|
|
// Charger start transaction
|
|
|
//==============================================
|
|
|
- if((server_sign == TRUE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq == 1))
|
|
|
+ if(/*(server_sign == TRUE) &&*/ (ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq == 1))
|
|
|
{
|
|
|
sendStartTransactionRequest(gun_index);
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq =0;
|
|
@@ -1291,7 +1291,7 @@ void CheckSystemValue(void)
|
|
|
//==============================================
|
|
|
// Charger stop transaction
|
|
|
//==============================================
|
|
|
- if((server_sign == TRUE) && ((ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 1)))
|
|
|
+ if(/*(server_sign == TRUE) &&*/ ((ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 1)))
|
|
|
{
|
|
|
sendStopTransactionRequest(gun_index);
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq =0;
|
|
@@ -1387,7 +1387,7 @@ void CheckSystemValue(void)
|
|
|
//==============================================
|
|
|
// Meter report
|
|
|
//==============================================
|
|
|
- if((server_sign == TRUE) && ((time((time_t*)NULL) - clientTime.MeterValues[gun_index])> (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 ) ) )
|
|
|
+ if(/*(server_sign == TRUE) &&*/ ((time((time_t*)NULL) - clientTime.MeterValues[gun_index])> (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 ) ) )
|
|
|
{
|
|
|
//check Transaction active
|
|
|
if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
|
|
@@ -1402,7 +1402,7 @@ void CheckSystemValue(void)
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
|
|
|
{
|
|
|
- sprintf(filenmae,"../Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ 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");
|
|
@@ -1424,7 +1424,7 @@ void CheckSystemValue(void)
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
|
|
|
{
|
|
|
- sprintf(filenmae,"../Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ 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");
|
|
@@ -1446,7 +1446,7 @@ void CheckSystemValue(void)
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
|
|
|
{
|
|
|
- sprintf(filenmae,"../Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ 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");
|
|
@@ -1469,7 +1469,7 @@ void CheckSystemValue(void)
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
|
|
|
{
|
|
|
- sprintf(filenmae,"../Storage/OCPP/TxProfile_%d.json",(gun_index+1));
|
|
|
+ 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");
|
|
@@ -4218,8 +4218,9 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
int connectorIsNULL = FALSE;
|
|
|
int chargingProfilePurposeIsNULL = FALSE;
|
|
|
int stackLevelIsNULL = FALSE;
|
|
|
+ int GotoEnd = FALSE;
|
|
|
FILE *fptr1, *fptr2;
|
|
|
- char temp[] = "../Storage/OCPP/ClearChargingProfiletemp.json";
|
|
|
+ char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json";
|
|
|
int n_chargingProfile=0;
|
|
|
char sLineWord[1060]={0};
|
|
|
|
|
@@ -4319,10 +4320,10 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
strcpy(fname, ChargePointMaxProfile_JSON);
|
|
|
}
|
|
|
- // else
|
|
|
- // {
|
|
|
- // strcpy(fname, TxDefaultProfile_0_JSON);
|
|
|
- // }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy(fname, TxDefaultProfile_0_JSON);
|
|
|
+ }
|
|
|
|
|
|
break;
|
|
|
|
|
@@ -4379,7 +4380,14 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
|
|
|
if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
|
|
|
{
|
|
|
- //clear the whole contents of a file in C
|
|
|
+ //clear file in C
|
|
|
+ sprintf(str,"rm -f %s",fname);
|
|
|
+ system(str);
|
|
|
+
|
|
|
+ // clear temp file
|
|
|
+ sprintf(str,"rm -f %s",temp);
|
|
|
+ system(str);
|
|
|
+#if 0
|
|
|
fclose(fopen(ChargePointMaxProfile_JSON, "w"));
|
|
|
fclose(fopen(TxDefaultProfile_0_JSON, "w"));
|
|
|
fclose(fopen(TxDefaultProfile_1_JSON, "w"));
|
|
@@ -4387,12 +4395,9 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
|
|
|
fclose(fopen(TxProfile_1_JSON, "w"));
|
|
|
fclose(fopen(TxProfile_2_JSON, "w"));
|
|
|
-#if 0
|
|
|
- fclose(fopen(ChargingProfile_0_JSON, "w"));
|
|
|
- fclose(fopen(ChargingProfile_1_JSON, "w"));
|
|
|
- fclose(fopen(ChargingProfile_2_JSON, "w"));
|
|
|
#endif
|
|
|
sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
|
|
|
+ goto end;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -4483,7 +4488,23 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
if((connectorIsNULL == FALSE) && (connectorIdInt != 0) && ( connectorIdInt == tempconnectorIdInt))
|
|
|
{
|
|
|
- if((stackLevelIsNULL == TRUE)||((stackLevelIsNULL == FALSE)&& (tempstackLevelInt == stackLevelInt)))
|
|
|
+ if(stackLevelIsNULL == TRUE)//((stackLevelIsNULL == TRUE)||((stackLevelIsNULL == FALSE)&& (tempstackLevelInt == stackLevelInt)))
|
|
|
+ {
|
|
|
+ fclose(fptr1);
|
|
|
+ fclose(fptr2);
|
|
|
+ sprintf(str,"rm -f %s",fname);
|
|
|
+ system(str);
|
|
|
+
|
|
|
+ // clear temp file
|
|
|
+ sprintf(str,"rm -f %s",temp);
|
|
|
+ system(str);
|
|
|
+ sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
|
|
|
+ clearflag = TRUE;
|
|
|
+ GotoEnd = TRUE;
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if((stackLevelIsNULL == FALSE)&& (tempstackLevelInt == stackLevelInt))
|
|
|
{
|
|
|
sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
|
|
|
clearflag = TRUE;
|
|
@@ -4517,9 +4538,16 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
memset(sLineWord, 0, sizeof sLineWord);
|
|
|
}
|
|
|
|
|
|
- if(clearflag == FALSE)
|
|
|
+
|
|
|
+ if((clearflag == FALSE) && (GotoEnd == TRUE))
|
|
|
{
|
|
|
sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Unknown] );
|
|
|
+ sprintf(str,"rm -f %s",temp);
|
|
|
+ system(str);
|
|
|
+ goto end;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
@@ -8273,7 +8301,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
//int lno=0;//, linectr = 0;
|
|
|
//int modifyflag = FALSE;
|
|
|
char filename[MAX]={0};
|
|
|
- char tempfile[] = "../Storage/OCPP/temp.json";
|
|
|
+ char tempfile[] = "/Storage/OCPP/temp.json";
|
|
|
//int resultRename=0;
|
|
|
char rmFileCmd[50]={0};
|
|
|
char tempchargingProfilePurposeStr[30]={0};
|
|
@@ -9738,7 +9766,7 @@ void handleAuthorizeResponse(char *payload, int gun_index)
|
|
|
int parentIdTagISNULL=FALSE;
|
|
|
char sstr[160]={ 0 };
|
|
|
char* filename = AuthorizationCache_JSON;
|
|
|
- char tempfile[] = "../Storage/OCPP/temp.json";
|
|
|
+ char tempfile[] = "/Storage/OCPP/temp.json";
|
|
|
int c = 0;
|
|
|
char *loc;
|
|
|
int resultRename=0;
|
|
@@ -10811,7 +10839,7 @@ int initialConfigurationTable(void)
|
|
|
char keystr[60]={0};
|
|
|
char readonlystr[10]={0};
|
|
|
char valuestr[100]={0};
|
|
|
- fp = fopen("../Storage/OCPP/OCPPConfiguration" , "r");
|
|
|
+ fp = fopen("/Storage/OCPP/OCPPConfiguration" , "r");
|
|
|
if(fp == NULL) {
|
|
|
DEBUG_INFO("Error opening file");
|
|
|
return FALSE;
|
|
@@ -11182,7 +11210,7 @@ int initialConfigurationTable(void)
|
|
|
void StoreConfigurationTable(void)
|
|
|
{
|
|
|
FILE *outfile;
|
|
|
- outfile = fopen("../Storage/OCPP/OCPPConfiguration" , "w+");
|
|
|
+ outfile = fopen("/Storage/OCPP/OCPPConfiguration" , "w+");
|
|
|
if(outfile == NULL)
|
|
|
{
|
|
|
DEBUG_INFO("Error opening file");
|
|
@@ -14309,6 +14337,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
memset(&ChargePointMaxProfile,0,sizeof(struct StructProfile));
|
|
|
memset(&TxDefaultProfile,0,sizeof(struct StructProfile));
|
|
|
memset(&TxProfile,0,sizeof(struct StructProfile));
|
|
|
+ memset(&ShmOCPP16Data->SmartChargingProfile[gunindex],0,sizeof(struct StructChargingProfile));
|
|
|
|
|
|
DEBUG_INFO("GetChargingProfileRequest\n");
|
|
|
|
|
@@ -14530,6 +14559,26 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
strcpy(tempvalidFromStr,"");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //***********validTo **************/
|
|
|
+ c = 0;
|
|
|
+ loc = strstr(sLineWord, "validTo");
|
|
|
+ if(loc != NULL)
|
|
|
+ {
|
|
|
+ memset(sstr ,0, sizeof(sstr) );
|
|
|
+ while (loc[3+strlen("validTo")+c] != '\"')
|
|
|
+ {
|
|
|
+ sstr[c] = loc[3+strlen("validTo")+c];
|
|
|
+ c++;
|
|
|
+ }
|
|
|
+ sstr[c] = '\0';
|
|
|
+ strcpy(tempvalidToStr,sstr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy(tempvalidToStr,"");
|
|
|
+ }
|
|
|
+
|
|
|
//***********duration**************/
|
|
|
c = 0;
|
|
|
loc = strstr(sLineWord, "duration");
|
|
@@ -14706,6 +14755,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
switch(gunindex + 1)
|
|
|
{
|
|
|
case 0:
|
|
|
+ strcpy(fname, TxDefaultProfile_0_JSON );
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
@@ -14903,7 +14953,26 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
strcpy(tempvalidFromStr,"");
|
|
|
}
|
|
|
|
|
|
- //***********validFrom**************/
|
|
|
+ //***********validTo **************/
|
|
|
+ c = 0;
|
|
|
+ loc = strstr(sLineWord, "validTo");
|
|
|
+ if(loc != NULL)
|
|
|
+ {
|
|
|
+ memset(sstr ,0, sizeof(sstr) );
|
|
|
+ while (loc[3+strlen("validTo")+c] != '\"')
|
|
|
+ {
|
|
|
+ sstr[c] = loc[3+strlen("validTo")+c];
|
|
|
+ c++;
|
|
|
+ }
|
|
|
+ sstr[c] = '\0';
|
|
|
+ strcpy(tempvalidToStr,sstr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy(tempvalidToStr,"");
|
|
|
+ }
|
|
|
+
|
|
|
+ //***********duration**************/
|
|
|
c = 0;
|
|
|
loc = strstr(sLineWord, "duration");
|
|
|
if(loc != NULL)
|
|
@@ -15340,6 +15409,24 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
strcpy(tempvalidFromStr,"");
|
|
|
}
|
|
|
|
|
|
+ //***********validTo**************/
|
|
|
+ c = 0;
|
|
|
+ loc = strstr(sLineWord, "validTo");
|
|
|
+ if(loc != NULL)
|
|
|
+ {
|
|
|
+ memset(sstr ,0, sizeof(sstr) );
|
|
|
+ while (loc[3+strlen("validTo")+c] != '\"')
|
|
|
+ {
|
|
|
+ sstr[c] = loc[3+strlen("validTo")+c];
|
|
|
+ c++;
|
|
|
+ }
|
|
|
+ sstr[c] = '\0';
|
|
|
+ strcpy(tempvalidToStr,sstr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy(tempvalidToStr,"");
|
|
|
+ }
|
|
|
|
|
|
//***********duration**************/
|
|
|
c = 0;
|
|
@@ -15645,6 +15732,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = TxDefaultProfile_TEMP.StackLevel;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = TxDefaultProfile_TEMP.ChargingSchedule.Duration;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = TxDefaultProfile_TEMP.ChargingSchedule.MinChargingRate;
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)TxDefaultProfile_TEMP.ChargingSchedule.ChargingRateUnit );
|
|
|
strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)TxDefaultProfile_TEMP.ChargingProfileKind );
|
|
|
strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)TxDefaultProfile_TEMP.ChargingProfilePurpose );
|
|
|
strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule, (const char *)TxDefaultProfile_TEMP.ChargingSchedule.StartSchedule);
|
|
@@ -15675,6 +15763,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = ChargePointMaxProfile_TEMP.StackLevel;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = 86400 ;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = ChargePointMaxProfile_TEMP.ChargingSchedule.MinChargingRate;
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)ChargePointMaxProfile_TEMP.ChargingSchedule.ChargingRateUnit );
|
|
|
strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)ChargePointMaxProfile_TEMP.ChargingProfileKind );
|
|
|
strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)ChargePointMaxProfile_TEMP.ChargingProfilePurpose );
|
|
|
strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule, (const char *)ChargePointMaxProfile_TEMP.ChargingSchedule.StartSchedule);
|