- templateFile: stationURL.file,
- }, numStationsTotal);
- worker.start().catch(() => {});
+ templateFile: stationURL.file
+ } as WorkerData;
+ if(counter === 0 || counter === chargingStationsPerWorker) {
+ // Start new worker with one charging station
+ worker = await new Wrk('./dist/charging-station/StationWorker.js', workerData, numStationsTotal);
+ worker.start().catch(() => {});
+ counter = 0;
+ // Start workers sequentially to optimize memory at start time
+ await Utils.sleep(500);
+ } else {
+ // Add new charging station to existing Worker
+ worker.startNewChargingStation(workerData, numStationsTotal)
+ }
+ counter++;
+ // Start charging station sequentially to optimize memory at start time
+ numConcurrentWorkers = worker.concurrentWorkers;