|
@@ -5443,6 +5443,7 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
// TxProfile found, composite schedule based on it
|
|
|
if(txProfile.id != -1)
|
|
|
{
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].duration = txProfile.chargingSchedule[idxSchedule].duration;
|
|
|
for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
|
|
|
{
|
|
|
if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
|
|
@@ -5504,6 +5505,7 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
{
|
|
|
if(defaultTxProfile.id != -1)
|
|
|
{
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].duration = (defaultTxProfile.chargingSchedule[idxSchedule].duration>compositeProfile->chargingSchedule[idxSchedule].duration)?defaultTxProfile.chargingSchedule[idxSchedule].duration:compositeProfile->chargingSchedule[idxSchedule].duration;
|
|
|
for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
|
|
|
{
|
|
|
if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
|
|
@@ -5554,7 +5556,18 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
+ if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ compositePeriodIdx++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ }
|
|
|
break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -5578,6 +5591,7 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
// TxProfile not found but defaultTxProfile found, composite schedule based on it
|
|
|
else if(defaultTxProfile.id != -1)
|
|
|
{
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].duration = defaultTxProfile.chargingSchedule[idxSchedule].duration;
|
|
|
for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
|
|
|
{
|
|
|
if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
|
|
@@ -5590,16 +5604,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
{
|
|
|
if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
|
|
|
{
|
|
|
+ tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
|
|
|
+ tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
|
|
|
+
|
|
|
if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
|
|
|
{
|
|
|
- tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
|
|
|
- tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
|
|
|
tmpPeriod.limit = (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
|
|
|
- tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
|
|
|
tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
|
|
|
}
|
|
|
|
|
@@ -5628,7 +5641,18 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
+ if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ compositePeriodIdx++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ }
|
|
|
break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -5650,50 +5674,76 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
// Fill other period by MaxProfile
|
|
|
if(maxProfile.id != -1)
|
|
|
{
|
|
|
- for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
|
|
|
+ if(compositePeriodIdx==0)
|
|
|
{
|
|
|
- if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
|
|
|
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
|
|
|
- (maxProfile.chargingSchedule[idxSchedule].duration > 0))
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
|
|
|
+ for(int idxMaxPeriod=0;idxMaxPeriod<limitDef;idxMaxPeriod++)
|
|
|
{
|
|
|
- if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
|
|
|
- (maxProfile.chargingSchedule[idxSchedule].duration > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
|
|
|
+ if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
|
|
|
+ (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
|
|
|
+ (maxProfile.chargingSchedule[idxSchedule].duration > 0))
|
|
|
{
|
|
|
- tmpPeriod.startPeriod = (compositePeriodIdx==0)?0:compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
|
|
|
- tmpPeriod.numberPhases = compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
|
|
|
- tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
|
|
|
- }
|
|
|
-
|
|
|
- if((compositePeriodIdx > 0) && (maxProfile.chargingSchedule[idxSchedule].duration > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
|
|
|
- {
|
|
|
- tmpPeriod.startPeriod = (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod>compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod)?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod:compositeProfile->chargingSchedule[idxSchedule].duration;
|
|
|
- tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
|
|
|
- tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
|
|
|
+ if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
|
|
|
+ compositePeriodIdx++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if(tmpPeriod.limit != -1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int lastCompositePeriodIdx = compositePeriodIdx;
|
|
|
+ for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
|
|
|
+ {
|
|
|
+ if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
|
|
|
+ (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
|
|
|
+ (maxProfile.chargingSchedule[idxSchedule].duration > 0))
|
|
|
{
|
|
|
- if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
|
|
|
+ if((maxProfile.chargingSchedule[idxSchedule].duration >= compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod))
|
|
|
{
|
|
|
- if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
|
|
|
+ if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit)
|
|
|
{
|
|
|
- memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
|
|
|
- compositePeriodIdx++;
|
|
|
+ tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
|
|
|
+ tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
|
|
|
+ tmpPeriod.limit = compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
|
|
|
+ tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
|
|
|
+ tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Delete duplicate period
|
|
|
- if(compositePeriodIdx > 1)
|
|
|
+ if(tmpPeriod.limit != -1)
|
|
|
{
|
|
|
- if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
|
|
|
+ if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].limit)
|
|
|
{
|
|
|
- compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
|
|
|
- compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
|
|
|
- compositePeriodIdx -= 1;
|
|
|
+ if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].startPeriod)
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ compositePeriodIdx++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Delete duplicate period
|
|
|
+ if(compositePeriodIdx > 1)
|
|
|
+ {
|
|
|
+ if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
|
|
|
+ {
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
|
|
|
+ compositePeriodIdx -= 1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5701,6 +5751,7 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
|
|
|
DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
|
|
|
DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
|
|
|
DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[idxSchedule].duration);
|
|
@@ -14643,7 +14694,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
|
|
|
|
|
|
sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", (gun_index+1));
|
|
|
filePtr = fopen((char*)filename, "w");
|
|
|
- fprintf(filePtr, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", (gun_index+1), json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
|
|
|
+ fprintf(filePtr, "{\"evseId\":%d,\"csChargingProfiles\":%s}\n", (gun_index+1), json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
|
|
|
fclose(filePtr);
|
|
|
}
|
|
|
|
|
@@ -14655,7 +14706,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
|
|
|
else
|
|
|
{
|
|
|
if(gun_index < 0)
|
|
|
- DEBUG_WARN("Connector id is wrong.\n");
|
|
|
+ DEBUG_WARN("evseId id is wrong.\n");
|
|
|
|
|
|
if(isPeriodOverMax)
|
|
|
DEBUG_WARN("Profile periods quantity is over spec.\n");
|