X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fbroadcast-channel%2FChargingStationWorkerBroadcastChannel.ts;h=9b6621343a4afcfa36958f11c29bee35888cdbf3;hb=ab29e6820d6a6d48d8ccc091ec8adae575398c3d;hp=1a825e39186e3bc94178507917ff966cd99b3db5;hpb=4c3f6c20f9416e148a3d26b6a06acc13274ab469;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 1a825e39..9b662134 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -1,4 +1,5 @@ import { secondsToMilliseconds } from 'date-fns' +import { isEmpty } from 'rambda' import { BaseError, type OCPPError } from '../../exception/index.js' import { @@ -36,13 +37,7 @@ import { type StopTransactionRequest, type StopTransactionResponse } from '../../types/index.js' -import { - Constants, - convertToInt, - isAsyncFunction, - isEmptyObject, - logger -} from '../../utils/index.js' +import { Constants, convertToInt, isAsyncFunction, logger } from '../../utils/index.js' import type { ChargingStation } from '../ChargingStation.js' import { getConfigurationKey } from '../ConfigurationKeyUtils.js' import { buildMeterValue } from '../ocpp/index.js' @@ -160,22 +155,21 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne [ BroadcastChannelProcedureName.BOOT_NOTIFICATION, async (requestPayload?: BroadcastChannelRequestPayload) => { - this.chargingStation.bootNotificationResponse = - await this.chargingStation.ocppRequestService.requestHandler< - BootNotificationRequest, - BootNotificationResponse - >( - this.chargingStation, - RequestCommand.BOOT_NOTIFICATION, - { - ...this.chargingStation.bootNotificationRequest, - ...requestPayload - }, - { - skipBufferingOnError: true, - throwError: true - } - ) + await this.chargingStation.ocppRequestService.requestHandler< + BootNotificationRequest, + BootNotificationResponse + >( + this.chargingStation, + RequestCommand.BOOT_NOTIFICATION, + { + ...this.chargingStation.bootNotificationRequest, + ...requestPayload + }, + { + skipBufferingOnError: true, + throwError: true + } + ) return this.chargingStation.bootNotificationResponse } ], @@ -293,7 +287,7 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne let responsePayload: BroadcastChannelResponsePayload | undefined this.commandHandler(command, requestPayload) .then(commandResponse => { - if (commandResponse == null || isEmptyObject(commandResponse)) { + if (commandResponse == null || isEmpty(commandResponse)) { responsePayload = { hashId: this.chargingStation.stationInfo?.hashId, status: ResponseStatus.SUCCESS @@ -306,7 +300,7 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne ) } }) - .catch(error => { + .catch((error: unknown) => { logger.error( `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: Handle request error:`, error @@ -420,7 +414,7 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne return ResponseStatus.FAILURE case BroadcastChannelProcedureName.STATUS_NOTIFICATION: case BroadcastChannelProcedureName.METER_VALUES: - if (isEmptyObject(commandResponse)) { + if (isEmpty(commandResponse)) { return ResponseStatus.SUCCESS } return ResponseStatus.FAILURE