X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2Fui-services%2FAbstractUIService.ts;h=6652def2ad2f64e5a43cf30fb1ab0831a9dfdcda;hb=3b09e788c6dab8e5a8b3314e8e69ede16ff82fcc;hp=6aed70a1b555cfcf5718cc153d02edc3e25da894;hpb=8ae4dcf159bf29835de7fd1edd7978aa8a3ee76b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/ui-services/AbstractUIService.ts b/src/charging-station/ui-server/ui-services/AbstractUIService.ts index 6aed70a1..6652def2 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -2,6 +2,7 @@ import { BaseError, type OCPPError } from '../../../exception/index.js' import { BroadcastChannelProcedureName, type BroadcastChannelRequestPayload, + type ChargingStationInfo, type ChargingStationOptions, ConfigurationSection, type JsonObject, @@ -275,23 +276,30 @@ export abstract class AbstractUIService { errorMessage: `Template '${template}' not found` } satisfies ResponsePayload } + const stationInfos: ChargingStationInfo[] = [] for (let i = 0; i < numberOfStations; i++) { + let stationInfo: ChargingStationInfo | undefined try { - await Bootstrap.getInstance().addChargingStation( + stationInfo = await Bootstrap.getInstance().addChargingStation( Bootstrap.getInstance().getLastIndex(template) + 1, `${template}.json`, options ) + if (stationInfo != null) { + stationInfos.push(stationInfo) + } } catch (error) { return { status: ResponseStatus.FAILURE, + ...(stationInfo?.hashId != null && { hashIdsFailed: [stationInfo.hashId] }), errorMessage: (error as Error).message, errorStack: (error as Error).stack } satisfies ResponsePayload } } return { - status: ResponseStatus.SUCCESS + status: ResponseStatus.SUCCESS, + hashIdsSucceeded: stationInfos.map(stationInfo => stationInfo.hashId) } }