type OCPP16SupportedFeatureProfiles,
OCPPVersion,
type SampledValueTemplate,
- Voltage,
} from '../../../types';
import {
ACElectricUtils,
getRandomFloatRounded,
getRandomInteger,
isNotEmptyArray,
+ isNotEmptyString,
isNullOrUndefined,
isUndefined,
logger,
if (socSampledValueTemplate) {
const socMaximumValue = 100;
const socMinimumValue = socSampledValueTemplate.minimumValue ?? 0;
- const socSampledValueTemplateValue = socSampledValueTemplate.value
+ const socSampledValueTemplateValue = isNotEmptyString(socSampledValueTemplate.value)
? getRandomFloatFluctuatedRounded(
parseInt(socSampledValueTemplate.value),
socSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT,
OCPP16MeterValueMeasurand.VOLTAGE,
);
if (voltageSampledValueTemplate) {
- const voltageSampledValueTemplateValue = voltageSampledValueTemplate.value
+ const voltageSampledValueTemplateValue = isNotEmptyString(voltageSampledValueTemplate.value)
? parseInt(voltageSampledValueTemplate.value)
: chargingStation.stationInfo.voltageOut!;
const fluctuationPercent =
);
let voltagePhaseLineToNeutralMeasurandValue: number | undefined;
if (voltagePhaseLineToNeutralSampledValueTemplate) {
- const voltagePhaseLineToNeutralSampledValueTemplateValue =
- voltagePhaseLineToNeutralSampledValueTemplate.value
- ? parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value)
- : chargingStation.stationInfo.voltageOut!;
+ const voltagePhaseLineToNeutralSampledValueTemplateValue = isNotEmptyString(
+ voltagePhaseLineToNeutralSampledValueTemplate.value,
+ )
+ ? parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value)
+ : chargingStation.stationInfo.voltageOut!;
const fluctuationPhaseToNeutralPercent =
voltagePhaseLineToNeutralSampledValueTemplate.fluctuationPercent ??
Constants.DEFAULT_FLUCTUATION_PERCENT;
);
let voltagePhaseLineToLineMeasurandValue: number | undefined;
if (voltagePhaseLineToLineSampledValueTemplate) {
- const voltagePhaseLineToLineSampledValueTemplateValue =
- voltagePhaseLineToLineSampledValueTemplate.value
- ? parseInt(voltagePhaseLineToLineSampledValueTemplate.value)
- : Voltage.VOLTAGE_400;
+ const voltagePhaseLineToLineSampledValueTemplateValue = isNotEmptyString(
+ voltagePhaseLineToLineSampledValueTemplate.value,
+ )
+ ? parseInt(voltagePhaseLineToLineSampledValueTemplate.value)
+ : roundTo(
+ Math.sqrt(chargingStation.getNumberOfPhases()) *
+ chargingStation.stationInfo.voltageOut!,
+ 2,
+ );
const fluctuationPhaseLineToLinePercent =
voltagePhaseLineToLineSampledValueTemplate.fluctuationPercent ??
Constants.DEFAULT_FLUCTUATION_PERCENT;
);
}
const defaultVoltagePhaseLineToLineMeasurandValue = getRandomFloatFluctuatedRounded(
- Voltage.VOLTAGE_400,
+ Math.sqrt(chargingStation.getNumberOfPhases()) *
+ chargingStation.stationInfo.voltageOut!,
fluctuationPercent,
);
meterValue.sampledValue.push(
);
break;
case CurrentType.DC:
- powerMeasurandValues.allPhases = powerSampledValueTemplate.value
+ powerMeasurandValues.allPhases = isNotEmptyString(powerSampledValueTemplate.value)
? getRandomFloatFluctuatedRounded(
OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue(
powerSampledValueTemplate.value,
(defaultFluctuatedAmperagePerPhase as number) ??
getRandomFloatRounded(connectorMaximumAmperage, connectorMinimumAmperage);
} else {
- currentMeasurandValues.L1 = currentSampledValueTemplate.value
+ currentMeasurandValues.L1 = isNotEmptyString(currentSampledValueTemplate.value)
? getRandomFloatFluctuatedRounded(
OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue(
currentSampledValueTemplate.value,
connectorMaximumAvailablePower,
chargingStation.stationInfo.voltageOut!,
);
- currentMeasurandValues.allPhases = currentSampledValueTemplate.value
+ currentMeasurandValues.allPhases = isNotEmptyString(currentSampledValueTemplate.value)
? getRandomFloatFluctuatedRounded(
OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue(
currentSampledValueTemplate.value,