X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FHelpers.ts;h=f0f848d38c96cfdddc9a5fce3ae7d68d5622ba2c;hb=1cee0015ac704be480535c7228103525cc3c8cc2;hp=068bc6c970afeaa9e402cc4f69086ccafae59ded;hpb=1c9de2b93a05cb7e29aaf8d070c9bd1d50731191;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 068bc6c9..f0f848d3 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -1,6 +1,7 @@ import { createHash, randomBytes } from 'node:crypto'; import type { EventEmitter } from 'node:events'; import { basename, dirname, join } from 'node:path'; +import { env } from 'node:process'; import { fileURLToPath } from 'node:url'; import chalk from 'chalk'; @@ -76,7 +77,7 @@ export const getChargingStationId = ( stationTemplate: ChargingStationTemplate, ): string => { // In case of multiple instances: add instance index to charging station id - const instanceIndex = process.env.CF_INSTANCE_INDEX ?? 0; + const instanceIndex = env.CF_INSTANCE_INDEX ?? 0; const idSuffix = stationTemplate?.nameSuffix ?? ''; const idStr = `000000000${index.toString()}`; return stationTemplate?.fixedName @@ -174,9 +175,9 @@ export const getPhaseRotationValue = ( } else if (connectorId > 0 && numberOfPhases === 0) { return `${connectorId}.${ConnectorPhaseRotation.NotApplicable}`; // AC - } else if (connectorId > 0 && numberOfPhases === 1) { + } else if (connectorId >= 0 && numberOfPhases === 1) { return `${connectorId}.${ConnectorPhaseRotation.NotApplicable}`; - } else if (connectorId > 0 && numberOfPhases === 3) { + } else if (connectorId >= 0 && numberOfPhases === 3) { return `${connectorId}.${ConnectorPhaseRotation.RST}`; } }; @@ -362,7 +363,7 @@ export const createBootNotificationRequest = ( stationInfo: ChargingStationInfo, bootReason: BootReasonEnumType = BootReasonEnumType.PowerUp, ): BootNotificationRequest => { - const ocppVersion = stationInfo.ocppVersion ?? OCPPVersion.VERSION_16; + const ocppVersion = stationInfo.ocppVersion!; switch (ocppVersion) { case OCPPVersion.VERSION_16: return { @@ -558,14 +559,14 @@ export const getChargingStationConnectorChargingProfilesPowerLimit = ( if (!isNullOrUndefined(result)) { limit = result?.limit; chargingProfile = result?.chargingProfile; - switch (chargingStation.getCurrentOutType()) { + switch (chargingStation.stationInfo?.currentOutType) { case CurrentType.AC: limit = chargingProfile?.chargingSchedule?.chargingRateUnit === ChargingRateUnitType.WATT ? limit : ACElectricUtils.powerTotal( chargingStation.getNumberOfPhases(), - chargingStation.getVoltageOut(), + chargingStation.stationInfo.voltageOut!, limit!, ); break; @@ -573,10 +574,10 @@ export const getChargingStationConnectorChargingProfilesPowerLimit = ( limit = chargingProfile?.chargingSchedule?.chargingRateUnit === ChargingRateUnitType.WATT ? limit - : DCElectricUtils.power(chargingStation.getVoltageOut(), limit!); + : DCElectricUtils.power(chargingStation.stationInfo.voltageOut!, limit!); } const connectorMaximumPower = - chargingStation.getMaximumPower() / chargingStation.powerDivider; + chargingStation.stationInfo.maximumPower! / chargingStation.powerDivider; if (limit! > connectorMaximumPower) { logger.error( `${chargingStation.logPrefix()} ${moduleName}.getChargingStationConnectorChargingProfilesPowerLimit: Charging profile id ${chargingProfile?.chargingProfileId} limit ${limit} is greater than connector id ${connectorId} maximum ${connectorMaximumPower}: %j`, @@ -714,7 +715,7 @@ const warnDeprecatedTemplateKey = ( isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : '' }`; logger.warn(`${logPrefix} ${logMsg}`); - console.warn(chalk.yellow(`${logMsg}`)); + console.warn(`${chalk.green(logPrefix)} ${chalk.yellow(logMsg)}`); } };