From: Jérôme Benoit Date: Tue, 20 Oct 2020 18:57:30 +0000 (+0200) Subject: Fix zero value in metervalues charging station templates. X-Git-Tag: v1.0.1-0~262 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5c389abe410aa4089378f8fd6a8618ca08708a55;p=e-mobility-charging-stations-simulator.git Fix zero value in metervalues charging station templates. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index c1ca553d..f794f1bc 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -548,7 +548,7 @@ class ChargingStation { const connector = self._connectors[connectorId]; // SoC measurand if (sampledValueLcl.sampledValue[index].measurand && sampledValueLcl.sampledValue[index].measurand === 'SoC') { - sampledValueLcl.sampledValue[index].value = sampledValueLcl.sampledValue[index].value ? + sampledValueLcl.sampledValue[index].value = !Utils.isUndefined(sampledValueLcl.sampledValue[index].value) ? sampledValueLcl.sampledValue[index].value : sampledValueLcl.sampledValue[index].value = Utils.getRandomInt(100); if (sampledValueLcl.sampledValue[index].value > 100 || debug) { @@ -556,10 +556,10 @@ class ChargingStation { } // Voltage measurand } else if (sampledValueLcl.sampledValue[index].measurand && sampledValueLcl.sampledValue[index].measurand === 'Voltage') { - sampledValueLcl.sampledValue[index].value = sampledValueLcl.sampledValue[index].value ? sampledValueLcl.sampledValue[index].value : 230; + sampledValueLcl.sampledValue[index].value = !Utils.isUndefined(sampledValueLcl.sampledValue[index].value) ? sampledValueLcl.sampledValue[index].value : 230; // Energy.Active.Import.Register measurand (default) } else if (!sampledValueLcl.sampledValue[index].measurand || sampledValueLcl.sampledValue[index].measurand === 'Energy.Active.Import.Register') { - if (!sampledValueLcl.sampledValue[index].value) { + if (Utils.isUndefined(sampledValueLcl.sampledValue[index].value)) { const measurandValue = Utils.getRandomInt(self._stationInfo.maxPower / 3600000 * interval); // Persist previous value in connector if (connector && connector.lastEnergyActiveImportRegisterValue >= 0) {