X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fbroadcast-channel%2FChargingStationWorkerBroadcastChannel.ts;h=b5fc1cef13cc76b3f8e5250227485594c55e4210;hb=8fa6f565c86b72f3d6f040d283da83740a51542e;hp=10d0c75c3aff0ad88776f0d76a2fb80cca665c5e;hpb=859099b6e7adaf9eeed2aa348921a23d7aa0bc7a;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 10d0c75c..b5fc1cef 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -1,6 +1,6 @@ import { secondsToMilliseconds } from 'date-fns' +import { isEmpty } from 'rambda' -import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js' import { BaseError, type OCPPError } from '../../exception/index.js' import { AuthorizationStatus, @@ -37,16 +37,11 @@ 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' +import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js' const moduleName = 'ChargingStationWorkerBroadcastChannel' @@ -86,6 +81,12 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne await this.chargingStation.stop() } ], + [ + BroadcastChannelProcedureName.DELETE_CHARGING_STATIONS, + async (requestPayload?: BroadcastChannelRequestPayload) => { + await this.chargingStation.delete(requestPayload?.deleteConfiguration as boolean) + } + ], [ BroadcastChannelProcedureName.OPEN_CONNECTION, () => { @@ -287,7 +288,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 @@ -300,7 +301,7 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne ) } }) - .catch(error => { + .catch((error: unknown) => { logger.error( `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: Handle request error:`, error @@ -414,7 +415,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