1 import Configuration from
'./utils/Configuration';
2 import { WorkerData
} from
'./types/Worker';
3 import WorkerFactory from
'./worker/WorkerFactory';
4 import Wrk from
'./worker/Wrk';
9 let numStationsTotal
= 0;
10 const workerImplementation
: Wrk
= WorkerFactory
.getWorkerImpl('./dist/charging-station/StationWorker.js');
11 void workerImplementation
.start();
12 // Start ChargingStation object in worker thread
13 if (Configuration
.getStationTemplateURLs()) {
14 for (const stationURL
of Configuration
.getStationTemplateURLs()) {
16 const nbStations
= stationURL
.numberOfStations
? stationURL
.numberOfStations
: 0;
17 for (let index
= 1; index
<= nbStations
; index
++) {
18 const workerData
: WorkerData
= {
20 templateFile
: stationURL
.file
22 void workerImplementation
.addElement(workerData
);
26 // eslint-disable-next-line no-console
27 console
.error('Charging station start with template file ' + stationURL
.file
+ ' error ', error
);
31 console
.log('No stationTemplateURLs defined in configuration, exiting');
33 if (numStationsTotal
=== 0) {
34 console
.log('No charging station template enabled in configuration, exiting');
36 console
.log(`Charging station simulator started with ${numStationsTotal.toString()} charging station(s) and ${workerImplementation.size}${Configuration.useWorkerPool() ? `/${Configuration.getWorkerPoolMaxSize().toString()}` : ''} worker(s
) concurrently
running (${workerImplementation.maxElementsPerWorker} charging
station(s
) per worker
)`);
39 // eslint-disable-next-line no-console
40 console.error('Bootstrap start error ', error);