)
await this.storage?.open()
}
+ this.uiServer.setChargingStationTemplates(
+ Configuration.getStationTemplateUrls()?.map(stationTemplateUrl =>
+ buildTemplateName(stationTemplateUrl.file)
+ )
+ )
if (
!this.uiServerStarted &&
Configuration.getConfigurationSection<UIServerConfiguration>(
provisioned: stationTemplateUrl.provisionedNumberOfStations ?? 0,
started: 0,
})
- this.uiServer.chargingStationTemplates.add(templateName)
}
if (this.templateStatistics.size !== stationTemplateUrls.length) {
console.error(
this.uiServer.stop()
this.uiServerStarted = false
}
- this.initializeCounters()
// FIXME: initialize worker implementation only if the worker section has changed
this.initializeWorkerImplementation(
Configuration.getConfigurationSection<WorkerConfiguration>(ConfigurationSection.worker)
const moduleName = 'AbstractUIServer'
export abstract class AbstractUIServer {
- public readonly chargingStationTemplates: Set<string>
protected readonly httpServer: Http2Server | Server
-
protected readonly responseHandlers: Map<
`${string}-${string}-${string}-${string}-${string}`,
ServerResponse | WebSocket
protected readonly uiServices: Map<ProtocolVersion, AbstractUIService>
private readonly chargingStations: Map<string, ChargingStationData>
+ private readonly chargingStationTemplates: Set<string>
public constructor (protected readonly uiServerConfiguration: UIServerConfiguration) {
this.chargingStations = new Map<string, ChargingStationData>()
return this.chargingStations.size
}
+ public getChargingStationTemplates (): string[] {
+ return [...this.chargingStationTemplates.values()]
+ }
+
public hasChargingStationData (hashId: string): boolean {
return this.chargingStations.has(hashId)
}
+ public hasChargingStationTemplates (template: string): boolean {
+ return this.chargingStationTemplates.has(template)
+ }
+
public hasResponseHandler (uuid: `${string}-${string}-${string}-${string}-${string}`): boolean {
return this.responseHandlers.has(uuid)
}
}
}
+ public setChargingStationTemplates (templates: string[] | undefined): void {
+ if (templates == null) {
+ return
+ }
+ for (const template of templates) {
+ this.chargingStationTemplates.add(template)
+ }
+ }
+
public abstract start (): void
public stop (): void {
status: ResponseStatus.FAILURE,
} satisfies ResponsePayload
}
- if (!this.uiServer.chargingStationTemplates.has(template)) {
+ if (!this.uiServer.hasChargingStationTemplates(template)) {
return {
errorMessage: `Template '${template}' not found`,
status: ResponseStatus.FAILURE,
private handleListTemplates (): ResponsePayload {
return {
status: ResponseStatus.SUCCESS,
- templates: [...this.uiServer.chargingStationTemplates.values()],
+ templates: this.uiServer.getChargingStationTemplates(),
} satisfies ResponsePayload
}