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();
+ if (
+ this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
+ Utils.isNotEmptyString(this.stationInfo.firmwareVersion) &&
+ Utils.isNotEmptyString(this.stationInfo.firmwareVersionPattern)
+ ) {
+ const patternGroup: number | undefined =
+ this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ??
+ this.stationInfo.firmwareVersion?.split('.').length;
+ const match = this.stationInfo?.firmwareVersion
+ ?.match(new RegExp(this.stationInfo.firmwareVersionPattern))
+ ?.slice(1, patternGroup + 1);
+ const patchLevelIndex = match.length - 1;
+ match[patchLevelIndex] = (
+ Utils.convertToInt(match[patchLevelIndex]) +
+ this.stationInfo.firmwareUpgrade?.versionUpgrade?.step
+ ).toString();
+ this.stationInfo.firmwareVersion = match?.join('.');
+ }
this.saveStationInfo();
// Avoid duplication of connectors related information in RAM
delete this.stationInfo?.Connectors;
status: RegistrationStatusEnumType.ACCEPTED,
};
}
- if (
- this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
- Utils.isNotEmptyString(this.stationInfo.firmwareVersion) &&
- Utils.isNotEmptyString(this.stationInfo.firmwareVersionPattern)
- ) {
- const patternGroup: number | undefined =
- this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ??
- this.stationInfo.firmwareVersion?.split('.').length;
- const match = this.stationInfo?.firmwareVersion
- ?.match(new RegExp(this.stationInfo.firmwareVersionPattern))
- ?.slice(1, patternGroup + 1);
- const patchLevelIndex = match.length - 1;
- match[patchLevelIndex] = (
- Utils.convertToInt(match[patchLevelIndex]) +
- this.stationInfo.firmwareUpgrade?.versionUpgrade?.step
- ).toString();
- this.stationInfo.firmwareVersion = match?.join('.');
- }
}
private initializeOcppServices(): void {