X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F2.0%2FOCPP20IncomingRequestService.ts;h=3fdb5cedf1b784c5b90c93706e05596557f0afe5;hb=022a231c76e227205b0124a7aef8e16ceb86a1d9;hp=0a274caf0327e1fb64c9db385af7f5163b2a8c90;hpb=60a743910478b70e39dcefa5e1b752ec8a93880e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 0a274caf..3fdb5ced 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -2,6 +2,7 @@ import type { JSONSchemaType } from 'ajv'; +import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; import type { ChargingStation } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { @@ -14,7 +15,7 @@ import { OCPPVersion, } from '../../../types'; import { logger } from '../../../utils'; -import { OCPP20ServiceUtils, OCPPIncomingRequestService } from '../internal'; +import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService'; const moduleName = 'OCPP20IncomingRequestService'; @@ -23,9 +24,9 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { private incomingRequestHandlers: Map; public constructor() { - if (new.target?.name === moduleName) { - throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); - } + // if (new.target?.name === moduleName) { + // throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); + // } super(OCPPVersion.VERSION_20); this.incomingRequestHandlers = new Map([ [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)], @@ -34,13 +35,17 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { [ OCPP20IncomingRequestCommand.CLEAR_CACHE, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/ClearCacheRequest.json', + 'assets/json-schemas/ocpp/2.0/ClearCacheRequest.json', moduleName, 'constructor' ), ], ]); - this.validatePayload.bind(this); + this.validatePayload = this.validatePayload.bind(this) as ( + chargingStation: ChargingStation, + commandName: OCPP20IncomingRequestCommand, + commandPayload: JsonType + ) => boolean; } public async incomingRequestHandler( @@ -52,7 +57,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { let response: JsonType; if ( chargingStation.getOcppStrictCompliance() === true && - chargingStation.isInPendingState() === true && + chargingStation.inPendingState() === true && (commandName === OCPP20IncomingRequestCommand.REQUEST_START_TRANSACTION || commandName === OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION) ) { @@ -70,7 +75,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { if ( chargingStation.isRegistered() === true || (chargingStation.getOcppStrictCompliance() === false && - chargingStation.isInUnknownState() === true) + chargingStation.inUnknownState() === true) ) { if ( this.incomingRequestHandlers.has(commandName) === true &&