Cleanup OCPP service module name usage
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 22 Feb 2022 19:01:26 +0000 (20:01 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 22 Feb 2022 19:01:26 +0000 (20:01 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts

index 6cf078059f0d8ec6e3dab8012cedb25ec343c2fc..5b7ac480450eb8f4a5e9c7c26110b59b78a7d0e3 100644 (file)
@@ -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<OCPP16IncomingRequestCommand, IncomingRequestHandler>;
 
   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);
index 3b671d6b809a0464b74da9e271a9cba57e193785..7ec4b019f29a3362c567c337ccfa62dffa07ff29 100644 (file)
@@ -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);
index 54815bd6b4eee8c46c1351cd4c0c658834a63155..7f1217fa45d1791b1337cc673440188dbc190b47 100644 (file)
@@ -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<OCPP16RequestCommand, ResponseHandler>;
 
   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);