X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FChargingStationWorkerBroadcastChannel.ts;h=0c3af5887ee06b494269b426df6736df25374a37;hb=4f317101dedf3e41deaa06cc04ef5beaf79af3bd;hp=159743a049104cd3d9d210b6a799c374c7614aa7;hpb=a5e9befcd2d47dc74838776f7a9ee0fea6fef9c6;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts index 159743a0..0c3af588 100644 --- a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts @@ -38,27 +38,27 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca if (this.isResponse(messageEvent.data)) { return; } - this.validateMessageEvent(messageEvent); + const [uuid, command, requestPayload] = this.validateMessageEvent(messageEvent) + .data as BroadcastChannelRequest; - const [uuid, command, requestPayload] = messageEvent.data as BroadcastChannelRequest; - - if ( - requestPayload?.hashId === undefined && - (requestPayload?.hashIds as string[])?.includes(this.chargingStation.stationInfo.hashId) === - false - ) { - return; - } - if ( - requestPayload?.hashIds === undefined && - requestPayload?.hashId !== this.chargingStation.stationInfo.hashId - ) { - return; - } - if (requestPayload?.hashId !== undefined) { - logger.warn( - `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead` - ); + if (requestPayload?.hashIds !== undefined || requestPayload?.hashId !== undefined) { + if ( + requestPayload?.hashId === undefined && + requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false + ) { + return; + } + if ( + requestPayload?.hashIds === undefined && + requestPayload?.hashId !== this.chargingStation.stationInfo.hashId + ) { + return; + } + if (requestPayload?.hashId !== undefined) { + logger.warn( + `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead` + ); + } } let responsePayload: BroadcastChannelResponsePayload; @@ -97,7 +97,7 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca private messageErrorHandler(messageEvent: MessageEvent): void { logger.error( `${this.chargingStation.logPrefix()} ${moduleName}.messageErrorHandler: Error at handling message:`, - { messageEvent, messageEventData: messageEvent.data } + { messageEvent } ); } @@ -137,7 +137,7 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca true ), idTag: this.chargingStation.getTransactionIdTag(requestPayload.transactionId), - reason: StopTransactionReason.NONE, + ...(requestPayload.reason && { reason: requestPayload.reason }), }); case BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR: this.chargingStation.startAutomaticTransactionGenerator(requestPayload.connectorIds);