From: Jérôme Benoit Date: Mon, 5 Feb 2024 10:57:51 +0000 (+0100) Subject: fix: add charging station at instantiation X-Git-Tag: v1.2.35~5^2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e9e43cff1ad9ba7f75e3ae64a53fceb596454a59;p=e-mobility-charging-stations-simulator.git fix: add charging station at instantiation Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c8eaf5e4..0f4bce43 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -245,6 +245,8 @@ export class ChargingStation extends EventEmitter { this.initialize() + this.add() + this.stationInfo?.autoStart === true && this.start() } @@ -652,7 +654,7 @@ export class ChargingStation extends EventEmitter { } } - public add (): void { + private add (): void { this.emit(ChargingStationEvents.added) } diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index 4eb6e6a0..4fde42c4 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -19,8 +19,8 @@ export let chargingStationWorker: object if (Configuration.workerPoolInUse()) { chargingStationWorker = new ThreadWorker( (data?: ChargingStationWorkerData): void => { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - new ChargingStation(data!.index, data!.templateFile).add() + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, no-new + new ChargingStation(data!.index, data!.templateFile) } ) } else { @@ -35,7 +35,6 @@ if (Configuration.workerPoolInUse()) { message.data.index, message.data.templateFile ) - chargingStation.add() parentPort?.postMessage({ event: WorkerMessageEvents.addedWorkerElement, data: buildChargingStationDataPayload(chargingStation)