X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=575d70962c21022c1888ebac3f1ec1e90079f18b;hb=c37528f1b44c116d0e714194e881d94951efdef6;hp=185eab5e504735608d2b3f184948fed422fcada1;hpb=7d75bee1fb4f5946cba9bd453604ae9c359595c1;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 185eab5e..575d7096 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -85,7 +85,7 @@ export default class ChargingStation { } public getRandomTagId(): string { - const index = Math.floor(Math.random() * this.authorizedTags.length); + const index = Math.floor(Utils.secureRandom() * this.authorizedTags.length); return this.authorizedTags[index]; } @@ -453,7 +453,7 @@ export default class ChargingStation { const stationInfo: ChargingStationInfo = stationTemplateFromFile ?? {} as ChargingStationInfo; if (!Utils.isEmptyArray(stationTemplateFromFile.power)) { stationTemplateFromFile.power = stationTemplateFromFile.power as number[]; - const powerArrayRandomIndex = Math.floor(Math.random() * stationTemplateFromFile.power.length); + const powerArrayRandomIndex = Math.floor(Utils.secureRandom() * stationTemplateFromFile.power.length); stationInfo.maxPower = stationTemplateFromFile.powerUnit === PowerUnits.KILO_WATT ? stationTemplateFromFile.power[powerArrayRandomIndex] * 1000 : stationTemplateFromFile.power[powerArrayRandomIndex]; @@ -899,7 +899,7 @@ export default class ChargingStation { if (webSocketPingInterval > 0 && !this.webSocketPingSetInterval) { this.webSocketPingSetInterval = setInterval(() => { if (this.isWebSocketConnectionOpened()) { - this.wsConnection.ping((): void => { }); + this.wsConnection.ping((): void => { /* This is intentional */ }); } }, webSocketPingInterval * 1000); logger.info(this.logPrefix() + ' WebSocket ping started every ' + Utils.secondsToHHMMSS(webSocketPingInterval)); @@ -924,7 +924,7 @@ export default class ChargingStation { indexUrl = this.index % supervisionUrls.length; } else { // Get a random url - indexUrl = Math.floor(Math.random() * supervisionUrls.length); + indexUrl = Math.floor(Utils.secureRandom() * supervisionUrls.length); } return new URL(supervisionUrls[indexUrl]); }