X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fbroadcast-channel%2FChargingStationWorkerBroadcastChannel.ts;h=422c964bcbedd232d28f1a7005efc09c7e5e989b;hb=04c32a956205b29f2f5d7a1ac1b28a9f3e9d39c1;hp=c9c2d84a512bfefacc2d944d1c086851ed83c3f7;hpb=e1d9a0f4d6ff1a90048e9a694fd12b7031cc6961;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts index c9c2d84a..422c964b 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -15,6 +15,7 @@ import { DataTransferStatus, type DiagnosticsStatusNotificationRequest, type DiagnosticsStatusNotificationResponse, + type EmptyObject, type FirmwareStatusNotificationRequest, type FirmwareStatusNotificationResponse, type HeartbeatRequest, @@ -36,17 +37,17 @@ import { } from '../../types'; import { Constants, convertToInt, isEmptyObject, isNullOrUndefined, logger } from '../../utils'; import type { ChargingStation } from '../ChargingStation'; -import { ChargingStationConfigurationUtils } from '../ChargingStationConfigurationUtils'; +import { getConfigurationKey } from '../ChargingStationConfigurationUtils'; import { OCPP16ServiceUtils } from '../ocpp'; const moduleName = 'ChargingStationWorkerBroadcastChannel'; type CommandResponse = + | EmptyObject | StartTransactionResponse | StopTransactionResponse | AuthorizeResponse | BootNotificationResponse - | StatusNotificationResponse | HeartbeatResponse | DataTransferResponse; @@ -173,11 +174,10 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne [ BroadcastChannelProcedureName.METER_VALUES, async (requestPayload?: BroadcastChannelRequestPayload) => { - const configuredMeterValueSampleInterval = - ChargingStationConfigurationUtils.getConfigurationKey( - chargingStation, - StandardParametersKey.MeterValueSampleInterval, - ); + const configuredMeterValueSampleInterval = getConfigurationKey( + chargingStation, + StandardParametersKey.MeterValueSampleInterval, + ); return this.chargingStation.ocppRequestService.requestHandler< MeterValuesRequest, MeterValuesResponse @@ -239,8 +239,8 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne ], ]); this.chargingStation = chargingStation; - this.onmessage = this.requestHandler.bind(this) as (message: MessageEvent) => void; - this.onmessageerror = this.messageErrorHandler.bind(this) as (message: MessageEvent) => void; + this.onmessage = this.requestHandler.bind(this) as (message: unknown) => void; + this.onmessageerror = this.messageErrorHandler.bind(this) as (message: unknown) => void; } private async requestHandler(messageEvent: MessageEvent): Promise { @@ -253,12 +253,12 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne } const [uuid, command, requestPayload] = validatedMessageEvent.data as BroadcastChannelRequest; if ( - !isNullOrUndefined(requestPayload?.hashIds) && - requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false + !isNullOrUndefined(requestPayload.hashIds) && + requestPayload.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false ) { return; } - if (!isNullOrUndefined(requestPayload?.hashId)) { + if (!isNullOrUndefined(requestPayload.hashId)) { logger.error( `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' array instead`, );