X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStationUtils.ts;h=f86c5d783b82657c483183f9bf43c562e2c11de1;hb=0b22144c135af531858c989650e864edb352764d;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..f86c5d78 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url'; import chalk from 'chalk'; import moment from 'moment'; -import type { ChargingStation } from './internal'; +import type { ChargingStation } from './ChargingStation'; import { BaseError } from '../exception'; import { AmpereUnits, @@ -29,15 +29,7 @@ import { RecurrencyKindType, Voltage, } from '../types'; -import { - ACElectricUtils, - Configuration, - Constants, - DCElectricUtils, - Utils, - logger, -} from '../utils'; -import { WorkerProcessType } from '../worker'; +import { ACElectricUtils, Constants, DCElectricUtils, Utils, logger } from '../utils'; const moduleName = 'ChargingStationUtils'; @@ -153,7 +145,7 @@ export class ChargingStationUtils { return connectorBootStatus; } - public static checkTemplateFile( + public static checkTemplate( stationTemplate: ChargingStationTemplate, logPrefix: string, templateFile: string @@ -168,6 +160,21 @@ export class ChargingStationUtils { logger.error(`${logPrefix} ${errorMsg}`); throw new BaseError(errorMsg); } + if (Utils.isEmptyObject(stationTemplate.AutomaticTransactionGenerator)) { + stationTemplate.AutomaticTransactionGenerator = Constants.DEFAULT_ATG_CONFIGURATION; + logger.warn( + `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default: %j`, + Constants.DEFAULT_ATG_CONFIGURATION + ); + } + if ( + Utils.isNullOrUndefined(stationTemplate.idTagsFile) || + Utils.isEmptyString(stationTemplate.idTagsFile) + ) { + logger.warn( + `${logPrefix} Missing id tags file in template file ${templateFile}. That can lead to issues with the Automatic Transaction Generator` + ); + } } public static checkConnectorsConfiguration( @@ -336,16 +343,6 @@ export class ChargingStationUtils { } } - public static workerPoolInUse(): boolean { - return [WorkerProcessType.dynamicPool, WorkerProcessType.staticPool].includes( - Configuration.getWorker().processType - ); - } - - public static workerDynamicPoolInUse(): boolean { - return Configuration.getWorker().processType === WorkerProcessType.dynamicPool; - } - public static warnTemplateKeysDeprecation( stationTemplate: ChargingStationTemplate, logPrefix: string, @@ -374,7 +371,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 +453,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)) { @@ -535,7 +532,7 @@ export class ChargingStationUtils { return ( stationInfo.idTagsFile && path.join( - path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'), + path.dirname(fileURLToPath(import.meta.url)), 'assets', path.basename(stationInfo.idTagsFile) )