1 import Configuration from
'./utils/Configuration';
2 import Utils from
'./utils/Utils';
3 import { WorkerData
} from
'./types/Worker';
4 import WorkerFactory from
'./worker/WorkerFactory';
5 import Wrk from
'./worker/Wrk';
10 let numStationsTotal
= 0;
11 const workerImplementation
: Wrk
= WorkerFactory
.getWorkerImpl('./dist/charging-station/StationWorker.js');
12 await workerImplementation
.start();
13 // Start ChargingStation object in worker thread
14 if (Configuration
.getStationTemplateURLs()) {
15 for (const stationURL
of Configuration
.getStationTemplateURLs()) {
17 const nbStations
= stationURL
.numberOfStations
? stationURL
.numberOfStations
: 0;
18 for (let index
= 1; index
<= nbStations
; index
++) {
19 const workerData
: WorkerData
= {
21 templateFile
: stationURL
.file
23 await workerImplementation
.addElement(workerData
);
27 // eslint-disable-next-line no-console
28 console
.error('Charging station start with template file ' + stationURL
.file
+ ' error ', error
);
32 console
.log('No stationTemplateURLs defined in configuration, exiting');
34 if (numStationsTotal
=== 0) {
35 console
.log('No charging station template enabled in configuration, exiting');
37 console
.log(`Charging station simulator started with ${numStationsTotal.toString()} charging station(s) and ${workerImplementation.size}${Utils.workerPoolInUse() ? `/${Configuration.getWorkerPoolMaxSize().toString()}` : ''} worker(s
) concurrently
running (${workerImplementation.maxElementsPerWorker} charging
station(s
) per worker
)`);
40 // eslint-disable-next-line no-console
41 console.error('Bootstrap start error ', error);
46 Bootstrap.start().catch(