X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPServiceUtils.ts;h=d09d8b1a1afaffc72b9891ab52f72b48f6282c69;hb=08b58f0020986c0ad1b55e562aaf325a47b9d58c;hp=16d83ee99c6be12b4bc56cadc6e65d83830cbd03;hpb=a37fc6dc8267e22b2b2d35773525980b81f014e8;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 16d83ee9..d09d8b1a 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -3,11 +3,12 @@ import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv'; +import { isDate } from 'date-fns'; import { OCPP16Constants } from './1.6/OCPP16Constants'; import { OCPP20Constants } from './2.0/OCPP20Constants'; import { OCPPConstants } from './OCPPConstants'; -import { type ChargingStation, ChargingStationConfigurationUtils } from '../../charging-station'; +import { type ChargingStation, getConfigurationKey } from '../../charging-station'; import { BaseError } from '../../exception'; import { ChargePointErrorCode, @@ -145,7 +146,7 @@ export class OCPPServiceUtils { public static convertDateToISOString(obj: T): void { for (const key in obj) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - if (obj![key] instanceof Date) { + if (isDate(obj![key])) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion (obj![key] as string) = (obj![key] as Date).toISOString(); // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion @@ -308,7 +309,7 @@ export class OCPPServiceUtils { } if ( measurand !== MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER && - ChargingStationConfigurationUtils.getConfigurationKey( + getConfigurationKey( chargingStation, StandardParametersKey.MeterValuesSampledData, )?.value?.includes(measurand) === false @@ -340,7 +341,7 @@ export class OCPPServiceUtils { phase && sampledValueTemplates[index]?.phase === phase && sampledValueTemplates[index]?.measurand === measurand && - ChargingStationConfigurationUtils.getConfigurationKey( + getConfigurationKey( chargingStation, StandardParametersKey.MeterValuesSampledData, )?.value?.includes(measurand) === true @@ -350,7 +351,7 @@ export class OCPPServiceUtils { !phase && !sampledValueTemplates[index].phase && sampledValueTemplates[index]?.measurand === measurand && - ChargingStationConfigurationUtils.getConfigurationKey( + getConfigurationKey( chargingStation, StandardParametersKey.MeterValuesSampledData, )?.value?.includes(measurand) === true