validation initialize all members

- fixes Coverity CID 260331
This commit is contained in:
Daniel Agar
2018-06-14 08:14:53 +02:00
committed by Beat Küng
parent 26dcf05d80
commit c3e071e052
4 changed files with 48 additions and 70 deletions
+29 -24
View File
@@ -49,8 +49,8 @@ class DataValidator
public:
static const unsigned dimensions = 3;
DataValidator();
virtual ~DataValidator() = default;
DataValidator() = default;
~DataValidator() = default;
/**
* Put an item into the validator.
@@ -64,7 +64,7 @@ public:
*
* @param val Item to put
*/
void put(uint64_t timestamp, float val[dimensions], uint64_t error_count, int priority);
void put(uint64_t timestamp, const float val[dimensions], uint64_t error_count, int priority);
/**
* Get the next sibling in the group
@@ -89,7 +89,7 @@ public:
* Get the error count of this validator
* @return the error count
*/
uint64_t error_count() { return _error_count; }
uint64_t error_count() const { return _error_count; }
/**
* Get the values of this validator
@@ -101,19 +101,19 @@ public:
* Get the used status of this validator
* @return true if this validator ever saw data
*/
bool used() { return (_time_last > 0); }
bool used() const { return (_time_last > 0); }
/**
* Get the priority of this validator
* @return the stored priority
*/
int priority() { return (_priority); }
int priority() const { return _priority; }
/**
* Get the error state of this validator
* @return the bitmask with the error status
*/
uint32_t state() { return _error_mask; }
uint32_t state() const { return _error_mask; }
/**
* Reset the error state of this validator
@@ -157,7 +157,7 @@ public:
*
* @return The timeout interval in microseconds
*/
uint32_t get_timeout() const { return _timeout_interval; }
uint32_t get_timeout() const { return _timeout_interval; }
/**
* Data validator error states
@@ -170,24 +170,29 @@ public:
static constexpr uint32_t ERROR_FLAG_HIGH_ERRDENSITY = (0x00000001U << 4);
private:
uint32_t _error_mask; /**< sensor error state */
uint32_t _timeout_interval; /**< interval in which the datastream times out in us */
uint64_t _time_last; /**< last timestamp */
uint64_t _event_count; /**< total data counter */
uint64_t _error_count; /**< error count */
int _error_density; /**< ratio between successful reads and errors */
int _priority; /**< sensor nominal priority */
float _mean[dimensions]; /**< mean of value */
float _lp[dimensions]; /**< low pass value */
float _M2[dimensions]; /**< RMS component value */
float _rms[dimensions]; /**< root mean square error */
float _value[dimensions]; /**< last value */
float _vibe[dimensions]; /**< vibration level, in sensor unit */
uint32_t _error_mask{ERROR_FLAG_NO_ERROR}; /**< sensor error state */
unsigned _value_equal_count; /**< equal values in a row */
unsigned _value_equal_count_threshold; /**< when to consider an equal count as a problem */
uint32_t _timeout_interval{20000}; /**< interval in which the datastream times out in us */
DataValidator *_sibling; /**< sibling in the group */
uint64_t _time_last{0}; /**< last timestamp */
uint64_t _event_count{0}; /**< total data counter */
uint64_t _error_count{0}; /**< error count */
int _error_density{0}; /**< ratio between successful reads and errors */
int _priority{0}; /**< sensor nominal priority */
float _mean[dimensions] {}; /**< mean of value */
float _lp[dimensions] {}; /**< low pass value */
float _M2[dimensions] {}; /**< RMS component value */
float _rms[dimensions] {}; /**< root mean square error */
float _value[dimensions] {}; /**< last value */
float _vibe[dimensions] {}; /**< vibration level, in sensor unit */
unsigned _value_equal_count{0}; /**< equal values in a row */
unsigned _value_equal_count_threshold{VALUE_EQUAL_COUNT_DEFAULT}; /**< when to consider an equal count as a problem */
DataValidator *_sibling{nullptr}; /**< sibling in the group */
static const constexpr unsigned NORETURN_ERRCOUNT = 10000; /**< if the error count reaches this value, return sensor as invalid */
static const constexpr float ERROR_DENSITY_WINDOW = 100.0f; /**< window in measurement counts for errors */