X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=575d70962c21022c1888ebac3f1ec1e90079f18b;hb=c37528f1b44c116d0e714194e881d94951efdef6;hp=fe2b5d8dd9abe16644fc6c3594b31f322cd594a0;hpb=0dad4bda6c02b3c62b8f9465a82d33f721dfbd13;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index fe2b5d8d..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]; @@ -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]); }