import WebSocket, { type RawData } from 'ws';
import {
- AuthorizedTagsCache,
AutomaticTransactionGenerator,
ChargingStationConfigurationUtils,
ChargingStationUtils,
ChargingStationWorkerBroadcastChannel,
+ IdTagsCache,
MessageChannelUtils,
SharedLRUCache,
} from './internal';
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;
this.requests = new Map<string, CachedRequest>();
this.messageBuffer = new Set<string>();
this.sharedLRUCache = SharedLRUCache.getInstance();
- this.authorizedTagsCache = AuthorizedTagsCache.getInstance();
+ this.idTagsCache = IdTagsCache.getInstance();
this.chargingStationWorkerBroadcastChannel = new ChargingStationWorkerBroadcastChannel(this);
this.initialize();
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 {
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);
`${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) &&
).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
);
}
if (
connectorId > 0 &&
- (this.getConnectorStatus(connectorId)?.transactionStarted === undefined ||
- this.getConnectorStatus(connectorId)?.transactionStarted === null)
+ Utils.isNullOrUndefined(this.getConnectorStatus(connectorId)?.transactionStarted)
) {
this.initializeConnectorStatus(connectorId);
}