From 380ccc42b2a771c64c49e5e6d65806c9e80e4117 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 24 Mar 2023 19:31:04 +0100 Subject: [PATCH] feat(simulator): wait when necessary between phases at firmware update simulation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.34.1