+ private async waitChargingStationsStopped(): Promise<string> {
+ return new Promise<string>((resolve, reject) => {
+ const waitTimeout = setTimeout(() => {
+ const message = `Timeout ${formatDurationMilliSeconds(
+ Constants.STOP_CHARGING_STATIONS_TIMEOUT,
+ )} reached at stopping charging stations`;
+ console.warn(chalk.yellow(message));
+ reject(new Error(message));
+ }, Constants.STOP_CHARGING_STATIONS_TIMEOUT);
+ waitChargingStationEvents(
+ this,
+ ChargingStationWorkerMessageEvents.stopped,
+ this.numberOfChargingStations,
+ )
+ .then(() => {
+ resolve('Charging stations stopped');
+ })
+ .catch(reject)
+ .finally(() => {
+ clearTimeout(waitTimeout);
+ });
+ });
+ }
+
+ private initializeWorkerImplementation(workerConfiguration: WorkerConfiguration): void {
+ let elementsPerWorker: number | undefined;
+ if (workerConfiguration?.elementsPerWorker === 'auto') {
+ elementsPerWorker =
+ this.numberOfChargingStations > availableParallelism()
+ ? Math.round(this.numberOfChargingStations / (availableParallelism() * 1.5))
+ : 1;
+ }