|
@@ -40,6 +40,7 @@
|
|
|
#include <mcheck.h>
|
|
|
|
|
|
|
|
|
+
|
|
|
#define PASS 1
|
|
|
#define FAIL -1
|
|
|
|
|
@@ -201,6 +202,7 @@ extern int SendBufLen;
|
|
|
extern char *random_uuid( char buf[37] );
|
|
|
extern void split(char **arr, char *str, const char *del);
|
|
|
extern void ChageWebSocketPingInterval(int WebSocketPingInterval);
|
|
|
+extern int GetTransactionQueueNum(void);
|
|
|
extern pthread_mutex_t mutex1;
|
|
|
extern struct Charger_Info Charger;
|
|
|
extern sqlite3 *db;
|
|
@@ -1265,10 +1267,10 @@ void CheckSystemValue(void)
|
|
|
//===============================
|
|
|
if((server_sign == TRUE) && (ShmOCPP16Data->SpMsg.bits.AuthorizeReq == 1)&&(authorizeRetryTimes < 3)/*authenrequest == FALSE*/)
|
|
|
{
|
|
|
- sendAuthorizeRequest(0);
|
|
|
- authorizeRetryTimes = authorizeRetryTimes + 1;
|
|
|
- // authenrequest = TRUE
|
|
|
- if(authorizeRetryTimes < 3)
|
|
|
+ sendAuthorizeRequest(0);
|
|
|
+ authorizeRetryTimes = authorizeRetryTimes + 1;
|
|
|
+
|
|
|
+ if(authorizeRetryTimes < 3)
|
|
|
ShmOCPP16Data->SpMsg.bits.AuthorizeReq = 0;
|
|
|
|
|
|
}
|
|
@@ -2031,6 +2033,7 @@ int sendStartTransactionRequest(int gun_index)
|
|
|
, ShmOCPP16Data->StartTransaction[gun_index].ReservationId
|
|
|
, ShmOCPP16Data->StartTransaction[gun_index].Timestamp );
|
|
|
|
|
|
+
|
|
|
sprintf(tempdata, "StartTransaction,%d", (gun_index));
|
|
|
if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
|
|
|
{
|
|
@@ -2039,7 +2042,10 @@ int sendStartTransactionRequest(int gun_index)
|
|
|
strcpy(queuedata, message);
|
|
|
queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
|
|
|
|
|
|
- LWS_Send(message);
|
|
|
+ if(GetTransactionQueueNum() == 1)
|
|
|
+ {
|
|
|
+ LWS_Send(message);
|
|
|
+ }
|
|
|
|
|
|
#if 0
|
|
|
sprintf(tempdata, "StartTransaction,%d", (gun_index));
|
|
@@ -2790,10 +2796,12 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
}
|
|
|
queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
|
|
|
|
|
|
- LWS_Send(queuedata);
|
|
|
-
|
|
|
-
|
|
|
+ if(GetTransactionQueueNum() == 1)
|
|
|
+ {
|
|
|
+ LWS_Send(queuedata);
|
|
|
+ }
|
|
|
|
|
|
+ //----------------------------replace queue StopTransaction TransactionId ---------------------------//
|
|
|
int gettransactionId = GetTransactionId(gun_index+1, ShmOCPP16Data->StopTransaction[gun_index].IdTag);
|
|
|
|
|
|
if((ShmOCPP16Data->StopTransaction[gun_index].TransactionId != 0) && (gettransactionId != 0))
|
|
@@ -3213,7 +3221,12 @@ int sendMeterValuesRequest(int gun_index)
|
|
|
DEBUG_INFO("MeterValues mapitem pass\n");
|
|
|
}
|
|
|
queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
|
|
|
- LWS_Send(queuedata);
|
|
|
+
|
|
|
+ if(GetTransactionQueueNum() == 1)
|
|
|
+ {
|
|
|
+ LWS_Send(queuedata);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
#if 0
|
|
|
// Put request guid to hash map
|
|
@@ -3429,9 +3442,8 @@ int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connector
|
|
|
|
|
|
int len = nPeriod;
|
|
|
//Last Period StartPriod is less than diffSeconds
|
|
|
- if(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[len -1].StartPeriod < diffSeconds)
|
|
|
+ if((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[len -1].StartPeriod % 86400) < diffSeconds)
|
|
|
{
|
|
|
-
|
|
|
sprintf(message + strlen(message), "{\"startPeriod\":%d,\"limit\":%.1f,\"numberPhases\":%d}"
|
|
|
, 0
|
|
|
, ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[len -1].Limit
|
|
@@ -3442,7 +3454,7 @@ int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connector
|
|
|
|
|
|
for(int idx_sample=0;idx_sample< len;idx_sample++)
|
|
|
{
|
|
|
- if((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod < diffSeconds) && (ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample + 1].StartPeriod > diffSeconds))//if (idx_sample == 0)
|
|
|
+ if(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod % 86400) < diffSeconds) && ((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample + 1].StartPeriod % 86400) > diffSeconds))//if (idx_sample == 0)
|
|
|
{
|
|
|
sprintf(message + strlen(message), "{\"startPeriod\":%d,\"limit\":%.1f,\"numberPhases\":%d}"
|
|
|
, 0 /*ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod*/
|
|
@@ -3452,7 +3464,7 @@ int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connector
|
|
|
else if(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod > diffSeconds)
|
|
|
{
|
|
|
sprintf(message + strlen(message), ",{\"startPeriod\":%d,\"limit\":%.1f,\"numberPhases\":%d}"
|
|
|
- , (ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/)//(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds ) <= 0)?(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod):(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/)) //(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/) <= 0)?(ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod):(ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/))
|
|
|
+ , ((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod % 86400) - diffSeconds /*-1*/)//(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds ) <= 0)?(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod):(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/)) //(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/) <= 0)?(ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod):(ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/))
|
|
|
, ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].Limit
|
|
|
, ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].NumberPhases );
|
|
|
}
|
|
@@ -4763,6 +4775,7 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
|
|
|
{
|
|
|
+ DEBUG_INFO("ChargeProfileCount=%d\n",ChargeProfileCount);
|
|
|
for(int k=0; k < ChargeProfileCount; k++)
|
|
|
{
|
|
|
fptr1 = fopen(chargingProfiles[k], "r");
|
|
@@ -4779,7 +4792,6 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
}
|
|
|
rewind(fptr1);
|
|
|
-
|
|
|
//search Charging Profile Element
|
|
|
//int i= 0;
|
|
|
while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
|
|
@@ -5552,37 +5564,70 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
if((ChargePointMaxProfileIsNull==FALSE)&&(TxDefaultProfileFileIsNull==FALSE))
|
|
|
{
|
|
|
strcpy(CurrentChargingProfileScheduleStr, TxDefaultProfileScheduleStr);
|
|
|
- for(int index=0; index < TxDefaultProfile.TotalPeriod ; index++)
|
|
|
+ struct tm tp;
|
|
|
+ strptime((const char *)CurrentChargingProfileScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
|
|
|
+ tp.tm_isdst = -1;
|
|
|
+ time_t utc = mktime(&tp);
|
|
|
+ time_t t = time(NULL);
|
|
|
+ double diff_f = difftime(t, utc);
|
|
|
+ int diff_i = (int)diff_f;
|
|
|
+ int quotient = diff_i / 86400;//86400 seconds/day
|
|
|
+
|
|
|
+ int period = 0;
|
|
|
+ for(int index=0; index < TxDefaultProfile.TotalPeriod ; index++)
|
|
|
{
|
|
|
- if(ChargePointMaxProfile.Period[0].Limit > TxDefaultProfile.Period[index].Limit)
|
|
|
- {
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].Limit = TxDefaultProfile.Period[index].Limit;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].Limit = ChargePointMaxProfile.Period[0].Limit;
|
|
|
- }
|
|
|
-
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].NumberPhases = TxDefaultProfile.Period[index].NumberPhases; //for discussion
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].StartPeriod = TxDefaultProfile.Period[index].StartPeriod;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.Duration = TxDefaultProfile.Duration;
|
|
|
+ if(((TxDefaultProfile.Period[index].StartPeriod % 86400) < durationInt) && ((TxDefaultProfile.Period[index].StartPeriod / 86400) == quotient))
|
|
|
+ {
|
|
|
+ if(ChargePointMaxProfile.Period[0].Limit > TxDefaultProfile.Period[index].Limit)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[index].Limit;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[index].NumberPhases; //for discussion
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = (TxDefaultProfile.Period[index].StartPeriod % 86400);
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.Duration = TxDefaultProfile.Duration;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- confirmPeriods = TxDefaultProfile.TotalPeriod;
|
|
|
+ confirmPeriods = period;
|
|
|
|
|
|
}
|
|
|
else if((ChargePointMaxProfileIsNull==TRUE)&&(TxDefaultProfileFileIsNull==FALSE))
|
|
|
{
|
|
|
strcpy(CurrentChargingProfileScheduleStr, TxDefaultProfileScheduleStr);
|
|
|
+ struct tm tp;
|
|
|
+ strptime((const char *)CurrentChargingProfileScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
|
|
|
+ tp.tm_isdst = -1;
|
|
|
+ time_t utc = mktime(&tp);
|
|
|
+ time_t t = time(NULL);
|
|
|
+ double diff_f = difftime(t, utc);
|
|
|
+ int diff_i = (int)diff_f;
|
|
|
+ int quotient = diff_i / 86400;//86400 seconds/day
|
|
|
+
|
|
|
+ int period = 0;
|
|
|
for(int index=0; index < TxDefaultProfile.TotalPeriod ; index++)
|
|
|
{
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].Limit = TxDefaultProfile.Period[index].Limit;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].NumberPhases = TxDefaultProfile.Period[index].NumberPhases; //for discussion
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].StartPeriod = TxDefaultProfile.Period[index].StartPeriod;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.Duration = TxDefaultProfile.Duration;
|
|
|
- }
|
|
|
+ if(((TxDefaultProfile.Period[index].StartPeriod % 86400) < durationInt) && ((TxDefaultProfile.Period[index].StartPeriod / 86400) == quotient))
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[index].Limit;
|
|
|
|
|
|
- confirmPeriods = TxDefaultProfile.TotalPeriod;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[index].NumberPhases; //for discussion
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = (TxDefaultProfile.Period[index].StartPeriod % 86400);
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.Duration = TxDefaultProfile.Duration;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ confirmPeriods = period;
|
|
|
|
|
|
}
|
|
|
else if((ChargePointMaxProfileIsNull==FALSE)&&(TxDefaultProfileFileIsNull==TRUE))
|
|
@@ -6381,6 +6426,16 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==FALSE) )
|
|
|
{
|
|
|
strcpy(CurrentChargingProfileScheduleStr,TxProfileScheduleStr);
|
|
|
+ struct tm tp;
|
|
|
+ strptime((const char *)CurrentChargingProfileScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
|
|
|
+ tp.tm_isdst = -1;
|
|
|
+ time_t utc = mktime(&tp);
|
|
|
+ time_t t = time(NULL);
|
|
|
+ double diff_f = difftime(t, utc);
|
|
|
+ int diff_i = (int)diff_f;
|
|
|
+ int quotient = diff_i / 86400;//86400 seconds/day
|
|
|
+ //int remainder = diff_i % 86400;
|
|
|
+
|
|
|
for(int k=0; k < TxProfile.TotalPeriod;k++)
|
|
|
{
|
|
|
if(TxProfile.Period[k].Limit < ChargePointMaxProfile.Period[0].Limit)
|
|
@@ -6409,7 +6464,7 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
|
|
|
for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
|
|
|
{
|
|
|
- if((TxDefaultProfile.Period[l].StartPeriod < durationInt)&&(TxDefaultProfile.Period[l].StartPeriod > ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period-1].StartPeriod))
|
|
|
+ if(((TxDefaultProfile.Period[l].StartPeriod % 86400) < durationInt)&& ((TxDefaultProfile.Period[l].StartPeriod / 86400) == quotient)&&((TxDefaultProfile.Period[l].StartPeriod %86400) > ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period-1].StartPeriod))
|
|
|
{
|
|
|
if(TxDefaultProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
|
|
|
{
|
|
@@ -6421,14 +6476,14 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
|
|
|
}
|
|
|
ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = (TxDefaultProfile.Period[l].StartPeriod % 86400);
|
|
|
|
|
|
period = period + 1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ // Check Last Period
|
|
|
if((TxDefaultProfile.Duration < durationInt) && (ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period-1].Limit) < ChargePointMaxProfile.Period[0].Limit)
|
|
|
{
|
|
|
ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
|
|
@@ -6442,35 +6497,100 @@ int handleGetCompositeScheduleRequest(char *uuid, char *payload)
|
|
|
else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==TRUE) )
|
|
|
{
|
|
|
strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
|
|
|
+ struct tm tp;
|
|
|
+ strptime((const char *)CurrentChargingProfileScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
|
|
|
+ tp.tm_isdst = -1;
|
|
|
+ time_t utc = mktime(&tp);
|
|
|
+ time_t t = time(NULL);
|
|
|
+ double diff_f = difftime(t, utc);
|
|
|
+ int diff_i = (int)diff_f;
|
|
|
+ int quotient = diff_i / 86400;//86400 seconds/day
|
|
|
+ //int remainder = diff_i % 86400;
|
|
|
+
|
|
|
for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
|
|
|
{
|
|
|
- if(TxProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
|
|
|
+ if((TxDefaultProfile.Period[l].StartPeriod < durationInt) && ((TxDefaultProfile.Period[l].StartPeriod / 86400) == quotient))
|
|
|
{
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
- period = period + 1;
|
|
|
+ if(TxDefaultProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else if(TxDefaultProfile.Period[l].StartPeriod > durationInt)
|
|
|
+ {
|
|
|
+ if((TxDefaultProfile.Period[l].StartPeriod / 86400) == quotient)
|
|
|
+ {
|
|
|
+ if((TxDefaultProfile.Period[l].StartPeriod % 86400) < durationInt)
|
|
|
+ {
|
|
|
+ if(TxDefaultProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = ChargePointMaxProfile.Period[0].Limit;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
- period = period + 1;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==TRUE) && (TxProfileIsNull==TRUE) )
|
|
|
{
|
|
|
strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
|
|
|
+ struct tm tp;
|
|
|
+ strptime((const char *)CurrentChargingProfileScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
|
|
|
+ tp.tm_isdst = -1;
|
|
|
+ time_t utc = mktime(&tp);
|
|
|
+ time_t t = time(NULL);
|
|
|
+ double diff_f = difftime(t, utc);
|
|
|
+ int diff_i = (int)diff_f;
|
|
|
+ int quotient = diff_i / 86400;//86400 seconds/day
|
|
|
+ //int remainder = diff_i % 86400;
|
|
|
+
|
|
|
for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
|
|
|
{
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
- period = period + 1;
|
|
|
+ if((TxDefaultProfile.Period[l].StartPeriod < durationInt) && ((TxDefaultProfile.Period[l].StartPeriod / 86400) == quotient))
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+ else if(TxDefaultProfile.Period[l].StartPeriod > durationInt)
|
|
|
+ {
|
|
|
+ if((TxDefaultProfile.Period[l].StartPeriod / 86400) == quotient)
|
|
|
+ {
|
|
|
+ if((TxDefaultProfile.Period[l].StartPeriod % 86400) < durationInt)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
|
|
|
+ ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
|
|
|
+ period = period + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -9243,7 +9363,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
|
|
|
if(strcmp(chargingProfilePurposeStr, ChargingProfilePurposeTypeStr[ChargePointMaxProfile]) == 0)
|
|
|
{
|
|
|
- //printf("set chargingProfile 1-2\n");
|
|
|
DEBUG_INFO("chargingProfilePurposeStr is ChargePointMaxProfile !!! \n");
|
|
|
if(connectorIdInt != 0)
|
|
|
{
|
|
@@ -9278,7 +9397,6 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else if(strcmp(chargingProfilePurposeStr, ChargingProfilePurposeTypeStr[TxDefaultProfile]) == 0)
|
|
|
{
|
|
|
- //printf("set chargingProfile 1-3\n");
|
|
|
DEBUG_INFO("chargingProfilePurposeStr is TxDefaultProfile !!! \n");
|
|
|
if((connectorIdInt != 0) && (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/))
|
|
|
{
|
|
@@ -9444,10 +9562,11 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
}
|
|
|
fclose(fptr1);
|
|
|
+ DEBUG_INFO("n_chargingProfile_3=%d\n",n_chargingProfile);
|
|
|
}
|
|
|
|
|
|
// Check ChargeProfileMaxStackLevel
|
|
|
- if(n_chargingProfile > atoi((const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData))
|
|
|
+ if(n_chargingProfile >= atoi((const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData))
|
|
|
{
|
|
|
sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
|
|
|
goto end;
|