From: Jérôme Benoit Date: Fri, 24 Mar 2023 18:31:04 +0000 (+0100) Subject: feat(simulator): wait when necessary between phases at firmware update X-Git-Tag: v1.2.0-0~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=380ccc42b2a771c64c49e5e6d65806c9e80e4117;p=e-mobility-charging-stations-simulator.git feat(simulator): wait when necessary between phases at firmware update simulation 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 b22e7e49..718f2f90 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -1045,6 +1045,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { status: OCPP16FirmwareStatus.Downloaded, }); chargingStation.stationInfo.firmwareStatus = OCPP16FirmwareStatus.Downloaded; + let wasTransactionsStarted = false; let transactionsStarted: boolean; do { let trxCount = 0; @@ -1065,6 +1066,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ); await Utils.sleep(waitTime); transactionsStarted = true; + wasTransactionsStarted = true; } else { for (const connectorId of chargingStation.connectors.keys()) { if ( @@ -1087,7 +1089,8 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { transactionsStarted = false; } } while (transactionsStarted); - await Utils.sleep(Utils.getRandomInteger(maxDelay, minDelay) * 1000); + !wasTransactionsStarted && + (await Utils.sleep(Utils.getRandomInteger(maxDelay, minDelay) * 1000)); if ( ChargingStationUtils.checkChargingStation(chargingStation, chargingStation.logPrefix()) === false