logger.warn(
`${logPrefix} ${moduleName}.getLimitFromChargingProfiles: startSchedule is not a Date object in charging profile id ${chargingProfile.chargingProfileId}. Trying to convert it to a Date object`,
);
- chargingSchedule.startSchedule = convertToDate(chargingSchedule.startSchedule)!;
+ chargingSchedule.startSchedule = convertToDate(chargingSchedule?.startSchedule)!;
}
if (
chargingProfile.chargingProfileKind === ChargingProfileKindType.RECURRING &&
}
// Check if the charging profile is active
if (
- isValidDate(chargingSchedule.startSchedule) &&
+ isValidDate(chargingSchedule?.startSchedule) &&
isWithinInterval(currentDate, {
start: chargingSchedule.startSchedule!,
end: addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!),
);
continue;
}
- // Handling of only one schedule period
+ // Handle only one schedule period
if (chargingSchedule.chargingSchedulePeriod.length === 1) {
const result: ChargingProfilesLimit = {
limit: chargingSchedule.chargingSchedulePeriod[0].limit,
checkRecurringChargingProfileDuration(chargingProfile, recurringInterval, logPrefix);
if (
!isWithinInterval(currentDate, recurringInterval) &&
- isBefore(chargingSchedule.startSchedule!, currentDate)
+ isBefore(recurringInterval.end, currentDate)
) {
chargingSchedule.startSchedule = addDays(
- chargingSchedule.startSchedule!,
+ recurringInterval.start,
differenceInDays(currentDate, recurringInterval.start),
);
recurringInterval = {
checkRecurringChargingProfileDuration(chargingProfile, recurringInterval, logPrefix);
if (
!isWithinInterval(currentDate, recurringInterval) &&
- isBefore(chargingSchedule.startSchedule!, currentDate)
+ isBefore(recurringInterval.end, currentDate)
) {
chargingSchedule.startSchedule = addWeeks(
- chargingSchedule.startSchedule!,
+ recurringInterval.start,
differenceInWeeks(currentDate, recurringInterval.start),
);
recurringInterval = {
logger.error(
`${logPrefix} ${moduleName}.prepareRecurringChargingProfile: Recurring ${
chargingProfile.recurrencyKind
- } charging profile id ${
- chargingProfile.chargingProfileId
- } startSchedule ${chargingSchedule.startSchedule!.toISOString()} is not properly translated to current recurrency time interval [${toDate(
+ } charging profile id ${chargingProfile.chargingProfileId} recurrency time interval [${toDate(
recurringInterval!.start,
- ).toISOString()}, ${toDate(recurringInterval!.end).toISOString()}]`,
+ ).toISOString()}, ${toDate(
+ recurringInterval!.end,
+ ).toISOString()}] is not properly translated to current date ${currentDate.toISOString()} `,
);
}
};
DCElectricUtils,
convertToFloat,
convertToInt,
+ formatDurationMilliSeconds,
getRandomFloatFluctuatedRounded,
getRandomFloatRounded,
getRandomInteger,
`${chargingStation.logPrefix()} MeterValues measurand ${
meterValue.sampledValue[sampledValuesIndex].measurand ??
OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
- }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${roundTo(
- interval / (3600 * 1000),
- 4,
- )}h`,
+ }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${formatDurationMilliSeconds(
+ interval,
+ )}(${roundTo(interval, 4)}ms)`,
);
}
}