Validator: Reset error state if no error condition triggers

This commit is contained in:
Lorenz Meier
2015-11-24 00:11:49 +01:00
parent a7cb170cc4
commit da47e8ade8
2 changed files with 12 additions and 12 deletions
+8 -8
View File
@@ -118,30 +118,30 @@ DataValidator::confidence(uint64_t timestamp)
if (_time_last == 0) { if (_time_last == 0) {
_error_mask |= ERROR_FLAG_NO_DATA; _error_mask |= ERROR_FLAG_NO_DATA;
ret = 0.0f; ret = 0.0f;
}
/* timed out - that's it */ /* timed out - that's it */
if (timestamp - _time_last > _timeout_interval) { } else if (timestamp - _time_last > _timeout_interval) {
_error_mask |= ERROR_FLAG_TIMEOUT; _error_mask |= ERROR_FLAG_TIMEOUT;
ret = 0.0f; ret = 0.0f;
}
/* we got the exact same sensor value N times in a row */ /* we got the exact same sensor value N times in a row */
if (_value_equal_count > VALUE_EQUAL_COUNT_MAX) { } else if (_value_equal_count > VALUE_EQUAL_COUNT_MAX) {
_error_mask |= ERROR_FLAG_STALE_DATA; _error_mask |= ERROR_FLAG_STALE_DATA;
ret = 0.0f; ret = 0.0f;
}
/* check error count limit */ /* check error count limit */
if (_error_count > NORETURN_ERRCOUNT) { } else if (_error_count > NORETURN_ERRCOUNT) {
_error_mask |= ERROR_FLAG_HIGH_ERRCOUNT; _error_mask |= ERROR_FLAG_HIGH_ERRCOUNT;
ret = 0.0f; ret = 0.0f;
}
/* cap error density counter at window size */ /* cap error density counter at window size */
if (_error_density > ERROR_DENSITY_WINDOW) { } else if (_error_density > ERROR_DENSITY_WINDOW) {
_error_mask |= ERROR_FLAG_HIGH_ERRDENSITY; _error_mask |= ERROR_FLAG_HIGH_ERRDENSITY;
_error_density = ERROR_DENSITY_WINDOW; _error_density = ERROR_DENSITY_WINDOW;
/* no error */
} else {
_error_mask = ERROR_FLAG_NO_ERROR;
} }
/* no critical errors */ /* no critical errors */
+1 -1
View File
@@ -97,7 +97,7 @@ public:
* Get the error state of this validator * Get the error state of this validator
* @return the bitmask with the error status * @return the bitmask with the error status
*/ */
uint32_t state() { return (_error_mask); } uint32_t state() { return _error_mask; }
/** /**
* Reset the error state of this validator * Reset the error state of this validator