X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=7eef4100355d0113f23848f72bac8c26c9b38acc;hb=0557254bd178be09468f48b28c570efa4ada83b2;hp=ccc9526369c24ceae553ed2f702b310be654c7b6;hpb=2ca0ea909c319b763257cedb8ba421c3f22823fd;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ccc95263..7eef4100 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -26,20 +26,6 @@ import { getConfigurationKey, setConfigurationKeyValue, } from './ConfigurationKeyUtils'; -import { IdTagsCache } from './IdTagsCache'; -import { - OCPP16IncomingRequestService, - OCPP16RequestService, - OCPP16ResponseService, - OCPP16ServiceUtils, - OCPP20IncomingRequestService, - OCPP20RequestService, - OCPP20ResponseService, - type OCPPIncomingRequestService, - type OCPPRequestService, - OCPPServiceUtils, -} from './ocpp'; -import { SharedLRUCache } from './SharedLRUCache'; import { buildConnectorsMap, checkConnectorsConfiguration, @@ -62,7 +48,21 @@ import { propagateSerialNumber, stationTemplateToStationInfo, warnTemplateKeysDeprecation, -} from './Utils'; +} from './Helpers'; +import { IdTagsCache } from './IdTagsCache'; +import { + OCPP16IncomingRequestService, + OCPP16RequestService, + OCPP16ResponseService, + OCPP16ServiceUtils, + OCPP20IncomingRequestService, + OCPP20RequestService, + OCPP20ResponseService, + type OCPPIncomingRequestService, + type OCPPRequestService, + OCPPServiceUtils, +} from './ocpp'; +import { SharedLRUCache } from './SharedLRUCache'; import { BaseError, OCPPError } from '../exception'; import { PerformanceStatistics } from '../performance'; import { @@ -936,7 +936,7 @@ export class ChargingStation { ); } - public getReservationOnConnectorId0Enabled(): boolean { + public getReserveConnectorZeroSupported(): boolean { return convertToBoolean( getConfigurationKey(this, StandardParametersKey.ReserveConnectorZeroSupported)!.value, ); @@ -1055,23 +1055,24 @@ 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, connectorId?: number, ): boolean { const reservationExists = !isUndefined(this.getReservationBy('reservationId', reservationId)); - const userReservationExists = - !isUndefined(idTag) && isUndefined(this.getReservationBy('idTag', idTag!)) ? false : true; - const notConnectorZero = isUndefined(connectorId) ? true : connectorId! > 0; - const freeConnectorsAvailable = this.getNumberOfReservableConnectors() > 0; - return ( - !reservationExists && !userReservationExists && notConnectorZero && freeConnectorsAvailable - ); + if (arguments.length === 1) { + return !reservationExists; + } else if (arguments.length > 1) { + const userReservationExists = + !isUndefined(idTag) && isUndefined(this.getReservationBy('idTag', idTag!)) ? false : true; + const notConnectorZero = isUndefined(connectorId) ? true : connectorId! > 0; + const freeConnectorsAvailable = this.getNumberOfReservableConnectors() > 0; + return ( + !reservationExists && !userReservationExists && notConnectorZero && freeConnectorsAvailable + ); + } + return false; } private getNumberOfReservableConnectors(): number {