+ this.commandHandlers = new Map<BroadcastChannelProcedureName, CommandHandler>([
+ [BroadcastChannelProcedureName.START_CHARGING_STATION, () => this.chargingStation.start()],
+ [
+ BroadcastChannelProcedureName.STOP_CHARGING_STATION,
+ async () => this.chargingStation.stop(),
+ ],
+ [
+ BroadcastChannelProcedureName.OPEN_CONNECTION,
+ () => this.chargingStation.openWSConnection(),
+ ],
+ [
+ BroadcastChannelProcedureName.CLOSE_CONNECTION,
+ () => this.chargingStation.closeWSConnection(),
+ ],
+ [
+ BroadcastChannelProcedureName.START_TRANSACTION,
+ async (requestPayload?: BroadcastChannelRequestPayload) =>
+ this.chargingStation.ocppRequestService.requestHandler<
+ StartTransactionRequest,
+ StartTransactionResponse
+ >(this.chargingStation, RequestCommand.START_TRANSACTION, {
+ connectorId: requestPayload.connectorId,
+ idTag: requestPayload.idTag,
+ }),
+ ],
+ [
+ BroadcastChannelProcedureName.STOP_TRANSACTION,
+ async (requestPayload?: BroadcastChannelRequestPayload) =>
+ this.chargingStation.ocppRequestService.requestHandler<
+ StopTransactionRequest,
+ StartTransactionResponse
+ >(this.chargingStation, RequestCommand.STOP_TRANSACTION, {
+ transactionId: requestPayload.transactionId,
+ meterStop: this.chargingStation.getEnergyActiveImportRegisterByTransactionId(
+ requestPayload.transactionId,
+ true
+ ),
+ idTag: requestPayload.idTag,
+ reason: requestPayload.reason,
+ }),
+ ],
+ [
+ BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
+ (requestPayload?: BroadcastChannelRequestPayload) =>
+ this.chargingStation.startAutomaticTransactionGenerator(requestPayload.connectorIds),
+ ],
+ [
+ BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
+ (requestPayload?: BroadcastChannelRequestPayload) =>
+ this.chargingStation.stopAutomaticTransactionGenerator(requestPayload.connectorIds),
+ ],
+ [
+ BroadcastChannelProcedureName.STATUS_NOTIFICATION,
+ async (requestPayload?: BroadcastChannelRequestPayload) =>
+ this.chargingStation.ocppRequestService.requestHandler<
+ StatusNotificationRequest,
+ StatusNotificationResponse
+ >(this.chargingStation, RequestCommand.STATUS_NOTIFICATION, {
+ connectorId: requestPayload.connectorId,
+ errorCode: requestPayload.errorCode,
+ status: requestPayload.status,
+ ...(requestPayload.info && { info: requestPayload.info }),
+ ...(requestPayload.timestamp && { timestamp: requestPayload.timestamp }),
+ ...(requestPayload.vendorId && { vendorId: requestPayload.vendorId }),
+ ...(requestPayload.vendorErrorCode && {
+ vendorErrorCode: requestPayload.vendorErrorCode,
+ }),
+ }),
+ ],
+ [
+ BroadcastChannelProcedureName.HEARTBEAT,
+ async (requestPayload?: BroadcastChannelRequestPayload) => {
+ delete requestPayload.hashId;
+ delete requestPayload.hashIds;
+ delete requestPayload.connectorIds;
+ return this.chargingStation.ocppRequestService.requestHandler<
+ HeartbeatRequest,
+ HeartbeatResponse
+ >(this.chargingStation, RequestCommand.HEARTBEAT, requestPayload);
+ },
+ ],
+ ]);