X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FMessageChannelUtils.ts;h=212ed5f20124c419fbf3933b6e2855dfcb482a07;hb=244c1396e337032577839fa13e9191d5e943864f;hp=a61bf94ab29d34879805982692a867b2e7285f4b;hpb=5199f9fdf202eb534948f165a0994e1993675aa8;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/MessageChannelUtils.ts b/src/utils/MessageChannelUtils.ts index a61bf94a..212ed5f2 100644 --- a/src/utils/MessageChannelUtils.ts +++ b/src/utils/MessageChannelUtils.ts @@ -12,6 +12,15 @@ import { type Statistics } from '../types/index.js' +export const buildAddedMessage = ( + chargingStation: ChargingStation +): ChargingStationWorkerMessage => { + return { + event: ChargingStationWorkerMessageEvents.added, + data: buildChargingStationDataPayload(chargingStation) + } +} + export const buildStartedMessage = ( chargingStation: ChargingStation ): ChargingStationWorkerMessage => { @@ -48,7 +57,9 @@ export const buildPerformanceStatisticsMessage = ( } } -const buildChargingStationDataPayload = (chargingStation: ChargingStation): ChargingStationData => { +export const buildChargingStationDataPayload = ( + chargingStation: ChargingStation +): ChargingStationData => { return { started: chargingStation.started, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion