From: Jérôme Benoit Date: Tue, 20 Jul 2021 14:24:10 +0000 (+0200) Subject: Allow to use fluctuated value for SoC MeterValues. X-Git-Tag: v1.0.29~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=561d966b15fec605a437b17b9a0183a57789414c;p=e-mobility-charging-stations-simulator.git Allow to use fluctuated value for SoC MeterValues. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index b19e3192..2c17b334 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -127,7 +127,10 @@ export default class OCPP16RequestService extends OCPPRequestService { // SoC measurand const socSampledValueTemplate = self.chargingStation.getSampledValueTemplate(connectorId, OCPP16MeterValueMeasurand.STATE_OF_CHARGE); if (socSampledValueTemplate) { - meterValue.sampledValue.push(OCPP16ServiceUtils.buildSampledValue(socSampledValueTemplate, Utils.getRandomInt(100))); + const socSampledValueTemplateValue = socSampledValueTemplate.value + ? Utils.getRandomFloatFluctuatedRounded(parseInt(socSampledValueTemplate.value), socSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT) + : Utils.getRandomInt(100); + meterValue.sampledValue.push(OCPP16ServiceUtils.buildSampledValue(socSampledValueTemplate, socSampledValueTemplateValue)); const sampledValuesIndex = meterValue.sampledValue.length - 1; if (Utils.convertToInt(meterValue.sampledValue[sampledValuesIndex].value) > 100 || debug) { logger.error(`${self.chargingStation.logPrefix()} MeterValues measurand ${meterValue.sampledValue[sampledValuesIndex].measurand ?? OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER}: connectorId ${connectorId}, transaction ${connector.transactionId}, value: ${meterValue.sampledValue[sampledValuesIndex].value}/100`);