private workerImplementation: WorkerAbstract<ChargingStationWorkerData> | null = null;
private readonly uiServer!: AbstractUIServer;
private readonly storage!: Storage;
- private numberOfChargingStations: number;
+ private numberOfChargingStationTemplates!: number;
+ private numberOfChargingStations!: number;
private readonly version: string = version;
private started: boolean;
private readonly workerScript: string;
'charging-station',
'ChargingStationWorker.js'
);
+ this.initialize();
this.initWorkerImplementation();
Configuration.getUIServer().enabled &&
(this.uiServer = UIServerFactory.getUIServerImplementation(ApplicationProtocol.WS, {
public async start(): Promise<void> {
if (isMainThread && !this.started) {
try {
- this.numberOfChargingStations = 0;
+ this.initialize();
await this.storage?.open();
await this.workerImplementation.start();
this.uiServer?.start();
const stationTemplateUrls = Configuration.getStationTemplateUrls();
+ this.numberOfChargingStationTemplates = stationTemplateUrls.length;
// Start ChargingStation object in worker thread
if (stationTemplateUrls) {
for (const stationTemplateUrl of stationTemplateUrls) {
chalk.green(
`Charging stations simulator ${
this.version
- } started with ${this.numberOfChargingStations.toString()} charging station(s) and ${
+ } started with ${this.numberOfChargingStations.toString()} charging station(s) from ${this.numberOfChargingStationTemplates.toString()} configured charging station template(s) and ${
ChargingStationUtils.workerDynamicPoolInUse()
? `${Configuration.getWorkerPoolMinSize().toString()}/`
: ''
public async restart(): Promise<void> {
await this.stop();
+ this.initialize();
this.initWorkerImplementation();
await this.start();
}
);
}
+ private initialize() {
+ this.numberOfChargingStations = 0;
+ this.numberOfChargingStationTemplates = 0;
+ }
+
private async startChargingStation(
index: number,
stationTemplateUrl: StationTemplateUrl