X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FIdTagsCache.ts;h=e5d28181b043de2f7faf1f0f9a71d6dbf6ef44df;hb=fc28853f03af7666e2f55a244b787157fddadfbc;hp=48ecb552a90b7c23f0f474952cdb33b87cd49dbb;hpb=e302df1d4573ef07df7c44a210a34e429f571814;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/IdTagsCache.ts b/src/charging-station/IdTagsCache.ts index 48ecb552..e5d28181 100644 --- a/src/charging-station/IdTagsCache.ts +++ b/src/charging-station/IdTagsCache.ts @@ -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( @@ -81,8 +81,10 @@ export class IdTagsCache { private getConnectorAffinityIdTag(chargingStation: ChargingStation, connectorId: number): string { 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) {