X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FChargingStationWorkerBroadcastChannel.ts;h=63b261d5db5b7a857686c63ce95f7ed47917f067;hb=edd134392e237a3242dc2093341df70244c51472;hp=274267ca446ade938bfd2e519fdf692a5b2f29d7;hpb=9383b2b1e4f256645b787d674bbd7a44b85dd3eb;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts index 274267ca..63b261d5 100644 --- a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts @@ -3,6 +3,7 @@ import type OCPPError from '../exception/OCPPError'; import { StandardParametersKey } from '../types/ocpp/Configuration'; import { type BootNotificationRequest, + type DataTransferRequest, type HeartbeatRequest, type MeterValuesRequest, RequestCommand, @@ -10,6 +11,8 @@ import { } from '../types/ocpp/Requests'; import { type BootNotificationResponse, + type DataTransferResponse, + DataTransferStatus, type HeartbeatResponse, type MeterValuesResponse, RegistrationStatus, @@ -24,6 +27,7 @@ import { type StopTransactionRequest, type StopTransactionResponse, } from '../types/ocpp/Transaction'; +import { ResponseStatus } from '../types/UIProtocol'; import { BroadcastChannelProcedureName, type BroadcastChannelRequest, @@ -31,7 +35,6 @@ import { type BroadcastChannelResponsePayload, type MessageEvent, } from '../types/WorkerBroadcastChannel'; -import { ResponseStatus } from '../ui/web/src/types/UIProtocol'; import Constants from '../utils/Constants'; import logger from '../utils/Logger'; import Utils from '../utils/Utils'; @@ -49,7 +52,8 @@ type CommandResponse = | BootNotificationResponse | StatusNotificationResponse | HeartbeatResponse - | MeterValuesResponse; + | MeterValuesResponse + | DataTransferResponse; type CommandHandler = ( requestPayload?: BroadcastChannelRequestPayload @@ -178,6 +182,14 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca }); }, ], + [ + BroadcastChannelProcedureName.DATA_TRANSFER, + async (requestPayload?: BroadcastChannelRequestPayload) => + this.chargingStation.ocppRequestService.requestHandler< + DataTransferRequest, + DataTransferResponse + >(this.chargingStation, RequestCommand.DATA_TRANSFER, requestPayload), + ], ]); this.chargingStation = chargingStation; this.onmessage = this.requestHandler.bind(this) as (message: MessageEvent) => void; @@ -201,7 +213,7 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca } if (requestPayload?.hashId !== undefined) { logger.error( - `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead` + `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' array instead` ); return; } @@ -268,7 +280,7 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca [ BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, - ].includes(command) === true && delete requestPayload.connectorIds; + ].includes(command) === false && delete requestPayload.connectorIds; } private commandResponseToResponsePayload( @@ -316,6 +328,11 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca return ResponseStatus.SUCCESS; } return ResponseStatus.FAILURE; + case BroadcastChannelProcedureName.DATA_TRANSFER: + if (commandResponse?.status === DataTransferStatus.ACCEPTED) { + return ResponseStatus.SUCCESS; + } + return ResponseStatus.FAILURE; case BroadcastChannelProcedureName.STATUS_NOTIFICATION: case BroadcastChannelProcedureName.METER_VALUES: if (Utils.isEmptyObject(commandResponse) === true) {