From: Jérôme Benoit Date: Fri, 22 Mar 2024 21:47:02 +0000 (+0100) Subject: refactor: cleanup logic at building station info X-Git-Tag: v1.3.1~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bf2561ebbc6f51ce3ea68df68eacfe8a28d50bc6;p=e-mobility-charging-stations-simulator.git refactor: cleanup logic at building station info Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index e41ea5ec..272abc8c 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1227,6 +1227,7 @@ export class ChargingStation extends EventEmitter { const stationInfoFromFile = this.getStationInfoFromFile( stationInfoFromTemplate.stationInfoPersistentConfiguration ) + let stationInfo: ChargingStationInfo // Priority: // 1. charging station info from template // 2. charging station info from configuration file @@ -1234,19 +1235,14 @@ export class ChargingStation extends EventEmitter { stationInfoFromFile != null && stationInfoFromFile.templateHash === stationInfoFromTemplate.templateHash ) { - return setChargingStationOptions( - mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfoFromFile), - options - ) + stationInfo = stationInfoFromFile + } else { + stationInfo = stationInfoFromTemplate + stationInfoFromFile != null && + propagateSerialNumber(this.getTemplateFromFile(), stationInfoFromFile, stationInfo) } - stationInfoFromFile != null && - propagateSerialNumber( - this.getTemplateFromFile(), - stationInfoFromFile, - stationInfoFromTemplate - ) return setChargingStationOptions( - mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfoFromTemplate), + mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfo), options ) }