X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FMessageChannelUtils.ts;h=36f797f5eb88feb3a9f5e0a4b6ea978b660a9f9b;hb=09379a0da5842414aa5835130a101aec11e724d5;hp=a61bf94ab29d34879805982692a867b2e7285f4b;hpb=68220b423c52da387fdf41967dd8c738da0ff52e;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/MessageChannelUtils.ts b/src/utils/MessageChannelUtils.ts index a61bf94a..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,7 +66,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 @@ -57,6 +77,7 @@ const buildChargingStationDataPayload = (chargingStation: ChargingStation): Char evses: buildEvsesStatus(chargingStation, OutputFormat.worker), // eslint-disable-next-line @typescript-eslint/no-non-null-assertion ocppConfiguration: chargingStation.ocppConfiguration!, + supervisionUrl: chargingStation.wsConnectionUrl.href, wsState: chargingStation.wsConnection?.readyState, bootNotificationResponse: chargingStation.bootNotificationResponse, ...(chargingStation.automaticTransactionGenerator != null && {