X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils%2FMessageChannelUtils.ts;h=212ed5f20124c419fbf3933b6e2855dfcb482a07;hb=244c1396e337032577839fa13e9191d5e943864f;hp=842b8bfe5644332e52acb7c6d833cfcc552a4bce;hpb=66a7748ddeda8c94d7562a1ce58d440319654a4c;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/MessageChannelUtils.ts b/src/utils/MessageChannelUtils.ts index 842b8bfe..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,15 +57,18 @@ export const buildPerformanceStatisticsMessage = ( } } -const buildChargingStationDataPayload = (chargingStation: ChargingStation): ChargingStationData => { +export const buildChargingStationDataPayload = ( + chargingStation: ChargingStation +): ChargingStationData => { return { started: chargingStation.started, - stationInfo: chargingStation.stationInfo, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + stationInfo: chargingStation.stationInfo!, connectors: buildConnectorsStatus(chargingStation), evses: buildEvsesStatus(chargingStation, OutputFormat.worker), // eslint-disable-next-line @typescript-eslint/no-non-null-assertion ocppConfiguration: chargingStation.ocppConfiguration!, - wsState: chargingStation?.wsConnection?.readyState, + wsState: chargingStation.wsConnection?.readyState, bootNotificationResponse: chargingStation.bootNotificationResponse, ...(chargingStation.automaticTransactionGenerator != null && { automaticTransactionGenerator: