Example 9 - Restoring values from memory
Task:
A connected device temporarily sends 0 km instead of the last mileage during the boot process. This deviation should not be recorded in the measurement data.
Solution:
$'CALC.ZSG_KM_STAND' = dLatch($'MVB.ZSG_KM_STAND' < 100.0, $'MVB.ZSG_KM_STAND', {storage:'lastValid_km_stand'});
Functions used:
Explanation:
dLatch(hold, value)withhold=falseallows the value to "pass" and stores it internally – in this case persistently by specifying the storage. As soon ashold=true, the last stored value is passed on. This happens when the connected device is started, as the mileage falls below 100.