|
@@ -903,6 +903,22 @@ uint8_t ocpp_get_starttransaction_result(uint8_t gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+uint8_t ocpp_get_maxcharging_profileId()
|
|
|
+{
|
|
|
+ uint8_t result = 0;
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ result = ShmOCPP16Data->MaxChargingProfile.ChargingProfileId;
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
+ {
|
|
|
+ result = ShmOCPP20Data->MaxChargingProfile.id;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
uint8_t ocpp_get_smartcharging_profileId(uint8_t gun_index)
|
|
|
{
|
|
|
uint8_t result = 0;
|
|
@@ -3119,7 +3135,51 @@ int isProfileValid(uint8_t gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-int getScheduleStart(unsigned char *time)
|
|
|
+int getMaxScheduleStart()
|
|
|
+{
|
|
|
+ int result = -1;
|
|
|
+ struct tm tmScheduleStart;;
|
|
|
+ struct timeb tbScheduleStart;
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ if((sscanf((char*)ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.StartSchedule, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
+ {
|
|
|
+ tmScheduleStart.tm_year -= 1900;
|
|
|
+ tmScheduleStart.tm_mon -= 1;
|
|
|
+ tbScheduleStart.time = mktime(&tmScheduleStart);
|
|
|
+ tbScheduleStart.millitm = 0;
|
|
|
+
|
|
|
+ result = DiffTimebWithNow(tbScheduleStart)/1000;
|
|
|
+ //DEBUG_INFO("Max schedule start compare Now(seconds): %d\n", result);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("Max schedule start date parsing error.\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
+ {
|
|
|
+ if((sscanf((char*)ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].startSchedule, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
+ {
|
|
|
+ tmScheduleStart.tm_year -= 1900;
|
|
|
+ tmScheduleStart.tm_mon -= 1;
|
|
|
+ tbScheduleStart.time = mktime(&tmScheduleStart);
|
|
|
+ tbScheduleStart.millitm = 0;
|
|
|
+
|
|
|
+ result = DiffTimebWithNow(tbScheduleStart)/1000;
|
|
|
+ //DEBUG_INFO("Max schedule start compare Now(seconds): %d\n", result);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("Max schedule start date parsing error.\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int getScheduleStart(int gun_index)
|
|
|
{
|
|
|
int result = -1;
|
|
|
struct tm tmScheduleStart;;
|
|
@@ -3127,8 +3187,7 @@ int getScheduleStart(unsigned char *time)
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
- // ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule
|
|
|
- if((sscanf((char*)time, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
+ if((sscanf((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
{
|
|
|
tmScheduleStart.tm_year -= 1900;
|
|
|
tmScheduleStart.tm_mon -= 1;
|
|
@@ -3145,8 +3204,7 @@ int getScheduleStart(unsigned char *time)
|
|
|
}
|
|
|
else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
{
|
|
|
- // ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].startSchedule
|
|
|
- if((sscanf((char*)time, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
+ if((sscanf((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].startSchedule, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
{
|
|
|
tmScheduleStart.tm_year -= 1900;
|
|
|
tmScheduleStart.tm_mon -= 1;
|
|
@@ -3539,34 +3597,15 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
//========================================
|
|
|
// Check TxProfile and TxDefaultProfile
|
|
|
//========================================
|
|
|
- if((ocpp_get_smartcharging_profileId(gun_index) > 0) &&
|
|
|
- (((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
+ if((ocpp_get_smartcharging_profileId(gun_index) > 0))
|
|
|
{
|
|
|
- // Debug information
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
- {
|
|
|
- DEBUG_INFO("========================================\n");
|
|
|
- DEBUG_INFO("Profile ID found: %d\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId);
|
|
|
- DEBUG_INFO("Valid from: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom);
|
|
|
- DEBUG_INFO("Valid to: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo);
|
|
|
- DEBUG_INFO("Start schedule: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule);
|
|
|
- DEBUG_INFO("Profile kind: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind);
|
|
|
- DEBUG_INFO("RecurrencyKind: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].RecurrencyKind);
|
|
|
- DEBUG_INFO("Profile purpose: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose);
|
|
|
- DEBUG_INFO("Transaction ID: %d\n", ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId);
|
|
|
- DEBUG_INFO("ChargingRateUnit: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit);
|
|
|
- DEBUG_INFO("========================================\n");
|
|
|
-
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
- }
|
|
|
-
|
|
|
// Checking profile kind
|
|
|
if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind, "Absolute") == PASS))
|
|
|
{
|
|
|
// Checking limitation
|
|
|
for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
{
|
|
|
- if((getScheduleStart(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule) >= ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ if((getScheduleStart(gun_index) >= ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
((idx_period == 0) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0))
|
|
|
)
|
|
|
{
|
|
@@ -3578,7 +3617,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId == 0))
|
|
|
+ else
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
|
|
|
}
|
|
@@ -3586,14 +3625,14 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
//========================================
|
|
|
// Check ChargingPointMaxProfile
|
|
|
//========================================
|
|
|
- if(ShmOCPP16Data->MaxChargingProfile.ChargingProfileId > 0)
|
|
|
+ if((ocpp_get_maxcharging_profileId() > 0))
|
|
|
{
|
|
|
// Absolute profile
|
|
|
if((mystrcmp((char*)ShmOCPP16Data->MaxChargingProfile.ChargingProfileKind, "Absolute") == PASS))
|
|
|
{
|
|
|
for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
{
|
|
|
- if((getScheduleStart(ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.StartSchedule) >= ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ if((getMaxScheduleStart() >= ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
((idx_period == 0) || (ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0))
|
|
|
)
|
|
|
{
|
|
@@ -3604,46 +3643,38 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ // Compare target current is over max current for EVSE limit
|
|
|
+ if(gun_index == 0)
|
|
|
+ {
|
|
|
if(ShmCharger->gun_info[gun_index].targetCurrent > MaxChargingProfileChargingCurrent)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = MaxChargingProfileChargingCurrent;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((ShmCharger->gun_info[gun_index-1].targetCurrent + ShmCharger->gun_info[gun_index].targetCurrent) > MaxChargingProfileChargingCurrent)
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (MaxChargingProfileChargingCurrent - ShmCharger->gun_info[gun_index-1].targetCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
{
|
|
|
//========================================
|
|
|
// Check TxProfile and TxDefaultProfile
|
|
|
//========================================
|
|
|
- if((ocpp_get_smartcharging_profileId(gun_index) > 0) &&
|
|
|
- (((strlen((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].validFrom)>0) && (strlen((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].validTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
+ if((ocpp_get_smartcharging_profileId(gun_index) > 0))
|
|
|
{
|
|
|
- // Debug information
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
- {
|
|
|
- DEBUG_INFO("========================================\n");
|
|
|
- DEBUG_INFO("Profile ID found: %d\n", ShmOCPP20Data->SmartChargingProfile[gun_index].id);
|
|
|
- DEBUG_INFO("Valid from: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].validFrom);
|
|
|
- DEBUG_INFO("Valid to: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].validTo);
|
|
|
- DEBUG_INFO("Start schedule: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].startSchedule);
|
|
|
- DEBUG_INFO("Profile kind: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].chargingProfileKind);
|
|
|
- DEBUG_INFO("RecurrencyKind: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].recurrencyKind);
|
|
|
- DEBUG_INFO("Profile purpose: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].chargingProfilePurpose);
|
|
|
- DEBUG_INFO("Transaction ID: %d\n", ShmOCPP20Data->SmartChargingProfile[gun_index].transactionId);
|
|
|
- DEBUG_INFO("ChargingRateUnit: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingRateUnit);
|
|
|
- DEBUG_INFO("========================================\n");
|
|
|
-
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
- }
|
|
|
-
|
|
|
// Checking profile kind
|
|
|
if((mystrcmp((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].chargingProfileKind, "Absolute") == PASS))
|
|
|
{
|
|
|
// Checking limitation
|
|
|
for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod);idx_period++)
|
|
|
{
|
|
|
- if((getScheduleStart(ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].startSchedule) >= ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod) &&
|
|
|
+ if((getScheduleStart(gun_index) >= ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod) &&
|
|
|
((idx_period == 0) || (ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod > 0))
|
|
|
)
|
|
|
{
|
|
@@ -3655,7 +3686,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if((ShmOCPP20Data->SmartChargingProfile[gun_index].id == 0))
|
|
|
+ else
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
|
|
|
}
|
|
@@ -3663,7 +3694,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
//========================================
|
|
|
// Check ChargingPointMaxProfile
|
|
|
//========================================
|
|
|
- if(ShmOCPP20Data->MaxChargingProfile.id > 0)
|
|
|
+ if((ocpp_get_maxcharging_profileId() > 0))
|
|
|
{
|
|
|
// Absolute profile
|
|
|
if((mystrcmp((char*)ShmOCPP20Data->MaxChargingProfile.chargingProfileKind, "Absolute") == PASS))
|
|
@@ -3671,7 +3702,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
// Checking limitation
|
|
|
for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod);idx_period++)
|
|
|
{
|
|
|
- if((getScheduleStart(ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].startSchedule) >= ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod) &&
|
|
|
+ if((getMaxScheduleStart() >= ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod) &&
|
|
|
((idx_period == 0) || (ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod > 0))
|
|
|
)
|
|
|
{
|
|
@@ -3682,12 +3713,23 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ // Compare target current is over max current for EVSE limit
|
|
|
+ if(gun_index == 0)
|
|
|
+ {
|
|
|
if(ShmCharger->gun_info[gun_index].targetCurrent > MaxChargingProfileChargingCurrent)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = MaxChargingProfileChargingCurrent;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((ShmCharger->gun_info[gun_index-1].targetCurrent + ShmCharger->gun_info[gun_index].targetCurrent) > MaxChargingProfileChargingCurrent)
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (MaxChargingProfileChargingCurrent - ShmCharger->gun_info[gun_index-1].targetCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
switch(system_mode)
|