Example 9 - Restore values from memory
Task:
A connected device temporarily sends 0km instead of the last odometer reading during the boot process. This deviation should not be recorded in the measurement data.
Solution:
$'CALC.ZSG_KM_VALUE' = dLatch($'MVB.ZSG_KM_VALUE' < 100.0, $'MVB.ZSG_KM_VALUE', {storage:'lastValid_km_value'});
Functions used:
Explanation:
dLatch(hold, value)
lets the value "pass" withhold=false
and saves it internally - here also persistently by specifying the storage. As soon ashold=true
, the last saved value is passed on. This happens when the connected device is started, as the mileage falls below 100.