X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ServiceUtils.ts;h=a959844ac497f46b1876acd068ac56f61c87045d;hb=1b7eb3863a1e2263e353d5b191b2de48ebbcaee8;hp=1f119a2e4753fb476bb6ee1ddf8e13e5e96cfd8c;hpb=a974c8e4b8a98c9450be49546a77be0d03e9f512;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 1f119a2e..a959844a 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -1,4 +1,4 @@ -// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. +// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved. import type { JSONSchemaType } from 'ajv' import { @@ -38,7 +38,7 @@ import { type OCPP16SupportedFeatureProfiles, OCPPVersion } from '../../../types/index.js' -import { isNotEmptyArray, logger, roundTo } from '../../../utils/index.js' +import { convertToDate, isNotEmptyArray, logger, roundTo } from '../../../utils/index.js' import { OCPPServiceUtils } from '../OCPPServiceUtils.js' export class OCPP16ServiceUtils extends OCPPServiceUtils { @@ -164,6 +164,9 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = [] } + cp.chargingSchedule.startSchedule = convertToDate(cp.chargingSchedule.startSchedule) + cp.validFrom = convertToDate(cp.validFrom) + cp.validTo = convertToDate(cp.validTo) let cpReplaced = false if (isNotEmptyArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -192,7 +195,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { const { id, chargingProfilePurpose, stackLevel } = commandPayload let clearedCP = false if (isNotEmptyArray(chargingProfiles)) { - chargingProfiles?.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => { + chargingProfiles.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => { let clearCurrentCP = false if (chargingProfile.chargingProfileId === id) { clearCurrentCP = true @@ -504,8 +507,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { .filter((schedulePeriod, index) => { if ( isWithinInterval( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!, + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), compositeInterval ) ) { @@ -546,8 +548,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ), chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod => isWithinInterval( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!, + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), compositeInterval ) )