From: Jérôme Benoit Date: Sun, 2 Oct 2022 10:16:43 +0000 (+0200) Subject: OCPP: Cleanup helpers X-Git-Tag: v1.1.75~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fd3c56d100bd07942aa29905b8efd1e47c58c494;p=e-mobility-charging-stations-simulator.git OCPP: Cleanup helpers 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 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(