isAfter(addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!), currentDate)
) {
if (isNotEmptyArray(chargingSchedule.chargingSchedulePeriod)) {
- // Handling of only one schedule period
+ chargingSchedule.chargingSchedulePeriod.sort((a, b) => a.startPeriod - b.startPeriod);
+ if (chargingSchedule.chargingSchedulePeriod[0].startPeriod !== 0) {
+ logger.error(
+ `${logPrefix} ${moduleName}.getLimitFromChargingProfiles: Charging profile id ${chargingProfile.chargingProfileId} first schedule period start period ${chargingSchedule.chargingSchedulePeriod[0].startPeriod} is not equal to 0`,
+ );
+ // continue;
+ }
+ // Handling of only one schedule period with startPeriod = 0
if (
chargingSchedule.chargingSchedulePeriod.length === 1 &&
chargingSchedule.chargingSchedulePeriod[0].startPeriod === 0
logger.debug(debugLogMsg, result);
return result;
}
- chargingSchedule.chargingSchedulePeriod.sort((a, b) => a.startPeriod - b.startPeriod);
let lastButOneSchedule: ChargingSchedulePeriod | undefined;
// Search for the right schedule period
for (const schedulePeriod of chargingSchedule.chargingSchedulePeriod) {
interval.start,
)}`,
);
+ chargingProfile.chargingSchedule.duration = differenceInSeconds(interval.end, interval.start);
}
};
private setRemoteStartTransactionChargingProfile(
chargingStation: ChargingStation,
connectorId: number,
- cp: OCPP16ChargingProfile,
+ chargingProfile: OCPP16ChargingProfile,
): boolean {
- if (cp && cp.chargingProfilePurpose === OCPP16ChargingProfilePurposeType.TX_PROFILE) {
- OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, cp);
+ if (
+ chargingProfile &&
+ chargingProfile.chargingProfilePurpose === OCPP16ChargingProfilePurposeType.TX_PROFILE
+ ) {
+ OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, chargingProfile);
logger.debug(
`${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction
on connector id ${connectorId}: %j`,
- cp,
+ chargingProfile,
);
return true;
- } else if (cp && cp.chargingProfilePurpose !== OCPP16ChargingProfilePurposeType.TX_PROFILE) {
+ } else if (
+ chargingProfile &&
+ chargingProfile.chargingProfilePurpose !== OCPP16ChargingProfilePurposeType.TX_PROFILE
+ ) {
logger.warn(
`${chargingStation.logPrefix()} Not allowed to set ${
- cp.chargingProfilePurpose
+ chargingProfile.chargingProfilePurpose
} charging profile(s) at remote start transaction`,
);
return false;