From: Jérôme Benoit Date: Mon, 25 Jan 2021 20:49:39 +0000 (+0100) Subject: Type properly station worker data. X-Git-Tag: v1.0.1-0~111 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=46eb543c2eb31661c078b7e9697dacc593d83e5e;p=e-mobility-charging-stations-simulator.git Type properly station worker data. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/StationWorker.ts b/src/charging-station/StationWorker.ts index 8ddffc4e..1b529190 100644 --- a/src/charging-station/StationWorker.ts +++ b/src/charging-station/StationWorker.ts @@ -1,4 +1,4 @@ -import { WorkerData, WorkerEvents } from '../types/Worker'; +import { StationWorkerData, WorkerEvents } from '../types/Worker'; import { isMainThread, parentPort, workerData } from 'worker_threads'; import ChargingStation from './ChargingStation'; @@ -22,7 +22,7 @@ function addListener() { }); } -function startChargingStation(data: WorkerData) { +function startChargingStation(data: StationWorkerData) { const station = new ChargingStation(data.index , data.templateFile); station.start(); } diff --git a/src/start.ts b/src/start.ts index c0eab941..5aaeea9f 100644 --- a/src/start.ts +++ b/src/start.ts @@ -1,6 +1,6 @@ import Configuration from './utils/Configuration'; +import { StationWorkerData } from './types/Worker'; import Utils from './utils/Utils'; -import { WorkerData } from './types/Worker'; import WorkerFactory from './worker/WorkerFactory'; import Wrk from './worker/Wrk'; @@ -16,7 +16,7 @@ class Bootstrap { try { const nbStations = stationURL.numberOfStations ? stationURL.numberOfStations : 0; for (let index = 1; index <= nbStations; index++) { - const workerData: WorkerData = { + const workerData: StationWorkerData = { index, templateFile: stationURL.file }; diff --git a/src/types/Worker.ts b/src/types/Worker.ts index 20c44882..6ec9e999 100644 --- a/src/types/Worker.ts +++ b/src/types/Worker.ts @@ -6,8 +6,9 @@ export enum WorkerProcessType { STATIC_POOL = 'staticPool' } -// FIXME: make it more generic -export interface WorkerData { +export interface WorkerData { } + +export interface StationWorkerData extends WorkerData { index: number; templateFile: string; }