X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=4f65a4e6a0c28122cf37e877daf7b4d953973670;hb=517ffa58b673e8ece31c6520d0f2331848fc05ed;hp=6050a73efee3b0402212f1d4d5da34174d4a238b;hpb=692f2f64aed9c4b79f43036c3318566484410b33;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 6050a73e..4f65a4e6 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -10,11 +10,11 @@ import merge from 'just-merge'; import WebSocket, { type RawData } from 'ws'; import { - AuthorizedTagsCache, AutomaticTransactionGenerator, ChargingStationConfigurationUtils, ChargingStationUtils, ChargingStationWorkerBroadcastChannel, + IdTagsCache, MessageChannelUtils, SharedLRUCache, } from './internal'; @@ -103,7 +103,7 @@ export class ChargingStation { public stationInfo!: ChargingStationInfo; public started: boolean; public starting: boolean; - public authorizedTagsCache: AuthorizedTagsCache; + public idTagsCache: IdTagsCache; public automaticTransactionGenerator!: AutomaticTransactionGenerator | undefined; public ocppConfiguration!: ChargingStationOcppConfiguration | undefined; public wsConnection!: WebSocket | null; @@ -141,7 +141,7 @@ export class ChargingStation { this.requests = new Map(); this.messageBuffer = new Set(); this.sharedLRUCache = SharedLRUCache.getInstance(); - this.authorizedTagsCache = AuthorizedTagsCache.getInstance(); + this.idTagsCache = IdTagsCache.getInstance(); this.chargingStationWorkerBroadcastChannel = new ChargingStationWorkerBroadcastChannel(this); this.initialize(); @@ -164,20 +164,17 @@ export class ChargingStation { public logPrefix = (): string => { return Utils.logPrefix( ` ${ - (Utils.isNotEmptyString(this?.stationInfo?.chargingStationId) && - this?.stationInfo?.chargingStationId) ?? - ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile()) ?? - '' + (Utils.isNotEmptyString(this?.stationInfo?.chargingStationId) + ? this?.stationInfo?.chargingStationId + : ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile())) ?? + 'Error at building log prefix' } |` ); }; - public hasAuthorizedTags(): boolean { - return Utils.isNotEmptyArray( - this.authorizedTagsCache.getAuthorizedTags( - ChargingStationUtils.getAuthorizationFile(this.stationInfo) - ) - ); + public hasIdTags(): boolean { + const idTagsFile = ChargingStationUtils.getIdTagsFile(this.stationInfo); + return Utils.isNotEmptyArray(this.idTagsCache.getIdTags(idTagsFile)); } public getEnableStatistics(): boolean { @@ -869,18 +866,10 @@ export class ChargingStation { logger.error(`${this.logPrefix()} ${errorMsg}`); throw new BaseError(errorMsg); } - // Deprecation template keys section - ChargingStationUtils.warnDeprecatedTemplateKey( - stationTemplate, - 'supervisionUrl', + ChargingStationUtils.warnTemplateKeysDeprecation( this.templateFile, - this.logPrefix(), - "Use 'supervisionUrls' instead" - ); - ChargingStationUtils.convertDeprecatedTemplateKey( stationTemplate, - 'supervisionUrl', - 'supervisionUrls' + this.logPrefix() ); const stationInfo: ChargingStationInfo = ChargingStationUtils.stationTemplateToStationInfo(stationTemplate); @@ -1015,17 +1004,6 @@ export class ChargingStation { `${ChargingStationUtils.getHashId(this.index, this.getTemplateFromFile())}.json` ); this.stationInfo = this.getStationInfo(); - this.saveStationInfo(); - // Avoid duplication of connectors related information in RAM - delete this.stationInfo?.Connectors; - this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl(); - if (this.getEnableStatistics() === true) { - this.performanceStatistics = PerformanceStatistics.getInstance( - this.stationInfo.hashId, - this.stationInfo.chargingStationId, - this.configuredSupervisionUrl - ); - } if ( this.stationInfo.firmwareStatus === FirmwareStatus.Installing && Utils.isNotEmptyString(this.stationInfo.firmwareVersion) && @@ -1044,6 +1022,17 @@ export class ChargingStation { ).toString(); this.stationInfo.firmwareVersion = match?.join('.'); } + this.saveStationInfo(); + // Avoid duplication of connectors related information in RAM + delete this.stationInfo?.Connectors; + this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl(); + if (this.getEnableStatistics() === true) { + this.performanceStatistics = PerformanceStatistics.getInstance( + this.stationInfo.hashId, + this.stationInfo.chargingStationId, + this.configuredSupervisionUrl + ); + } this.bootNotificationRequest = ChargingStationUtils.createBootNotificationRequest( this.stationInfo ); @@ -1331,8 +1320,7 @@ export class ChargingStation { } if ( connectorId > 0 && - (this.getConnectorStatus(connectorId)?.transactionStarted === undefined || - this.getConnectorStatus(connectorId)?.transactionStarted === null) + Utils.isNullOrUndefined(this.getConnectorStatus(connectorId)?.transactionStarted) ) { this.initializeConnectorStatus(connectorId); }