X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FAutomaticTransactionGenerator.ts;h=efc3769ac45b273c65cefbc2f5beea549dc3224d;hb=42b8cf5cdca8eaab1e7442f7c92c2a5ed97434f6;hp=ebfd8c196fd026b0ca673bba3cb5a38bff8a3e9d;hpb=3e888c6560f1a59e1d34f06d465e698305c90aea;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index ebfd8c19..efc3769a 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -12,7 +12,6 @@ import { BaseError } from '../exception'; import { PerformanceStatistics } from '../performance'; import { AuthorizationStatus, - ConnectorStatusEnum, RequestCommand, type StartTransactionRequest, type StartTransactionResponse, @@ -305,56 +304,51 @@ export class AutomaticTransactionGenerator extends AsyncResource { ); return false; } - if ( - this.chargingStation.getConnectorStatus(connectorId)?.status === - ConnectorStatusEnum.Unavailable - ) { - logger.info( - `${this.logPrefix( - connectorId, - )} entered in transaction loop while the connector ${connectorId} status is unavailable`, - ); - return false; - } return true; } private async waitChargingStationServiceInitialization(connectorId: number): Promise { - if (!this.chargingStation?.ocppRequestService) { - logger.info( - `${this.logPrefix( - connectorId, - )} transaction loop waiting for charging station service to be initialized`, - ); - do { - await sleep(Constants.CHARGING_STATION_ATG_INITIALIZATION_TIME); - } while (!this.chargingStation?.ocppRequestService); + let logged = false; + while (!this.chargingStation?.ocppRequestService) { + if (!logged) { + logger.info( + `${this.logPrefix( + connectorId, + )} transaction loop waiting for charging station service to be initialized`, + ); + logged = true; + } + await sleep(Constants.CHARGING_STATION_ATG_INITIALIZATION_TIME); } } private async waitChargingStationAvailable(connectorId: number): Promise { - if (!this.chargingStation.isChargingStationAvailable()) { - logger.info( - `${this.logPrefix( - connectorId, - )} transaction loop waiting for charging station to be available`, - ); - do { - await sleep(Constants.CHARGING_STATION_ATG_AVAILABILITY_TIME); - } while (!this.chargingStation.isChargingStationAvailable()); + let logged = false; + while (!this.chargingStation.isChargingStationAvailable()) { + if (!logged) { + logger.info( + `${this.logPrefix( + connectorId, + )} transaction loop waiting for charging station to be available`, + ); + logged = true; + } + await sleep(Constants.CHARGING_STATION_ATG_AVAILABILITY_TIME); } } private async waitConnectorAvailable(connectorId: number): Promise { - if (!this.chargingStation.isConnectorAvailable(connectorId)) { - logger.info( - `${this.logPrefix( - connectorId, - )} transaction loop waiting for connector ${connectorId} to be available`, - ); - do { - await sleep(Constants.CHARGING_STATION_ATG_AVAILABILITY_TIME); - } while (!this.chargingStation.isConnectorAvailable(connectorId)); + let logged = false; + while (!this.chargingStation.isConnectorAvailable(connectorId)) { + if (!logged) { + logger.info( + `${this.logPrefix( + connectorId, + )} transaction loop waiting for connector ${connectorId} to be available`, + ); + logged = true; + } + await sleep(Constants.CHARGING_STATION_ATG_AVAILABILITY_TIME); } }