X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ServiceUtils.ts;h=e567be4f820c394e7b1b9230733f809f38dc3c1e;hb=a19b897d3aa5cb0f12177a42d8168121ce6ada97;hp=570708b74be0ba7f30b9f243bc613ccbe25dd584;hpb=68220b423c52da387fdf41967dd8c738da0ff52e;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 570708b7..e567be4f 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,12 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = [] } + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + cp.chargingSchedule.startSchedule = convertToDate(cp.chargingSchedule.startSchedule)! + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + cp.validFrom = convertToDate(cp.validFrom)! + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + 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 +198,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 @@ -293,7 +299,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ), chargingSchedulePeriod: [ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => { + ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(schedulePeriod => { return { ...schedulePeriod, startPeriod: higherFirst @@ -306,7 +312,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { } }), // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ...compositeChargingScheduleLower!.chargingSchedulePeriod.map((schedulePeriod) => { + ...compositeChargingScheduleLower!.chargingSchedulePeriod.map(schedulePeriod => { return { ...schedulePeriod, startPeriod: higherFirst @@ -339,7 +345,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ), chargingSchedulePeriod: [ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => { + ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(schedulePeriod => { return { ...schedulePeriod, startPeriod: higherFirst @@ -544,7 +550,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { compositeInterval.end as Date, chargingScheduleInterval.start ), - chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter((schedulePeriod) => + chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod => isWithinInterval( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,