Variable Measurement Interval
Adapts the measurement and upload intervals based on how full the measurement
queue is (__status().mqueue), allowing more measurements to be stored during
communication outages.
// This function adjusts the measurement interval dependong on how full the queue is, adjusts the measurement interval to allow for storing more measurements during comm outages
function checkMeasurementInterval(){
if(__status().mqueue > 75){ // 75% full
setEnv("sys.meas_interval",3600);// 1 hr meas interval
setEnv("sys.sync_interval",300);// 5 min upload
} else if(__status().mqueue > 10){ // 10% full
setEnv("sys.meas_interval",300);// 5 min interval
setEnv("sys.sync_interval",300); // 5 min upload
} else { // Default Measurement & Upload Interval
setEnv("sys.meas_interval",60);
setEnv("sys.sync_interval",60);
}
}
while(run()){
checkMeasurementInterval();
}