X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FMessageChannelUtils.ts;h=36f797f5eb88feb3a9f5e0a4b6ea978b660a9f9b;hb=09379a0da5842414aa5835130a101aec11e724d5;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..36f797f5 100644 --- a/src/utils/MessageChannelUtils.ts +++ b/src/utils/MessageChannelUtils.ts @@ -12,6 +12,24 @@ import { type Statistics } from '../types/index.js' +export const buildAddedMessage = ( + chargingStation: ChargingStation +): ChargingStationWorkerMessage => { + return { + event: ChargingStationWorkerMessageEvents.added, + data: buildChargingStationDataPayload(chargingStation) + } +} + +export const buildDeletedMessage = ( + chargingStation: ChargingStation +): ChargingStationWorkerMessage => { + return { + event: ChargingStationWorkerMessageEvents.deleted, + data: buildChargingStationDataPayload(chargingStation) + } +} + export const buildStartedMessage = ( chargingStation: ChargingStation ): ChargingStationWorkerMessage => { @@ -48,15 +66,19 @@ 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, + supervisionUrl: chargingStation.wsConnectionUrl.href, + wsState: chargingStation.wsConnection?.readyState, bootNotificationResponse: chargingStation.bootNotificationResponse, ...(chargingStation.automaticTransactionGenerator != null && { automaticTransactionGenerator: