1 import Configuration from
'./utils/Configuration';
2 import { StationTemplateURL
} from
'./types/ConfigurationData';
3 import Wrk from
'./charging-station/Worker';
8 let numStationsTotal
= 0;
9 // Start each ChargingStation object in a worker thread
10 if (Configuration
.getStationTemplateURLs()) {
11 Configuration
.getStationTemplateURLs().forEach((stationURL
: StationTemplateURL
) => {
13 const nbStations
= stationURL
.numberOfStations
? stationURL
.numberOfStations
: 0;
14 numStationsTotal
+= nbStations
;
15 for (let index
= 1; index
<= nbStations
; index
++) {
16 const worker
= new Wrk('./dist/charging-station/StationWorker.js', {
18 templateFile
: stationURL
.file
,
20 worker
.start().catch(() => {});
23 // eslint-disable-next-line no-console
24 console
.log('Charging station start with template file ' + stationURL
.file
+ ' error ' + JSON
.stringify(error
, null, ' '));
28 console
.log('No stationTemplateURLs defined in configuration, exiting');
30 if (numStationsTotal
=== 0) {
31 console
.log('No charging station template enabled in configuration, exiting');
33 console
.log('Charging station simulator started with ' + numStationsTotal
.toString() + ' charging station(s)');
36 // eslint-disable-next-line no-console
37 console
.log('Bootstrap start error ' + JSON
.stringify(error
, null, ' '));