X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ServiceUtils.ts;h=d0d46c25d50df40ae9fb3f1f4bed5d9fbe196d5d;hb=27f08ad31f3e69c0681005edc6e9fec49d0450c2;hp=d09a8548d28e0545e949fd7c9913637e7ee0dd69;hpb=130783a74f495abcb198b7f01abe19dab4f7fb47;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 d09a8548..d0d46c25 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -1,6 +1,5 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -8,7 +7,6 @@ import type { JSONSchemaType } from 'ajv'; import OCPPError from '../../../exception/OCPPError'; import { CurrentType, Voltage } from '../../../types/ChargingStationTemplate'; -import { FileType } from '../../../types/FileType'; import type { JsonType } from '../../../types/JsonType'; import type { MeasurandPerPhaseSampledValueTemplates, @@ -37,7 +35,6 @@ import { ErrorType } from '../../../types/ocpp/ErrorType'; import { OCPPVersion } from '../../../types/ocpp/OCPPVersion'; import Constants from '../../../utils/Constants'; import { ACElectricUtils, DCElectricUtils } from '../../../utils/ElectricUtils'; -import FileUtils from '../../../utils/FileUtils'; import logger from '../../../utils/Logger'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; @@ -789,19 +786,17 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { !cpReplaced && chargingStation.getConnectorStatus(connectorId)?.chargingProfiles?.push(cp); } - public static parseJsonSchemaFile(relativePath: string): JSONSchemaType { - const filePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath); - try { - return JSON.parse(fs.readFileSync(filePath, 'utf8')) as JSONSchemaType; - } catch (error) { - FileUtils.handleFileException( - OCPPServiceUtils.logPrefix(OCPPVersion.VERSION_16), - FileType.JsonSchema, - filePath, - error as NodeJS.ErrnoException, - { throwError: false } - ); - } + public static parseJsonSchemaFile( + relativePath: string, + moduleName?: string, + methodName?: string + ): JSONSchemaType { + return super.parseJsonSchemaFile( + path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath), + OCPPVersion.VERSION_16, + moduleName, + methodName + ); } private static buildSampledValue(