import { type Storage, StorageFactory } from '../performance/index.js'
import {
type ChargingStationData,
+ type ChargingStationInfo,
type ChargingStationOptions,
type ChargingStationWorkerData,
type ChargingStationWorkerEventError,
export class Bootstrap extends EventEmitter {
private static instance: Bootstrap | null = null
- private workerImplementation?: WorkerAbstract<ChargingStationWorkerData>
+ private workerImplementation?: WorkerAbstract<ChargingStationWorkerData, ChargingStationInfo>
private readonly uiServer: AbstractUIServer
private storage?: Storage
private readonly templateStatistics: Map<string, TemplateStatistics>
: 1
break
}
- this.workerImplementation = WorkerFactory.getWorkerImplementation<ChargingStationWorkerData>(
+ this.workerImplementation = WorkerFactory.getWorkerImplementation<
+ ChargingStationWorkerData,
+ ChargingStationInfo
+ >(
join(
dirname(fileURLToPath(import.meta.url)),
`ChargingStationWorker${extname(fileURLToPath(import.meta.url))}`
index: number,
templateFile: string,
options?: ChargingStationOptions
- ): Promise<void> {
+ ): Promise<ChargingStationInfo | undefined> {
if (!this.started && !this.starting) {
throw new BaseError(
'Cannot add charging station while the charging stations simulator is not started'
)
}
- await this.workerImplementation?.addElement({
+ const stationInfo = await this.workerImplementation?.addElement({
index,
templateFile: join(
dirname(fileURLToPath(import.meta.url)),
const templateStatistics = this.templateStatistics.get(buildTemplateName(templateFile))!
++templateStatistics.added
templateStatistics.indexes.add(index)
+ return stationInfo
}
private gracefulShutdown (): void {