From: Jérôme Benoit Date: Tue, 22 Feb 2022 19:01:26 +0000 (+0100) Subject: Cleanup OCPP service module name usage X-Git-Tag: v1.1.48~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=909dcf2dda1acb9556a5ec21c252bcca2992ec1c;p=e-mobility-charging-stations-simulator.git Cleanup OCPP service module name usage Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 6cf07805..5b7ac480 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -25,11 +25,13 @@ import logger from '../../../utils/Logger'; import path from 'path'; import tar from 'tar'; +const moduleName = 'OCPPIncomingRequestService'; + export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService { private incomingRequestHandlers: Map; public constructor(chargingStation: ChargingStation) { - if (new.target?.name === 'OCPP16IncomingRequestService') { + if (new.target?.name === moduleName) { throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); } super(chargingStation); diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 3b671d6b..7ec4b019 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -23,9 +23,11 @@ import { SendParams } from '../../../types/ocpp/Requests'; import Utils from '../../../utils/Utils'; import logger from '../../../utils/Logger'; +const moduleName = 'OCPP16RequestService'; + export default class OCPP16RequestService extends OCPPRequestService { public constructor(chargingStation: ChargingStation, ocppResponseService: OCPPResponseService) { - if (new.target?.name === 'OCPP16RequestService') { + if (new.target?.name === moduleName) { throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); } super(chargingStation, ocppResponseService); diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 54815bd6..7f1217fa 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -17,11 +17,13 @@ import { ResponseHandler } from '../../../types/ocpp/Responses'; import Utils from '../../../utils/Utils'; import logger from '../../../utils/Logger'; +const moduleName = 'OCPP16ResponseService'; + export default class OCPP16ResponseService extends OCPPResponseService { private responseHandlers: Map; public constructor(chargingStation: ChargingStation) { - if (new.target?.name === 'OCPP16ResponseService') { + if (new.target?.name === moduleName) { throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); } super(chargingStation);