// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
-import { ChargingStationWorkerData, WorkerMessage, WorkerMessageEvents } from '../types/Worker';
+import { ChargingStationWorkerData, ChargingStationWorkerMessage, ChargingStationWorkerMessageEvents } from '../types/ChargingStationWorker';
import Configuration from '../utils/Configuration';
import { Storage } from '../performance/storage/Storage';
private static workerImplementation: WorkerAbstract | null = null;
private static storage: Storage;
private static numberOfChargingStations: number;
- private version: string = version;
+ private readonly version: string = version;
private started: boolean;
- private workerScript: string;
+ private readonly workerScript: string;
private constructor() {
this.started = false;
} catch (error) {
console.error(chalk.red('Bootstrap start error '), error);
}
+ } else {
+ console.error(chalk.red('Cannot start an already started charging stations simulator'));
}
}
if (isMainThread && this.started) {
await Bootstrap.workerImplementation.stop();
await Bootstrap.storage.close();
+ } else {
+ console.error(chalk.red('Trying to stop the charging stations simulator while not started'));
}
this.started = false;
}
poolOptions: {
workerChoiceStrategy: Configuration.getWorkerPoolStrategy()
},
- messageHandler: async (msg: WorkerMessage) => {
- if (msg.id === WorkerMessageEvents.PERFORMANCE_STATISTICS) {
+ messageHandler: async (msg: ChargingStationWorkerMessage) => {
+ if (msg.id === ChargingStationWorkerMessageEvents.PERFORMANCE_STATISTICS) {
await Bootstrap.storage.storePerformanceStatistics(msg.data);
}
}