From: Jérôme Benoit Date: Sun, 30 Jul 2023 16:58:41 +0000 (+0200) Subject: refactor: remove uneeded helper in reservation code X-Git-Tag: v1.2.20~78 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=10e8c3e1ea9f4b8bb034bdd8450e5a0db61092e4;p=e-mobility-charging-stations-simulator.git refactor: remove uneeded helper in reservation code Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c379ec7b..7eef4100 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -936,7 +936,7 @@ export class ChargingStation { ); } - public getReservationOnConnectorId0Enabled(): boolean { + public getReserveConnectorZeroSupported(): boolean { return convertToBoolean( getConfigurationKey(this, StandardParametersKey.ReserveConnectorZeroSupported)!.value, ); @@ -1055,10 +1055,6 @@ export class ChargingStation { this.startReservationExpirationSetInterval(); } - public validateIncomingRequestWithReservation(connectorId: number, idTag: string): boolean { - return this.getReservationBy('connectorId', connectorId)?.idTag === idTag; - } - public isConnectorReservable( reservationId: number, idTag?: string, diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 2659458f..87277e88 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -833,8 +833,11 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { chargingStation.getConnectorStatus(0)!.status === OCPP16ChargePointStatus.Reserved; if ( (reserved && - !chargingStation.validateIncomingRequestWithReservation(transactionConnectorId, idTag)) || - (reservedOnConnectorZero && !chargingStation.validateIncomingRequestWithReservation(0, idTag)) + !( + chargingStation.getReservationBy('connectorId', transactionConnectorId)?.idTag === idTag + )) || + (reservedOnConnectorZero && + !(chargingStation.getReservationBy('connectorId', 0)?.idTag === idTag)) ) { return OCPP16Constants.OCPP_RESPONSE_REJECTED; } @@ -1549,7 +1552,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { if (!chargingStation.isConnectorAvailable(connectorId) && connectorId > 0) { return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED; } - if (connectorId === 0 && !chargingStation.getReservationOnConnectorId0Enabled()) { + if (connectorId === 0 && !chargingStation.getReserveConnectorZeroSupported()) { return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED; } if (!(await OCPP16ServiceUtils.isIdTagAuthorized(chargingStation, connectorId, idTag))) {