예제 #1
0
/*
callback for sensor driver to update the value, e.g. if the sampled value changes
can be called for every sample acquisition
this will evaluate the sample against the reporting criteria and schedule a report 
if a reportable event occurs
*/
void on_update(sample s)// callback from sensor driver, e.g. on changing value 
{
    if (band(s) != last_band || s >= high_step || s <= low_step){ // test limits
        schedule_report(s);
    }
    return;
}
예제 #2
0
void M2MReportHandler::set_value(float value)
{
    tr_debug("M2MReportHandler::set_value()");
    _current_value = value;    
    if(_current_value != _last_value && _under_observation) {
        tr_debug("M2MReportHandler::set_value() - UNDER OBSERVATION");
        if (check_threshold_values()) {
            _notify = true;
            schedule_report(_current_value);
        }
        else {
            tr_debug("M2MReportHandler::set_value - value not in range");
            _notify = false;
            _last_value = _current_value;
            if ((_attribute_state & M2MReportHandler::Lt) == M2MReportHandler::Lt ||
                    (_attribute_state & M2MReportHandler::Gt) == M2MReportHandler::Gt ||
                    (_attribute_state & M2MReportHandler::St) == M2MReportHandler::St) {
                tr_debug("M2MReportHandler::set_value - stop pmin timer");
                _pmin_timer->stop_timer();
                _pmin_exceeded = true;
            }
        }
        _high_step = _current_value + _st;
        _low_step = _current_value - _st;
    }
}