From fd3c56d100bd07942aa29905b8efd1e47c58c494 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 2 Oct 2022 12:16:43 +0200 Subject: [PATCH] OCPP: Cleanup helpers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 2 +- src/charging-station/ocpp/1.6/OCPP16RequestService.ts | 3 +-- src/charging-station/ocpp/1.6/OCPP16ResponseService.ts | 3 +-- src/charging-station/ocpp/OCPPServiceUtils.ts | 8 ++++---- src/charging-station/ui-server/UIWebSocketServer.ts | 1 + 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 0597e5ce..c4b8d156 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -303,7 +303,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer ) { if ( this.incomingRequestHandlers.has(commandName) && - OCPP16ServiceUtils.isIncomingRequestCommandSupported(commandName, chargingStation) + OCPP16ServiceUtils.isIncomingRequestCommandSupported(chargingStation, commandName) ) { try { this.validatePayload(chargingStation, commandName, commandPayload); diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index d840e5e9..3bb9f6ce 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -27,7 +27,6 @@ import Constants from '../../../utils/Constants'; import logger from '../../../utils/Logger'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; -import { ChargingStationUtils } from '../../ChargingStationUtils'; import OCPPRequestService from '../OCPPRequestService'; import type OCPPResponseService from '../OCPPResponseService'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; @@ -150,7 +149,7 @@ export default class OCPP16RequestService extends OCPPRequestService { commandParams?: JsonType, params?: RequestParams ): Promise { - if (OCPP16ServiceUtils.isRequestCommandSupported(commandName, chargingStation)) { + if (OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName)) { const requestPayload = this.buildRequestPayload( chargingStation, commandName, diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 041122c5..f72f2c3c 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -43,7 +43,6 @@ import logger from '../../../utils/Logger'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils'; -import { ChargingStationUtils } from '../../ChargingStationUtils'; import OCPPResponseService from '../OCPPResponseService'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; @@ -178,7 +177,7 @@ export default class OCPP16ResponseService extends OCPPResponseService { if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) { if ( this.responseHandlers.has(commandName) && - OCPP16ServiceUtils.isRequestCommandSupported(commandName, chargingStation) + OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName) ) { try { this.validatePayload(chargingStation, commandName, payload); diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index c524d454..163828d5 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -34,8 +34,8 @@ export class OCPPServiceUtils { } public static isRequestCommandSupported( - command: RequestCommand, - chargingStation: ChargingStation + chargingStation: ChargingStation, + command: RequestCommand ): boolean { const isRequestCommand = Object.values(RequestCommand).includes(command); if ( @@ -54,8 +54,8 @@ export class OCPPServiceUtils { } public static isIncomingRequestCommandSupported( - command: IncomingRequestCommand, - chargingStation: ChargingStation + chargingStation: ChargingStation, + command: IncomingRequestCommand ): boolean { const isIncomingRequestCommand = Object.values(IncomingRequestCommand).includes(command); if ( diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index cf1bfa65..1b060783 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -27,6 +27,7 @@ export default class UIWebSocketServer extends AbstractUIServer { } public start(): void { + // eslint-disable-next-line @typescript-eslint/no-unused-vars this.webSocketServer.on('connection', (ws: WebSocket, req: IncomingMessage): void => { if (UIServerUtils.isProtocolAndVersionSupported(ws.protocol) === false) { logger.error( -- 2.34.1