-import { StationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
+import { ChargingStationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
import Configuration from '../utils/Configuration';
import { Storage } from '../utils/performance-storage/Storage';
private constructor() {
this.started = false;
- this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'StationWorker.js');
+ this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'ChargingStationWorker.js');
this.initWorkerImplementation();
Bootstrap.storage = StorageFactory.getStorage(Configuration.getPerformanceStorage().type, Configuration.getPerformanceStorage().URI, this.logPrefix());
Configuration.setConfigurationChangeCallback(async () => Bootstrap.getInstance().restart());
try {
const nbStations = stationURL.numberOfStations ? stationURL.numberOfStations : 0;
for (let index = 1; index <= nbStations; index++) {
- const workerData: StationWorkerData = {
+ const workerData: ChargingStationWorkerData = {
index,
templateFile: path.join(path.resolve(__dirname, '../'), 'assets', 'station-templates', path.basename(stationURL.file))
};
}
private initWorkerImplementation() {
- Bootstrap.workerImplementation = WorkerFactory.getWorkerImplementation<StationWorkerData>(this.workerScript, Configuration.getWorkerProcess(),
+ Bootstrap.workerImplementation = WorkerFactory.getWorkerImplementation<ChargingStationWorkerData>(this.workerScript, Configuration.getWorkerProcess(),
{
startDelay: Configuration.getWorkerStartDelay(),
poolMaxSize: Configuration.getWorkerPoolMaxSize(),
// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
-import { StationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
+import { ChargingStationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
import { parentPort, workerData } from 'worker_threads';
import ChargingStation from './ChargingStation';
// Conditionally export ThreadWorker instance for pool usage
export let threadWorker: ThreadWorker;
if (Utils.workerPoolInUse()) {
- threadWorker = new ThreadWorker<StationWorkerData>(startChargingStation, { maxInactiveTime: Constants.WORKER_POOL_MAX_INACTIVE_TIME, async: false });
+ threadWorker = new ThreadWorker<ChargingStationWorkerData>(startChargingStation, { maxInactiveTime: Constants.WORKER_POOL_MAX_INACTIVE_TIME, async: false });
} else {
// Add message listener to start charging station from main thread
addMessageListener();
*
* @param data workerData
*/
-function startChargingStation(data: StationWorkerData): void {
+function startChargingStation(data: ChargingStationWorkerData): void {
const station = new ChargingStation(data.index, data.templateFile);
station.start();
}