|
@@ -43,8 +43,6 @@
|
|
|
#include <mcheck.h>
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
#define PASS 1
|
|
|
#define FAIL -1
|
|
|
|
|
@@ -170,6 +168,7 @@ static struct OCPPAuthLocalElemet
|
|
|
// OCPP HeartBeat Response Not Receive Counts
|
|
|
//============================================
|
|
|
static int HeartBeatWithNOResponse = 0;
|
|
|
+static int HeartBeatCount = 0;
|
|
|
|
|
|
|
|
|
extern struct lws *wsi_client;
|
|
@@ -1857,6 +1856,7 @@ int sendBootNotificationRequest(void)
|
|
|
memset(queuedata, 0, sizeof(queuedata));
|
|
|
strcpy(queuedata,message);
|
|
|
|
|
|
+ HeartBeatCount = 0;
|
|
|
//#ifdef SystemLogMessage
|
|
|
//DEBUG_INFO(">>>>>BootNotification request\n");
|
|
|
//DEBUG_INFO("Message: %s\n", SendBuffer);
|
|
@@ -2049,11 +2049,6 @@ int sendHeartbeatRequest(int gun_index)
|
|
|
//DEBUG_ERROR("Heartbeat mapItem pass\n");
|
|
|
}
|
|
|
|
|
|
- //#ifdef SystemLogMessage
|
|
|
- //DEBUG_INFO(">>>>>Heartbeat request\n");
|
|
|
- //DEBUG_INFO("Message: %s\n", SendBuffer);
|
|
|
- //#endif
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -3515,7 +3510,7 @@ int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connector
|
|
|
diffSeconds = diff_i % 86400;//86400 seconds/day
|
|
|
}
|
|
|
|
|
|
- DEBUG_INFO("\n diff_f=%f \n",diff_f);
|
|
|
+ //DEBUG_INFO("\n diff_f=%f \n",diff_f);
|
|
|
|
|
|
CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
|
|
|
|
|
@@ -3808,7 +3803,7 @@ int sendSetChargingProfileConfirmation(char *uuid,char *payload)
|
|
|
//[3,"5748585f-8524-4fa6-9b4f-4a7eca750b90",{"status":"NotSupported"}]
|
|
|
char message[80]={0};
|
|
|
|
|
|
- DEBUG_ERROR("handleSetChargingProfileRequest\n");
|
|
|
+ DEBUG_INFO("sendSetChargingProfileConfirmation\n");
|
|
|
sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
|
|
|
LWS_Send(message);
|
|
|
result = TRUE;
|
|
@@ -3822,7 +3817,7 @@ int sendTriggerMessageConfirmation(char *uuid,char *payload)
|
|
|
int result = FAIL;
|
|
|
char message[80]={0};
|
|
|
|
|
|
- DEBUG_ERROR("sendTriggerMessageConfirmation\n");
|
|
|
+ DEBUG_INFO("sendTriggerMessageConfirmation\n");
|
|
|
sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
|
|
|
LWS_Send(message);
|
|
|
result = TRUE;
|
|
@@ -3837,7 +3832,7 @@ int sendUnlockConnectorConfirmation(char *uuid,char *payload)
|
|
|
char message[80]={0};
|
|
|
|
|
|
//[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
|
|
|
- DEBUG_ERROR("sendUnlockConnectorConfirmation\n");
|
|
|
+ DEBUG_INFO("sendUnlockConnectorConfirmation\n");
|
|
|
sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
|
|
|
LWS_Send(message);
|
|
|
result = TRUE;
|
|
@@ -3853,7 +3848,7 @@ int sendUpdateFirmwareConfirmation(char *uuid)
|
|
|
char message[60]={0};
|
|
|
|
|
|
//[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
|
|
|
- DEBUG_ERROR("sendUpdateFirmwareConfirmation\n");
|
|
|
+ DEBUG_INFO("sendUpdateFirmwareConfirmation\n");
|
|
|
sprintf(message,"[%d,\"%s\",{}]",MESSAGE_TYPE_CALLRESULT, uuid);
|
|
|
LWS_Send(message);
|
|
|
result = TRUE;
|
|
@@ -5725,7 +5720,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
int i = 0;
|
|
|
int j = 0;
|
|
|
while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
|
|
|
- DEBUG_INFO(" 1-1\n");
|
|
|
+ //DEBUG_INFO(" 1-1\n");
|
|
|
#if 0
|
|
|
/***********connectorId****************/
|
|
|
c = 0;
|
|
@@ -5831,7 +5826,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
time_t t = time(NULL);
|
|
|
diff_t = difftime(t, utc);
|
|
|
|
|
|
- DEBUG_INFO("diff_t=%f\n",diff_t);
|
|
|
+ //DEBUG_INFO("diff_t=%f\n",diff_t);
|
|
|
|
|
|
//parsing strings to words
|
|
|
i = 0;
|
|
@@ -5917,7 +5912,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
|
|
|
j = j + 1;
|
|
|
|
|
|
- DEBUG_INFO(" 1-2\n");
|
|
|
+ //DEBUG_INFO(" 1-2\n");
|
|
|
}
|
|
|
|
|
|
fclose(fptr1);
|
|
@@ -8397,7 +8392,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
//int modifyflag = FALSE;
|
|
|
char filename[MAX]={0};
|
|
|
char tempfile[] = "../Storage/OCPP/temp.json";
|
|
|
- int resultRename=0;
|
|
|
+ //int resultRename=0;
|
|
|
char rmFileCmd[50]={0};
|
|
|
char tempchargingProfilePurposeStr[30]={0};
|
|
|
|
|
@@ -8896,7 +8891,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
if (!fptr1)
|
|
|
{
|
|
|
//file not exist
|
|
|
- DEBUG_INFO("Unable to open the input file!!\n");
|
|
|
+ //DEBUG_INFO("Unable to open the input file!!\n");
|
|
|
fptr1 = fopen(filename, "w+");
|
|
|
|
|
|
}
|
|
@@ -9017,9 +9012,9 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
//*检测到文件结束标识返回1,否则返回0。*/
|
|
|
if(d == EOF)
|
|
|
{
|
|
|
- DEBUG_INFO("ChargingProfile content is NULL\n");
|
|
|
+ //DEBUG_INFO("ChargingProfile content is NULL\n");
|
|
|
|
|
|
- fprintf(outfile,"[%s]\n",payload);
|
|
|
+ fprintf(outfile,"%s\n",payload);
|
|
|
sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Accepted] );
|
|
|
|
|
|
|
|
@@ -9030,6 +9025,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
system(rmFileCmd);
|
|
|
|
|
|
+ rename(tempfile, filename);
|
|
|
+#if 0
|
|
|
resultRename = rename(tempfile, filename);
|
|
|
|
|
|
if(resultRename == 0)
|
|
@@ -9040,7 +9037,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
DEBUG_INFO("Error: unable to rename the chargingProfile file");
|
|
|
}
|
|
|
-
|
|
|
+#endif
|
|
|
//sprintf(rmFileCmd,"rm -f %s",tempfile);
|
|
|
//system(rmFileCmd);
|
|
|
}
|
|
@@ -9208,6 +9205,9 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
system(rmFileCmd);
|
|
|
|
|
|
+ rename(tempfile, filename);
|
|
|
+
|
|
|
+#if 0
|
|
|
resultRename = rename(tempfile, filename);
|
|
|
|
|
|
if(resultRename == 0)
|
|
@@ -9218,7 +9218,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
DEBUG_INFO("Error: unable to rename the chargingProfile file");
|
|
|
}
|
|
|
-
|
|
|
+#endif
|
|
|
result = TRUE;
|
|
|
sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Accepted] );
|
|
|
}
|
|
@@ -10246,7 +10246,13 @@ void handleHeartbeatResponse(char *payload, int gun_index)
|
|
|
char *loc;
|
|
|
//[3,"9c2e3c41-ab34-409e-8902-f5f48b6de641",{"currentTime":"2018-09-06T02:22:57.171Z"}]
|
|
|
|
|
|
- DEBUG_INFO("handleHeartbeatResponse ...\n");
|
|
|
+ if((HeartBeatCount%360) == 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("handleHeartbeatResponse ...\n");
|
|
|
+ DEBUG_INFO("After 1 hour, It will print out Heartbeat.\n");
|
|
|
+
|
|
|
+ }
|
|
|
+ HeartBeatCount = HeartBeatCount + 1;
|
|
|
c = 0;
|
|
|
loc = strstr(payload, "currentTime");
|
|
|
memset(sstr ,0, sizeof(sstr) );
|
|
@@ -14221,6 +14227,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
int period=0;
|
|
|
if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==FALSE) )
|
|
|
{
|
|
|
+ //TxProfile
|
|
|
strcpy(CurrentChargingProfileScheduleStr,TxProfileScheduleStr);
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxProfile_TEMP.ChargingProfileId;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = temptransactionId;
|
|
@@ -14301,6 +14308,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
}
|
|
|
else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==TRUE) )
|
|
|
{
|
|
|
+ //TxDefaultProfile
|
|
|
strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxDefaultProfile_TEMP.ChargingProfileId;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = 0;
|
|
@@ -14344,6 +14352,7 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
}
|
|
|
else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==TRUE) && (TxProfileIsNull==TRUE) )
|
|
|
{
|
|
|
+ //TxDefaultProfile
|
|
|
strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxDefaultProfile_TEMP.ChargingProfileId;
|
|
|
ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = 0;
|
|
@@ -14371,6 +14380,56 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ else if((TxDefaultProfileFileIsNull==TRUE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==TRUE) )
|
|
|
+ {
|
|
|
+ //ChargePointMaxProfile
|
|
|
+ strcpy(CurrentChargingProfileScheduleStr,ChargePointMaxProfileScheduleStr);
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = ChargePointMaxProfile_TEMP.ChargingProfileId;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = 0;
|
|
|
+ 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].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);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)ChargePointMaxProfile_TEMP.RecurrencyKind);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)ChargePointMaxProfile_TEMP.ValidFrom);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)ChargePointMaxProfile_TEMP.ValidTo);
|
|
|
+
|
|
|
+ for(int l=0; l < ChargePointMaxProfile.TotalPeriod;l++)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].Limit = ChargePointMaxProfile.Period[l].Limit;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = ChargePointMaxProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = ChargePointMaxProfile.Period[l].StartPeriod;
|
|
|
+
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if((TxDefaultProfileFileIsNull==TRUE) && (ChargePointMaxProfileIsNull==TRUE) && (TxProfileIsNull==FALSE) )
|
|
|
+ {
|
|
|
+ //TxProfile
|
|
|
+ strcpy(CurrentChargingProfileScheduleStr,TxProfileScheduleStr);
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxProfile_TEMP.ChargingProfileId;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = temptransactionId;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = TxProfile_TEMP.StackLevel;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = TxProfile_TEMP.ChargingSchedule.Duration ;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = TxProfile_TEMP.ChargingSchedule.MinChargingRate;
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)TxProfile_TEMP.ChargingSchedule.ChargingRateUnit);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)TxProfile_TEMP.ChargingProfileKind );
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)TxProfile_TEMP.ChargingProfilePurpose );
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule,(const char *)TxProfile_TEMP.ChargingSchedule.StartSchedule);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)TxProfile_TEMP.RecurrencyKind);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)TxProfile_TEMP.ValidFrom);
|
|
|
+ strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)TxProfile_TEMP.ValidTo);
|
|
|
+
|
|
|
+ for(int k=0; k < TxProfile.TotalPeriod;k++)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[k].Limit = TxProfile.Period[k].Limit;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[k].NumberPhases = TxProfile.Period[k].NumberPhases;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[k].StartPeriod = TxProfile.Period[k].StartPeriod;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
confirmPeriods = period;
|
|
|
DEBUG_INFO("confirmPeriods=%d\n",confirmPeriods);
|
|
@@ -14431,7 +14490,6 @@ void GetChargingProfileRequest(int gunindex)
|
|
|
|
|
|
void LWS_Send(char * str)
|
|
|
{
|
|
|
-
|
|
|
//=====================================================
|
|
|
// Check InternetConn 0: disconnected, 1: connected
|
|
|
//====================================================
|
|
@@ -14447,8 +14505,7 @@ void LWS_Send(char * str)
|
|
|
pthread_mutex_unlock(&lock);
|
|
|
lws_callback_on_writable(wsi_client);
|
|
|
lws_service(context, 10000);//timeout_ms
|
|
|
- //usleep(10000); // 等 ?? ?微 ?
|
|
|
- //DEBUG_INFO("Send message end\n");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|