X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStationUtils.ts;h=d8f67c21460b626875d01be4bae961e93d1c3b78;hb=1227a6f190a8020afd953a26bdede86e5f04eb0c;hp=dbfbe41fdfd2981bb35ab238e8d4e10c614bb035;hpb=8a133cc8eea914f56bb8e00aecd9d9954414cce6;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index dbfbe41f..d8f67c21 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -168,6 +168,21 @@ export class ChargingStationUtils { logger.error(`${logPrefix} ${errorMsg}`); throw new BaseError(errorMsg); } + if (Utils.isEmptyObject(stationTemplate.AutomaticTransactionGenerator)) { + stationTemplate.AutomaticTransactionGenerator = { + enable: false, + minDuration: 60, + maxDuration: 120, + minDelayBetweenTwoTransactions: 15, + maxDelayBetweenTwoTransactions: 30, + probabilityOfStart: 1, + stopAfterHours: 0.3, + stopOnConnectionFailure: true, + }; + logger.warn( + `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default values` + ); + } } public static checkConnectorsConfiguration( @@ -374,7 +389,7 @@ export class ChargingStationUtils { public static stationTemplateToStationInfo( stationTemplate: ChargingStationTemplate ): ChargingStationInfo { - stationTemplate = Utils.cloneObject(stationTemplate); + stationTemplate = Utils.cloneObject(stationTemplate); delete stationTemplate.power; delete stationTemplate.powerUnit; delete stationTemplate?.Connectors; @@ -456,15 +471,15 @@ export class ChargingStationUtils { let limit: number, matchingChargingProfile: ChargingProfile; // Get charging profiles for connector and sort by stack level const chargingProfiles = - Utils.cloneObject(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)?.sort( - (a, b) => b.stackLevel - a.stackLevel - ) ?? []; + Utils.cloneObject( + chargingStation.getConnectorStatus(connectorId)?.chargingProfiles + )?.sort((a, b) => b.stackLevel - a.stackLevel) ?? []; // Get profiles on connector 0 if (chargingStation.getConnectorStatus(0)?.chargingProfiles) { chargingProfiles.push( - ...Utils.cloneObject(chargingStation.getConnectorStatus(0).chargingProfiles).sort( - (a, b) => b.stackLevel - a.stackLevel - ) + ...Utils.cloneObject( + chargingStation.getConnectorStatus(0).chargingProfiles + ).sort((a, b) => b.stackLevel - a.stackLevel) ); } if (Utils.isNotEmptyArray(chargingProfiles)) {