X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FIdTagsCache.ts;h=e5d28181b043de2f7faf1f0f9a71d6dbf6ef44df;hb=b1bbdae5d6550f7a6a03b443d60d41debe166a07;hp=7b49b590d17332a47bc17cbe077ebe664b16b7f0;hpb=f911a4af34e676a49f542aec31cbef8075fb65ef;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/IdTagsCache.ts b/src/charging-station/IdTagsCache.ts index 7b49b590..e5d28181 100644 --- a/src/charging-station/IdTagsCache.ts +++ b/src/charging-station/IdTagsCache.ts @@ -32,7 +32,7 @@ export class IdTagsCache { connectorId: number ): string { const hashId = chargingStation.stationInfo.hashId; - const idTagsFile = ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo); + const idTagsFile = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo); switch (distribution) { case IdTagDistribution.RANDOM: return this.getRandomIdTag(hashId, idTagsFile); @@ -58,7 +58,7 @@ export class IdTagsCache { private getRandomIdTag(hashId: string, file: string): string { const idTags = this.getIdTags(file); - const addressableKey = file + hashId; + const addressableKey = this.getIdTagsCacheIndexesAddressableKey(file, hashId); this.idTagsCachesAddressableIndexes.set( addressableKey, Math.floor(Utils.secureRandom() * idTags.length) @@ -68,7 +68,7 @@ export class IdTagsCache { private getRoundRobinIdTag(hashId: string, file: string): string { const idTags = this.getIdTags(file); - const addressableKey = file + hashId; + const addressableKey = this.getIdTagsCacheIndexesAddressableKey(file, hashId); const idTagIndex = this.idTagsCachesAddressableIndexes.get(addressableKey) ?? 0; const idTag = idTags[idTagIndex]; this.idTagsCachesAddressableIndexes.set( @@ -79,10 +79,12 @@ export class IdTagsCache { } private getConnectorAffinityIdTag(chargingStation: ChargingStation, connectorId: number): string { - const file = ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo); + const file = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo); const idTags = this.getIdTags(file); - const hashId = chargingStation.stationInfo.hashId; - const addressableKey = file + hashId; + const addressableKey = this.getIdTagsCacheIndexesAddressableKey( + file, + chargingStation.stationInfo.hashId + ); this.idTagsCachesAddressableIndexes.set( addressableKey, (chargingStation.index - 1 + (connectorId - 1)) % idTags.length @@ -144,6 +146,10 @@ export class IdTagsCache { } } + private getIdTagsCacheIndexesAddressableKey(prefix: string, uid: string): string { + return `${prefix}${uid}`; + } + private getIdTagsFromFile(file: string): string[] { let idTags: string[] = []; if (file) {