X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ServiceUtils.ts;h=197fb6a2aeca0e924a677ee0d327f600abc1f926;hb=33276ba6a447f0beb92b934d2b8d5cb08eababb4;hp=7f065d30bed7dd29c684edaa358c82c0866cbe9e;hpb=d8093be156ab575dbd44546ef4646a6338a27358;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 7f065d30..197fb6a2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -1,14 +1,27 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. import type { JSONSchemaType } from 'ajv'; +import { + addSeconds, + areIntervalsOverlapping, + differenceInSeconds, + isAfter, + isBefore, + isWithinInterval, +} from 'date-fns'; -import { type ChargingStation, getIdTagsFile, hasFeatureProfile } from '../../../charging-station'; +import { OCPP16Constants } from './OCPP16Constants'; +import { + type ChargingStation, + hasFeatureProfile, + hasReservationExpired, +} from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { type ClearChargingProfileRequest, - type ConnectorStatus, CurrentType, ErrorType, + type GenericResponse, type JsonType, type MeasurandPerPhaseSampledValueTemplates, type MeasurandValues, @@ -16,9 +29,11 @@ import { MeterValueLocation, MeterValueUnit, OCPP16AuthorizationStatus, - type OCPP16AuthorizeRequest, - type OCPP16AuthorizeResponse, + OCPP16AvailabilityType, + type OCPP16ChangeAvailabilityResponse, + OCPP16ChargePointStatus, type OCPP16ChargingProfile, + type OCPP16ChargingSchedule, type OCPP16IncomingRequestCommand, type OCPP16MeterValue, OCPP16MeterValueMeasurand, @@ -26,10 +41,10 @@ import { OCPP16RequestCommand, type OCPP16SampledValue, OCPP16StandardParametersKey, + OCPP16StopTransactionReason, type OCPP16SupportedFeatureProfiles, OCPPVersion, type SampledValueTemplate, - Voltage, } from '../../../types'; import { ACElectricUtils, @@ -87,7 +102,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { 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, @@ -108,7 +123,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${socMinimumValue}/${ meterValue.sampledValue[sampledValuesIndex].value - }/${socMaximumValue}}`, + }/${socMaximumValue}`, ); } } @@ -119,9 +134,9 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { OCPP16MeterValueMeasurand.VOLTAGE, ); if (voltageSampledValueTemplate) { - const voltageSampledValueTemplateValue = voltageSampledValueTemplate.value + const voltageSampledValueTemplateValue = isNotEmptyString(voltageSampledValueTemplate.value) ? parseInt(voltageSampledValueTemplate.value) - : chargingStation.getVoltageOut(); + : chargingStation.stationInfo.voltageOut!; const fluctuationPercent = voltageSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT; const voltageMeasurandValue = getRandomFloatFluctuatedRounded( @@ -130,7 +145,8 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ); if ( chargingStation.getNumberOfPhases() !== 3 || - (chargingStation.getNumberOfPhases() === 3 && chargingStation.getMainVoltageMeterValues()) + (chargingStation.getNumberOfPhases() === 3 && + chargingStation.stationInfo?.mainVoltageMeterValues) ) { meterValue.sampledValue.push( OCPP16ServiceUtils.buildSampledValue(voltageSampledValueTemplate, voltageMeasurandValue), @@ -151,10 +167,11 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ); let voltagePhaseLineToNeutralMeasurandValue: number | undefined; if (voltagePhaseLineToNeutralSampledValueTemplate) { - const voltagePhaseLineToNeutralSampledValueTemplateValue = - voltagePhaseLineToNeutralSampledValueTemplate.value - ? parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value) - : chargingStation.getVoltageOut(); + const voltagePhaseLineToNeutralSampledValueTemplateValue = isNotEmptyString( + voltagePhaseLineToNeutralSampledValueTemplate.value, + ) + ? parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value) + : chargingStation.stationInfo.voltageOut!; const fluctuationPhaseToNeutralPercent = voltagePhaseLineToNeutralSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT; @@ -171,12 +188,17 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { phaseLineToNeutralValue as OCPP16MeterValuePhase, ), ); - if (chargingStation.getPhaseLineToLineVoltageMeterValues()) { + if (chargingStation.stationInfo?.phaseLineToLineVoltageMeterValues) { const phaseLineToLineValue = `L${phase}-L${ (phase + 1) % chargingStation.getNumberOfPhases() !== 0 ? (phase + 1) % chargingStation.getNumberOfPhases() : chargingStation.getNumberOfPhases() }`; + const voltagePhaseLineToLineValueRounded = roundTo( + Math.sqrt(chargingStation.getNumberOfPhases()) * + chargingStation.stationInfo.voltageOut!, + 2, + ); const voltagePhaseLineToLineSampledValueTemplate = OCPP16ServiceUtils.getSampledValueTemplate( chargingStation, @@ -186,10 +208,11 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ); let voltagePhaseLineToLineMeasurandValue: number | undefined; if (voltagePhaseLineToLineSampledValueTemplate) { - const voltagePhaseLineToLineSampledValueTemplateValue = - voltagePhaseLineToLineSampledValueTemplate.value - ? parseInt(voltagePhaseLineToLineSampledValueTemplate.value) - : Voltage.VOLTAGE_400; + const voltagePhaseLineToLineSampledValueTemplateValue = isNotEmptyString( + voltagePhaseLineToLineSampledValueTemplate.value, + ) + ? parseInt(voltagePhaseLineToLineSampledValueTemplate.value) + : voltagePhaseLineToLineValueRounded; const fluctuationPhaseLineToLinePercent = voltagePhaseLineToLineSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT; @@ -199,7 +222,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ); } const defaultVoltagePhaseLineToLineMeasurandValue = getRandomFloatFluctuatedRounded( - Voltage.VOLTAGE_400, + voltagePhaseLineToLineValueRounded, fluctuationPercent, ); meterValue.sampledValue.push( @@ -250,7 +273,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { const errMsg = `MeterValues measurand ${ powerSampledValueTemplate.measurand ?? OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: Unknown ${chargingStation.getCurrentOutType()} currentOutType in template file ${ + }: Unknown ${chargingStation.stationInfo?.currentOutType} currentOutType in template file ${ chargingStation.templateFile }, cannot calculate ${ powerSampledValueTemplate.measurand ?? @@ -264,85 +287,116 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { const connectorMaximumPowerPerPhase = Math.round( connectorMaximumAvailablePower / chargingStation.getNumberOfPhases(), ); - const connectorMinimumPower = Math.round(powerSampledValueTemplate.minimumValue!) ?? 0; + const connectorMinimumPower = Math.round(powerSampledValueTemplate.minimumValue ?? 0); const connectorMinimumPowerPerPhase = Math.round( connectorMinimumPower / chargingStation.getNumberOfPhases(), ); - switch (chargingStation.getCurrentOutType()) { + switch (chargingStation.stationInfo?.currentOutType) { case CurrentType.AC: if (chargingStation.getNumberOfPhases() === 3) { - const defaultFluctuatedPowerPerPhase = - powerSampledValueTemplate.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - powerSampledValueTemplate.value, - connectorMaximumPower / unitDivider, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ) / chargingStation.getNumberOfPhases(), - powerSampledValueTemplate.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); - const phase1FluctuatedValue = - powerPerPhaseSampledValueTemplates.L1?.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - powerPerPhaseSampledValueTemplates.L1.value, - connectorMaximumPowerPerPhase / unitDivider, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - powerPerPhaseSampledValueTemplates.L1.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); - const phase2FluctuatedValue = - powerPerPhaseSampledValueTemplates.L2?.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - powerPerPhaseSampledValueTemplates.L2.value, - connectorMaximumPowerPerPhase / unitDivider, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - powerPerPhaseSampledValueTemplates.L2.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); - const phase3FluctuatedValue = - powerPerPhaseSampledValueTemplates.L3?.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - powerPerPhaseSampledValueTemplates.L3.value, - connectorMaximumPowerPerPhase / unitDivider, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - powerPerPhaseSampledValueTemplates.L3.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); + const defaultFluctuatedPowerPerPhase = isNotEmptyString(powerSampledValueTemplate.value) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + powerSampledValueTemplate.value, + connectorMaximumPower / unitDivider, + connectorMinimumPower / unitDivider, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumPower / unitDivider, + }, + ) / chargingStation.getNumberOfPhases(), + powerSampledValueTemplate.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; + const phase1FluctuatedValue = isNotEmptyString( + powerPerPhaseSampledValueTemplates.L1?.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + powerPerPhaseSampledValueTemplates.L1?.value, + connectorMaximumPowerPerPhase / unitDivider, + connectorMinimumPowerPerPhase / unitDivider, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumPowerPerPhase / unitDivider, + }, + ), + powerPerPhaseSampledValueTemplates.L1?.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; + const phase2FluctuatedValue = isNotEmptyString( + powerPerPhaseSampledValueTemplates.L2?.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + powerPerPhaseSampledValueTemplates.L2?.value, + connectorMaximumPowerPerPhase / unitDivider, + connectorMinimumPowerPerPhase / unitDivider, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumPowerPerPhase / unitDivider, + }, + ), + powerPerPhaseSampledValueTemplates.L2?.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; + const phase3FluctuatedValue = isNotEmptyString( + powerPerPhaseSampledValueTemplates.L3?.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + powerPerPhaseSampledValueTemplates.L3?.value, + connectorMaximumPowerPerPhase / unitDivider, + connectorMinimumPowerPerPhase / unitDivider, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumPowerPerPhase / unitDivider, + }, + ), + powerPerPhaseSampledValueTemplates.L3?.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; powerMeasurandValues.L1 = - (phase1FluctuatedValue as number) ?? - (defaultFluctuatedPowerPerPhase as number) ?? + phase1FluctuatedValue ?? + defaultFluctuatedPowerPerPhase ?? getRandomFloatRounded( connectorMaximumPowerPerPhase / unitDivider, connectorMinimumPowerPerPhase / unitDivider, ); powerMeasurandValues.L2 = - (phase2FluctuatedValue as number) ?? - (defaultFluctuatedPowerPerPhase as number) ?? + phase2FluctuatedValue ?? + defaultFluctuatedPowerPerPhase ?? getRandomFloatRounded( connectorMaximumPowerPerPhase / unitDivider, connectorMinimumPowerPerPhase / unitDivider, ); powerMeasurandValues.L3 = - (phase3FluctuatedValue as number) ?? - (defaultFluctuatedPowerPerPhase as number) ?? + phase3FluctuatedValue ?? + defaultFluctuatedPowerPerPhase ?? getRandomFloatRounded( connectorMaximumPowerPerPhase / unitDivider, connectorMinimumPowerPerPhase / unitDivider, ); } else { - powerMeasurandValues.L1 = powerSampledValueTemplate.value + powerMeasurandValues.L1 = isNotEmptyString(powerSampledValueTemplate.value) ? getRandomFloatFluctuatedRounded( OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( powerSampledValueTemplate.value, connectorMaximumPower / unitDivider, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, + connectorMinimumPower / unitDivider, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumPower / unitDivider, + }, ), powerSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT, @@ -360,12 +414,17 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ); break; case CurrentType.DC: - powerMeasurandValues.allPhases = powerSampledValueTemplate.value + powerMeasurandValues.allPhases = isNotEmptyString(powerSampledValueTemplate.value) ? getRandomFloatFluctuatedRounded( OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( powerSampledValueTemplate.value, connectorMaximumPower / unitDivider, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, + connectorMinimumPower / unitDivider, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumPower / unitDivider, + }, ), powerSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT, @@ -414,7 +473,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { OCPP16ServiceUtils.buildSampledValue( powerPerPhaseSampledValueTemplates[ `L${phase}` as keyof MeasurandPerPhaseSampledValueTemplates - ]! ?? powerSampledValueTemplate, + ] ?? powerSampledValueTemplate, powerMeasurandValues[`L${phase}` as keyof MeasurandPerPhaseSampledValueTemplates], undefined, phaseValue as OCPP16MeterValuePhase, @@ -486,7 +545,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { const errMsg = `MeterValues measurand ${ currentSampledValueTemplate.measurand ?? OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: Unknown ${chargingStation.getCurrentOutType()} currentOutType in template file ${ + }: Unknown ${chargingStation.stationInfo?.currentOutType} currentOutType in template file ${ chargingStation.templateFile }, cannot calculate ${ currentSampledValueTemplate.measurand ?? @@ -497,77 +556,110 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { chargingStation.getConnectorMaximumAvailablePower(connectorId); const connectorMinimumAmperage = currentSampledValueTemplate.minimumValue ?? 0; let connectorMaximumAmperage: number; - switch (chargingStation.getCurrentOutType()) { + switch (chargingStation.stationInfo?.currentOutType) { case CurrentType.AC: connectorMaximumAmperage = ACElectricUtils.amperagePerPhaseFromPower( chargingStation.getNumberOfPhases(), connectorMaximumAvailablePower, - chargingStation.getVoltageOut(), + chargingStation.stationInfo.voltageOut!, ); if (chargingStation.getNumberOfPhases() === 3) { - const defaultFluctuatedAmperagePerPhase = - currentSampledValueTemplate.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - currentSampledValueTemplate.value, - connectorMaximumAmperage, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - currentSampledValueTemplate.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); - const phase1FluctuatedValue = - currentPerPhaseSampledValueTemplates.L1?.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - currentPerPhaseSampledValueTemplates.L1.value, - connectorMaximumAmperage, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - currentPerPhaseSampledValueTemplates.L1.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); - const phase2FluctuatedValue = - currentPerPhaseSampledValueTemplates.L2?.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - currentPerPhaseSampledValueTemplates.L2.value, - connectorMaximumAmperage, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - currentPerPhaseSampledValueTemplates.L2.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); - const phase3FluctuatedValue = - currentPerPhaseSampledValueTemplates.L3?.value && - getRandomFloatFluctuatedRounded( - OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( - currentPerPhaseSampledValueTemplates.L3.value, - connectorMaximumAmperage, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, - ), - currentPerPhaseSampledValueTemplates.L3.fluctuationPercent ?? - Constants.DEFAULT_FLUCTUATION_PERCENT, - ); + const defaultFluctuatedAmperagePerPhase = isNotEmptyString( + currentSampledValueTemplate.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + currentSampledValueTemplate.value, + connectorMaximumAmperage, + connectorMinimumAmperage, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumAmperage, + }, + ), + currentSampledValueTemplate.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; + const phase1FluctuatedValue = isNotEmptyString( + currentPerPhaseSampledValueTemplates.L1?.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + currentPerPhaseSampledValueTemplates.L1?.value, + connectorMaximumAmperage, + connectorMinimumAmperage, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumAmperage, + }, + ), + currentPerPhaseSampledValueTemplates.L1?.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; + const phase2FluctuatedValue = isNotEmptyString( + currentPerPhaseSampledValueTemplates.L2?.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + currentPerPhaseSampledValueTemplates.L2?.value, + connectorMaximumAmperage, + connectorMinimumAmperage, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumAmperage, + }, + ), + currentPerPhaseSampledValueTemplates.L2?.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; + const phase3FluctuatedValue = isNotEmptyString( + currentPerPhaseSampledValueTemplates.L3?.value, + ) + ? getRandomFloatFluctuatedRounded( + OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( + currentPerPhaseSampledValueTemplates.L3?.value, + connectorMaximumAmperage, + connectorMinimumAmperage, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumAmperage, + }, + ), + currentPerPhaseSampledValueTemplates.L3?.fluctuationPercent ?? + Constants.DEFAULT_FLUCTUATION_PERCENT, + ) + : undefined; currentMeasurandValues.L1 = - (phase1FluctuatedValue as number) ?? - (defaultFluctuatedAmperagePerPhase as number) ?? + phase1FluctuatedValue ?? + defaultFluctuatedAmperagePerPhase ?? getRandomFloatRounded(connectorMaximumAmperage, connectorMinimumAmperage); currentMeasurandValues.L2 = - (phase2FluctuatedValue as number) ?? - (defaultFluctuatedAmperagePerPhase as number) ?? + phase2FluctuatedValue ?? + defaultFluctuatedAmperagePerPhase ?? getRandomFloatRounded(connectorMaximumAmperage, connectorMinimumAmperage); currentMeasurandValues.L3 = - (phase3FluctuatedValue as number) ?? - (defaultFluctuatedAmperagePerPhase as number) ?? + phase3FluctuatedValue ?? + defaultFluctuatedAmperagePerPhase ?? getRandomFloatRounded(connectorMaximumAmperage, connectorMinimumAmperage); } else { - currentMeasurandValues.L1 = currentSampledValueTemplate.value + currentMeasurandValues.L1 = isNotEmptyString(currentSampledValueTemplate.value) ? getRandomFloatFluctuatedRounded( OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( currentSampledValueTemplate.value, connectorMaximumAmperage, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, + connectorMinimumAmperage, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumAmperage, + }, ), currentSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT, @@ -585,14 +677,19 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { case CurrentType.DC: connectorMaximumAmperage = DCElectricUtils.amperage( connectorMaximumAvailablePower, - chargingStation.getVoltageOut(), + chargingStation.stationInfo.voltageOut!, ); - currentMeasurandValues.allPhases = currentSampledValueTemplate.value + currentMeasurandValues.allPhases = isNotEmptyString(currentSampledValueTemplate.value) ? getRandomFloatFluctuatedRounded( OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( currentSampledValueTemplate.value, connectorMaximumAmperage, - { limitationEnabled: chargingStation.getCustomValueLimitationMeterValues() }, + connectorMinimumAmperage, + { + limitationEnabled: + chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumAmperage, + }, ), currentSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT, @@ -636,7 +733,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { OCPP16ServiceUtils.buildSampledValue( currentPerPhaseSampledValueTemplates[ phaseValue as keyof MeasurandPerPhaseSampledValueTemplates - ]! ?? currentSampledValueTemplate, + ] ?? currentSampledValueTemplate, currentMeasurandValues[phaseValue as keyof MeasurandPerPhaseSampledValueTemplates], undefined, phaseValue as OCPP16MeterValuePhase, @@ -681,20 +778,25 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { (connectorMaximumAvailablePower * interval) / (3600 * 1000), 2, ); - const energyValueRounded = energySampledValueTemplate.value - ? // Cumulate the fluctuated value around the static one - getRandomFloatFluctuatedRounded( + const connectorMinimumEnergyRounded = roundTo( + energySampledValueTemplate.minimumValue ?? 0, + 2, + ); + const energyValueRounded = isNotEmptyString(energySampledValueTemplate.value) + ? getRandomFloatFluctuatedRounded( OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( energySampledValueTemplate.value, connectorMaximumEnergyRounded, + connectorMinimumEnergyRounded, { - limitationEnabled: chargingStation.getCustomValueLimitationMeterValues(), + limitationEnabled: chargingStation.stationInfo?.customValueLimitationMeterValues, + fallbackValue: connectorMinimumEnergyRounded, unitMultiplier: unitDivider, }, ), energySampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT, ) - : getRandomFloatRounded(connectorMaximumEnergyRounded); + : getRandomFloatRounded(connectorMaximumEnergyRounded, connectorMinimumEnergyRounded); // Persist previous value on connector if (connector) { if ( @@ -721,12 +823,16 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ), ); const sampledValuesIndex = meterValue.sampledValue.length - 1; - if (energyValueRounded > connectorMaximumEnergyRounded || debug) { + if ( + energyValueRounded > connectorMaximumEnergyRounded || + energyValueRounded < connectorMinimumEnergyRounded || + debug + ) { logger.error( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${interval}ms`, + }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${connectorMinimumEnergyRounded}/${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${interval}ms`, ); } } @@ -793,6 +899,55 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { return meterValues; } + public static remoteStopTransaction = async ( + chargingStation: ChargingStation, + connectorId: number, + ): Promise => { + await OCPP16ServiceUtils.sendAndSetConnectorStatus( + chargingStation, + connectorId, + OCPP16ChargePointStatus.Finishing, + ); + const stopResponse = await chargingStation.stopTransactionOnConnector( + connectorId, + OCPP16StopTransactionReason.REMOTE, + ); + if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) { + return OCPP16Constants.OCPP_RESPONSE_ACCEPTED; + } + return OCPP16Constants.OCPP_RESPONSE_REJECTED; + }; + + public static changeAvailability = async ( + chargingStation: ChargingStation, + connectorIds: number[], + chargePointStatus: OCPP16ChargePointStatus, + availabilityType: OCPP16AvailabilityType, + ): Promise => { + const responses: OCPP16ChangeAvailabilityResponse[] = []; + for (const connectorId of connectorIds) { + let response: OCPP16ChangeAvailabilityResponse = + OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED; + const connectorStatus = chargingStation.getConnectorStatus(connectorId)!; + if (connectorStatus?.transactionStarted === true) { + response = OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED; + } + connectorStatus.availability = availabilityType; + if (response === OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) { + await OCPP16ServiceUtils.sendAndSetConnectorStatus( + chargingStation, + connectorId, + chargePointStatus, + ); + } + responses.push(response); + } + if (responses.includes(OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED)) { + return OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED; + } + return OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED; + }; + public static setChargingProfile( chargingStation: ChargingStation, connectorId: number, @@ -808,7 +963,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { Array.isArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles) === false ) { logger.error( - `${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId} with an improper attribute type for the charging profiles array, applying proper type initialization`, + `${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId} with an improper attribute type for the charging profiles array, applying proper type deferred initialization`, ); chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []; } @@ -835,28 +990,23 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { commandPayload: ClearChargingProfileRequest, chargingProfiles: OCPP16ChargingProfile[] | undefined, ): boolean => { + const { id, chargingProfilePurpose, stackLevel } = commandPayload; let clearedCP = false; if (isNotEmptyArray(chargingProfiles)) { chargingProfiles?.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => { let clearCurrentCP = false; - if (chargingProfile.chargingProfileId === commandPayload.id) { + if (chargingProfile.chargingProfileId === id) { clearCurrentCP = true; } - if ( - !commandPayload.chargingProfilePurpose && - chargingProfile.stackLevel === commandPayload.stackLevel - ) { + if (!chargingProfilePurpose && chargingProfile.stackLevel === stackLevel) { clearCurrentCP = true; } - if ( - !chargingProfile.stackLevel && - chargingProfile.chargingProfilePurpose === commandPayload.chargingProfilePurpose - ) { + if (!stackLevel && chargingProfile.chargingProfilePurpose === chargingProfilePurpose) { clearCurrentCP = true; } if ( - chargingProfile.stackLevel === commandPayload.stackLevel && - chargingProfile.chargingProfilePurpose === commandPayload.chargingProfilePurpose + chargingProfile.stackLevel === stackLevel && + chargingProfile.chargingProfilePurpose === chargingProfilePurpose ) { clearCurrentCP = true; } @@ -873,6 +1023,226 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { return clearedCP; }; + public static composeChargingSchedules = ( + chargingScheduleHigher: OCPP16ChargingSchedule | undefined, + chargingScheduleLower: OCPP16ChargingSchedule | undefined, + compositeInterval: Interval, + ): OCPP16ChargingSchedule | undefined => { + if (!chargingScheduleHigher && !chargingScheduleLower) { + return undefined; + } + if (chargingScheduleHigher && !chargingScheduleLower) { + return OCPP16ServiceUtils.composeChargingSchedule(chargingScheduleHigher, compositeInterval); + } + if (!chargingScheduleHigher && chargingScheduleLower) { + return OCPP16ServiceUtils.composeChargingSchedule(chargingScheduleLower, compositeInterval); + } + const compositeChargingScheduleHigher: OCPP16ChargingSchedule | undefined = + OCPP16ServiceUtils.composeChargingSchedule(chargingScheduleHigher!, compositeInterval); + const compositeChargingScheduleLower: OCPP16ChargingSchedule | undefined = + OCPP16ServiceUtils.composeChargingSchedule(chargingScheduleLower!, compositeInterval); + const compositeChargingScheduleHigherInterval: Interval = { + start: compositeChargingScheduleHigher!.startSchedule!, + end: addSeconds( + compositeChargingScheduleHigher!.startSchedule!, + compositeChargingScheduleHigher!.duration!, + ), + }; + const compositeChargingScheduleLowerInterval: Interval = { + start: compositeChargingScheduleLower!.startSchedule!, + end: addSeconds( + compositeChargingScheduleLower!.startSchedule!, + compositeChargingScheduleLower!.duration!, + ), + }; + const higherFirst = isBefore( + compositeChargingScheduleHigherInterval.start, + compositeChargingScheduleLowerInterval.start, + ); + if ( + !areIntervalsOverlapping( + compositeChargingScheduleHigherInterval, + compositeChargingScheduleLowerInterval, + ) + ) { + return { + ...compositeChargingScheduleLower, + ...compositeChargingScheduleHigher!, + startSchedule: higherFirst + ? (compositeChargingScheduleHigherInterval.start as Date) + : (compositeChargingScheduleLowerInterval.start as Date), + duration: higherFirst + ? differenceInSeconds( + compositeChargingScheduleLowerInterval.end, + compositeChargingScheduleHigherInterval.start, + ) + : differenceInSeconds( + compositeChargingScheduleHigherInterval.end, + compositeChargingScheduleLowerInterval.start, + ), + chargingSchedulePeriod: [ + ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => { + return { + ...schedulePeriod, + startPeriod: higherFirst + ? 0 + : schedulePeriod.startPeriod + + differenceInSeconds( + compositeChargingScheduleHigherInterval.start, + compositeChargingScheduleLowerInterval.start, + ), + }; + }), + ...compositeChargingScheduleLower!.chargingSchedulePeriod.map((schedulePeriod) => { + return { + ...schedulePeriod, + startPeriod: higherFirst + ? schedulePeriod.startPeriod + + differenceInSeconds( + compositeChargingScheduleLowerInterval.start, + compositeChargingScheduleHigherInterval.start, + ) + : 0, + }; + }), + ].sort((a, b) => a.startPeriod - b.startPeriod), + }; + } + return { + ...compositeChargingScheduleLower, + ...compositeChargingScheduleHigher!, + startSchedule: higherFirst + ? (compositeChargingScheduleHigherInterval.start as Date) + : (compositeChargingScheduleLowerInterval.start as Date), + duration: higherFirst + ? differenceInSeconds( + compositeChargingScheduleLowerInterval.end, + compositeChargingScheduleHigherInterval.start, + ) + : differenceInSeconds( + compositeChargingScheduleHigherInterval.end, + compositeChargingScheduleLowerInterval.start, + ), + chargingSchedulePeriod: [ + ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => { + return { + ...schedulePeriod, + startPeriod: higherFirst + ? 0 + : schedulePeriod.startPeriod + + differenceInSeconds( + compositeChargingScheduleHigherInterval.start, + compositeChargingScheduleLowerInterval.start, + ), + }; + }), + ...compositeChargingScheduleLower!.chargingSchedulePeriod + .filter((schedulePeriod, index) => { + if ( + higherFirst && + isWithinInterval( + addSeconds( + compositeChargingScheduleLowerInterval.start, + schedulePeriod.startPeriod, + ), + { + start: compositeChargingScheduleLowerInterval.start, + end: compositeChargingScheduleHigherInterval.end, + }, + ) + ) { + return false; + } + if ( + higherFirst && + index < compositeChargingScheduleLower!.chargingSchedulePeriod.length - 1 && + !isWithinInterval( + addSeconds( + compositeChargingScheduleLowerInterval.start, + schedulePeriod.startPeriod, + ), + { + start: compositeChargingScheduleLowerInterval.start, + end: compositeChargingScheduleHigherInterval.end, + }, + ) && + isWithinInterval( + addSeconds( + compositeChargingScheduleLowerInterval.start, + compositeChargingScheduleLower!.chargingSchedulePeriod[index + 1].startPeriod, + ), + { + start: compositeChargingScheduleLowerInterval.start, + end: compositeChargingScheduleHigherInterval.end, + }, + ) + ) { + return false; + } + if ( + !higherFirst && + isWithinInterval( + addSeconds( + compositeChargingScheduleLowerInterval.start, + schedulePeriod.startPeriod, + ), + { + start: compositeChargingScheduleHigherInterval.start, + end: compositeChargingScheduleLowerInterval.end, + }, + ) + ) { + return false; + } + return true; + }) + .map((schedulePeriod, index) => { + if (index === 0 && schedulePeriod.startPeriod !== 0) { + schedulePeriod.startPeriod = 0; + } + return { + ...schedulePeriod, + startPeriod: higherFirst + ? schedulePeriod.startPeriod + + differenceInSeconds( + compositeChargingScheduleLowerInterval.start, + compositeChargingScheduleHigherInterval.start, + ) + : 0, + }; + }), + ].sort((a, b) => a.startPeriod - b.startPeriod), + }; + }; + + public static hasReservation = ( + chargingStation: ChargingStation, + connectorId: number, + idTag: string, + ): boolean => { + const connectorReservation = chargingStation.getReservationBy('connectorId', connectorId); + const chargingStationReservation = chargingStation.getReservationBy('connectorId', 0); + if ( + (chargingStation.getConnectorStatus(connectorId)?.status === + OCPP16ChargePointStatus.Reserved && + connectorReservation && + !hasReservationExpired(connectorReservation) && + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + connectorReservation?.idTag === idTag) || + (chargingStation.getConnectorStatus(0)?.status === OCPP16ChargePointStatus.Reserved && + chargingStationReservation && + !hasReservationExpired(chargingStationReservation) && + chargingStationReservation?.idTag === idTag) + ) { + logger.debug( + `${chargingStation.logPrefix()} Connector id ${connectorId} has a valid reservation for idTag ${idTag}: %j`, + connectorReservation ?? chargingStationReservation, + ); + return true; + } + return false; + }; + public static parseJsonSchemaFile( relativePath: string, moduleName?: string, @@ -886,28 +1256,78 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ); } - public static async isIdTagAuthorized( - chargingStation: ChargingStation, - connectorId: number, - idTag: string, - ): Promise { - let authorized = false; - const connectorStatus: ConnectorStatus = chargingStation.getConnectorStatus(connectorId)!; - if (OCPP16ServiceUtils.isIdTagLocalAuthorized(chargingStation, idTag)) { - connectorStatus.localAuthorizeIdTag = idTag; - connectorStatus.idTagLocalAuthorized = true; - authorized = true; - } else if (chargingStation.getMustAuthorizeAtRemoteStart() === true) { - connectorStatus.authorizeIdTag = idTag; - authorized = await OCPP16ServiceUtils.isIdTagRemoteAuthorized(chargingStation, idTag); - } else { - logger.warn( - `${chargingStation.logPrefix()} The charging station configuration expects authorize at - remote start transaction but local authorization or authorize isn't enabled`, - ); + private static composeChargingSchedule = ( + chargingSchedule: OCPP16ChargingSchedule, + compositeInterval: Interval, + ): OCPP16ChargingSchedule | undefined => { + const chargingScheduleInterval: Interval = { + start: chargingSchedule.startSchedule!, + end: addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!), + }; + if (areIntervalsOverlapping(chargingScheduleInterval, compositeInterval)) { + chargingSchedule.chargingSchedulePeriod.sort((a, b) => a.startPeriod - b.startPeriod); + if (isBefore(chargingScheduleInterval.start, compositeInterval.start)) { + return { + ...chargingSchedule, + startSchedule: compositeInterval.start as Date, + duration: differenceInSeconds( + chargingScheduleInterval.end, + compositeInterval.start as Date, + ), + chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod + .filter((schedulePeriod, index) => { + if ( + isWithinInterval( + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!, + compositeInterval, + ) + ) { + return true; + } + if ( + index < chargingSchedule.chargingSchedulePeriod.length - 1 && + !isWithinInterval( + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), + compositeInterval, + ) && + isWithinInterval( + addSeconds( + chargingScheduleInterval.start, + chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod, + ), + compositeInterval, + ) + ) { + return true; + } + return false; + }) + .map((schedulePeriod, index) => { + if (index === 0 && schedulePeriod.startPeriod !== 0) { + schedulePeriod.startPeriod = 0; + } + return schedulePeriod; + }), + }; + } + if (isAfter(chargingScheduleInterval.end, compositeInterval.end)) { + return { + ...chargingSchedule, + duration: differenceInSeconds( + compositeInterval.end as Date, + chargingScheduleInterval.start, + ), + chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter((schedulePeriod) => + isWithinInterval( + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!, + compositeInterval, + ), + ), + }; + } + return chargingSchedule; } - return authorized; - } + }; private static buildSampledValue( sampledValueTemplate: SampledValueTemplate, @@ -915,12 +1335,11 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { context?: MeterValueContext, phase?: OCPP16MeterValuePhase, ): OCPP16SampledValue { - const sampledValueValue = value ?? sampledValueTemplate?.value ?? null; - const sampledValueContext = context ?? sampledValueTemplate?.context ?? null; + const sampledValueContext = context ?? sampledValueTemplate?.context; const sampledValueLocation = sampledValueTemplate?.location ?? OCPP16ServiceUtils.getMeasurandDefaultLocation(sampledValueTemplate.measurand!); - const sampledValuePhase = phase ?? sampledValueTemplate?.phase ?? null; + const sampledValuePhase = phase ?? sampledValueTemplate?.phase; return { ...(!isNullOrUndefined(sampledValueTemplate.unit) && { unit: sampledValueTemplate.unit, @@ -930,7 +1349,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { measurand: sampledValueTemplate.measurand, }), ...(!isNullOrUndefined(sampledValueLocation) && { location: sampledValueLocation }), - ...(!isNullOrUndefined(sampledValueValue) && { value: sampledValueValue.toString() }), + ...(!isNullOrUndefined(value) && { value: value.toString() }), ...(!isNullOrUndefined(sampledValuePhase) && { phase: sampledValuePhase }), } as OCPP16SampledValue; } @@ -963,51 +1382,25 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { } } - private static getMeasurandDefaultUnit( - measurandType: OCPP16MeterValueMeasurand, - ): MeterValueUnit | undefined { - switch (measurandType) { - case OCPP16MeterValueMeasurand.CURRENT_EXPORT: - case OCPP16MeterValueMeasurand.CURRENT_IMPORT: - case OCPP16MeterValueMeasurand.CURRENT_OFFERED: - return MeterValueUnit.AMP; - case OCPP16MeterValueMeasurand.ENERGY_ACTIVE_EXPORT_REGISTER: - case OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER: - return MeterValueUnit.WATT_HOUR; - case OCPP16MeterValueMeasurand.POWER_ACTIVE_EXPORT: - case OCPP16MeterValueMeasurand.POWER_ACTIVE_IMPORT: - case OCPP16MeterValueMeasurand.POWER_OFFERED: - return MeterValueUnit.WATT; - case OCPP16MeterValueMeasurand.STATE_OF_CHARGE: - return MeterValueUnit.PERCENT; - case OCPP16MeterValueMeasurand.VOLTAGE: - return MeterValueUnit.VOLT; - } - } - - private static isIdTagLocalAuthorized(chargingStation: ChargingStation, idTag: string): boolean { - return ( - chargingStation.getLocalAuthListEnabled() === true && - chargingStation.hasIdTags() === true && - isNotEmptyString( - chargingStation.idTagsCache - .getIdTags(getIdTagsFile(chargingStation.stationInfo)!) - ?.find((tag) => tag === idTag), - ) - ); - } - - private static async isIdTagRemoteAuthorized( - chargingStation: ChargingStation, - idTag: string, - ): Promise { - const authorizeResponse: OCPP16AuthorizeResponse = - await chargingStation.ocppRequestService.requestHandler< - OCPP16AuthorizeRequest, - OCPP16AuthorizeResponse - >(chargingStation, OCPP16RequestCommand.AUTHORIZE, { - idTag: idTag, - }); - return authorizeResponse?.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED; - } + // private static getMeasurandDefaultUnit( + // measurandType: OCPP16MeterValueMeasurand, + // ): MeterValueUnit | undefined { + // switch (measurandType) { + // case OCPP16MeterValueMeasurand.CURRENT_EXPORT: + // case OCPP16MeterValueMeasurand.CURRENT_IMPORT: + // case OCPP16MeterValueMeasurand.CURRENT_OFFERED: + // return MeterValueUnit.AMP; + // case OCPP16MeterValueMeasurand.ENERGY_ACTIVE_EXPORT_REGISTER: + // case OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER: + // return MeterValueUnit.WATT_HOUR; + // case OCPP16MeterValueMeasurand.POWER_ACTIVE_EXPORT: + // case OCPP16MeterValueMeasurand.POWER_ACTIVE_IMPORT: + // case OCPP16MeterValueMeasurand.POWER_OFFERED: + // return MeterValueUnit.WATT; + // case OCPP16MeterValueMeasurand.STATE_OF_CHARGE: + // return MeterValueUnit.PERCENT; + // case OCPP16MeterValueMeasurand.VOLTAGE: + // return MeterValueUnit.VOLT; + // } + // } }