X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FBootstrap.ts;h=4f72d6dfdffef0ca7a65cb24a2103f19558ced6f;hb=3b09e788c6dab8e5a8b3314e8e69ede16ff82fcc;hp=34ac90f3f3e4ba2e211d47ef3639907e5ccff066;hpb=8ae4dcf159bf29835de7fd1edd7978aa8a3ee76b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 34ac90f3..4f72d6df 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -15,6 +15,7 @@ import { BaseError } from '../exception/index.js' import { type Storage, StorageFactory } from '../performance/index.js' import { type ChargingStationData, + type ChargingStationInfo, type ChargingStationOptions, type ChargingStationWorkerData, type ChargingStationWorkerEventError, @@ -59,7 +60,7 @@ enum exitCodes { export class Bootstrap extends EventEmitter { private static instance: Bootstrap | null = null - private workerImplementation?: WorkerAbstract + private workerImplementation?: WorkerAbstract private readonly uiServer: AbstractUIServer private storage?: Storage private readonly templateStatistics: Map @@ -346,7 +347,10 @@ export class Bootstrap extends EventEmitter { : 1 break } - this.workerImplementation = WorkerFactory.getWorkerImplementation( + this.workerImplementation = WorkerFactory.getWorkerImplementation< + ChargingStationWorkerData, + ChargingStationInfo + >( join( dirname(fileURLToPath(import.meta.url)), `ChargingStationWorker${extname(fileURLToPath(import.meta.url))}` @@ -541,13 +545,13 @@ export class Bootstrap extends EventEmitter { index: number, templateFile: string, options?: ChargingStationOptions - ): Promise { + ): Promise { 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)), @@ -561,6 +565,7 @@ export class Bootstrap extends EventEmitter { const templateStatistics = this.templateStatistics.get(buildTemplateName(templateFile))! ++templateStatistics.added templateStatistics.indexes.add(index) + return stationInfo } private gracefulShutdown (): void {