mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-18 22:00:34 +08:00
Expand auto-format coverage and tiny style changes
This commit is contained in:
committed by
Mathieu Bresciani
parent
fbdd75da2e
commit
f20726d47f
@@ -43,17 +43,13 @@
|
||||
|
||||
#include <ecl.h>
|
||||
|
||||
void
|
||||
DataValidator::put(uint64_t timestamp, float val, uint64_t error_count_in, int priority_in)
|
||||
{
|
||||
float data[dimensions] = { val }; //sets the first value and all others to 0
|
||||
|
||||
void DataValidator::put(uint64_t timestamp, float val, uint64_t error_count_in, int priority_in) {
|
||||
float data[dimensions] = {val}; // sets the first value and all others to 0
|
||||
put(timestamp, data, error_count_in, priority_in);
|
||||
}
|
||||
|
||||
void
|
||||
DataValidator::put(uint64_t timestamp, const float val[dimensions], uint64_t error_count_in, int priority_in)
|
||||
{
|
||||
void DataValidator::put(uint64_t timestamp, const float val[dimensions], uint64_t error_count_in, int priority_in) {
|
||||
|
||||
_event_count++;
|
||||
|
||||
if (error_count_in > _error_count) {
|
||||
@@ -99,9 +95,8 @@ DataValidator::put(uint64_t timestamp, const float val[dimensions], uint64_t err
|
||||
_time_last = timestamp;
|
||||
}
|
||||
|
||||
float
|
||||
DataValidator::confidence(uint64_t timestamp)
|
||||
{
|
||||
float DataValidator::confidence(uint64_t timestamp) {
|
||||
|
||||
float ret = 1.0f;
|
||||
|
||||
/* check if we have any data */
|
||||
@@ -128,7 +123,6 @@ DataValidator::confidence(uint64_t timestamp)
|
||||
/* cap error density counter at window size */
|
||||
_error_mask |= ERROR_FLAG_HIGH_ERRDENSITY;
|
||||
_error_density = ERROR_DENSITY_WINDOW;
|
||||
|
||||
}
|
||||
|
||||
/* no critical errors */
|
||||
@@ -144,17 +138,14 @@ DataValidator::confidence(uint64_t timestamp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
DataValidator::print()
|
||||
{
|
||||
void DataValidator::print() {
|
||||
if (_time_last == 0) {
|
||||
ECL_INFO("\tno data");
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < dimensions; i++) {
|
||||
ECL_INFO("\tval: %8.4f, lp: %8.4f mean dev: %8.4f RMS: %8.4f conf: %8.4f",
|
||||
(double) _value[i], (double)_lp[i], (double)_mean[i],
|
||||
(double)_rms[i], (double)confidence(ecl_absolute_time()));
|
||||
ECL_INFO("\tval: %8.4f, lp: %8.4f mean dev: %8.4f RMS: %8.4f conf: %8.4f", (double)_value[i],
|
||||
(double)_lp[i], (double)_mean[i], (double)_rms[i], (double)confidence(ecl_absolute_time()));
|
||||
}
|
||||
}
|
||||
|
||||
+46
-44
@@ -44,8 +44,7 @@
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class DataValidator
|
||||
{
|
||||
class DataValidator {
|
||||
public:
|
||||
static const unsigned dimensions = 3;
|
||||
|
||||
@@ -57,146 +56,149 @@ public:
|
||||
*
|
||||
* @param val Item to put
|
||||
*/
|
||||
void put(uint64_t timestamp, float val, uint64_t error_count, int priority);
|
||||
void put(uint64_t timestamp, float val, uint64_t error_count, int priority);
|
||||
|
||||
/**
|
||||
* Put a 3D item into the validator.
|
||||
*
|
||||
* @param val Item to put
|
||||
*/
|
||||
void put(uint64_t timestamp, const 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
|
||||
*
|
||||
* @return the next sibling
|
||||
*/
|
||||
DataValidator *sibling() { return _sibling; }
|
||||
DataValidator *sibling() { return _sibling; }
|
||||
|
||||
/**
|
||||
* Set the sibling to the next node in the group
|
||||
*
|
||||
*/
|
||||
void setSibling(DataValidator *new_sibling) { _sibling = new_sibling; }
|
||||
void setSibling(DataValidator *new_sibling) { _sibling = new_sibling; }
|
||||
|
||||
/**
|
||||
* Get the confidence of this validator
|
||||
* @return the confidence between 0 and 1
|
||||
*/
|
||||
float confidence(uint64_t timestamp);
|
||||
float confidence(uint64_t timestamp);
|
||||
|
||||
/**
|
||||
* Get the error count of this validator
|
||||
* @return the error count
|
||||
*/
|
||||
uint64_t error_count() const { return _error_count; }
|
||||
uint64_t error_count() const { return _error_count; }
|
||||
|
||||
/**
|
||||
* Get the values of this validator
|
||||
* @return the stored value
|
||||
*/
|
||||
float *value() { return _value; }
|
||||
float *value() { return _value; }
|
||||
|
||||
/**
|
||||
* Get the used status of this validator
|
||||
* @return true if this validator ever saw data
|
||||
*/
|
||||
bool used() const { return (_time_last > 0); }
|
||||
bool used() const { return (_time_last > 0); }
|
||||
|
||||
/**
|
||||
* Get the priority of this validator
|
||||
* @return the stored priority
|
||||
*/
|
||||
int priority() const { return _priority; }
|
||||
int priority() const { return _priority; }
|
||||
|
||||
/**
|
||||
* Get the error state of this validator
|
||||
* @return the bitmask with the error status
|
||||
*/
|
||||
uint32_t state() const { return _error_mask; }
|
||||
uint32_t state() const { return _error_mask; }
|
||||
|
||||
/**
|
||||
* Reset the error state of this validator
|
||||
*/
|
||||
void reset_state() { _error_mask = ERROR_FLAG_NO_ERROR; }
|
||||
void reset_state() { _error_mask = ERROR_FLAG_NO_ERROR; }
|
||||
|
||||
/**
|
||||
* Get the RMS values of this validator
|
||||
* @return the stored RMS
|
||||
*/
|
||||
float *rms() { return _rms; }
|
||||
float *rms() { return _rms; }
|
||||
|
||||
/**
|
||||
* Get the vibration offset
|
||||
* @return the stored vibration offset
|
||||
*/
|
||||
float *vibration_offset() { return _vibe; }
|
||||
float *vibration_offset() { return _vibe; }
|
||||
|
||||
/**
|
||||
* Print the validator value
|
||||
*
|
||||
*/
|
||||
void print();
|
||||
void print();
|
||||
|
||||
/**
|
||||
* Set the timeout value
|
||||
*
|
||||
* @param timeout_interval_us The timeout interval in microseconds
|
||||
*/
|
||||
void set_timeout(uint32_t timeout_interval_us) { _timeout_interval = timeout_interval_us; }
|
||||
void set_timeout(uint32_t timeout_interval_us) { _timeout_interval = timeout_interval_us; }
|
||||
|
||||
/**
|
||||
* Set the equal count threshold
|
||||
*
|
||||
* @param threshold The number of equal values before considering the sensor stale
|
||||
*/
|
||||
void set_equal_value_threshold(uint32_t threshold) { _value_equal_count_threshold = threshold; }
|
||||
void set_equal_value_threshold(uint32_t threshold) { _value_equal_count_threshold = threshold; }
|
||||
|
||||
/**
|
||||
* Get the timeout value
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
static constexpr uint32_t ERROR_FLAG_NO_ERROR = (0x00000000U);
|
||||
static constexpr uint32_t ERROR_FLAG_NO_DATA = (0x00000001U);
|
||||
static constexpr uint32_t ERROR_FLAG_STALE_DATA = (0x00000001U << 1);
|
||||
static constexpr uint32_t ERROR_FLAG_TIMEOUT = (0x00000001U << 2);
|
||||
static constexpr uint32_t ERROR_FLAG_HIGH_ERRCOUNT = (0x00000001U << 3);
|
||||
static constexpr uint32_t ERROR_FLAG_HIGH_ERRDENSITY = (0x00000001U << 4);
|
||||
static constexpr uint32_t ERROR_FLAG_NO_ERROR = (0x00000000U);
|
||||
static constexpr uint32_t ERROR_FLAG_NO_DATA = (0x00000001U);
|
||||
static constexpr uint32_t ERROR_FLAG_STALE_DATA = (0x00000001U << 1);
|
||||
static constexpr uint32_t ERROR_FLAG_TIMEOUT = (0x00000001U << 2);
|
||||
static constexpr uint32_t ERROR_FLAG_HIGH_ERRCOUNT = (0x00000001U << 3);
|
||||
static constexpr uint32_t ERROR_FLAG_HIGH_ERRDENSITY = (0x00000001U << 4);
|
||||
|
||||
private:
|
||||
uint32_t _error_mask{ERROR_FLAG_NO_ERROR}; /**< sensor error state */
|
||||
uint32_t _error_mask{ERROR_FLAG_NO_ERROR}; /**< sensor error state */
|
||||
|
||||
uint32_t _timeout_interval{20000}; /**< interval in which the datastream times out in us */
|
||||
uint32_t _timeout_interval{20000}; /**< interval in which the datastream times out in us */
|
||||
|
||||
uint64_t _time_last{0}; /**< last timestamp */
|
||||
uint64_t _event_count{0}; /**< total data counter */
|
||||
uint64_t _error_count{0}; /**< error count */
|
||||
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 _error_density{0}; /**< ratio between successful reads and errors */
|
||||
|
||||
int _priority{0}; /**< sensor nominal priority */
|
||||
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 */
|
||||
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 */
|
||||
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 */
|
||||
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 */
|
||||
static const constexpr unsigned VALUE_EQUAL_COUNT_DEFAULT = 100; /**< if the sensor value is the same (accumulated also between axes) this many times, flag it */
|
||||
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 */
|
||||
static const constexpr unsigned VALUE_EQUAL_COUNT_DEFAULT =
|
||||
100; /**< if the sensor value is the same (accumulated also between axes) this many times, flag it */
|
||||
|
||||
/* we don't want this class to be copied */
|
||||
DataValidator(const DataValidator &) = delete;
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
#include <ecl.h>
|
||||
#include <float.h>
|
||||
|
||||
DataValidatorGroup::DataValidatorGroup(unsigned siblings)
|
||||
{
|
||||
DataValidatorGroup::DataValidatorGroup(unsigned siblings) {
|
||||
|
||||
DataValidator *next = nullptr;
|
||||
DataValidator *prev = nullptr;
|
||||
|
||||
@@ -68,8 +68,7 @@ DataValidatorGroup::DataValidatorGroup(unsigned siblings)
|
||||
}
|
||||
}
|
||||
|
||||
DataValidatorGroup::~DataValidatorGroup()
|
||||
{
|
||||
DataValidatorGroup::~DataValidatorGroup() {
|
||||
while (_first) {
|
||||
DataValidator *next = _first->sibling();
|
||||
delete (_first);
|
||||
@@ -77,8 +76,8 @@ DataValidatorGroup::~DataValidatorGroup()
|
||||
}
|
||||
}
|
||||
|
||||
DataValidator *DataValidatorGroup::add_new_validator()
|
||||
{
|
||||
DataValidator *DataValidatorGroup::add_new_validator() {
|
||||
|
||||
DataValidator *validator = new DataValidator();
|
||||
|
||||
if (!validator) {
|
||||
@@ -91,9 +90,8 @@ DataValidator *DataValidatorGroup::add_new_validator()
|
||||
return _last;
|
||||
}
|
||||
|
||||
void
|
||||
DataValidatorGroup::set_timeout(uint32_t timeout_interval_us)
|
||||
{
|
||||
void DataValidatorGroup::set_timeout(uint32_t timeout_interval_us) {
|
||||
|
||||
DataValidator *next = _first;
|
||||
|
||||
while (next != nullptr) {
|
||||
@@ -104,9 +102,8 @@ DataValidatorGroup::set_timeout(uint32_t timeout_interval_us)
|
||||
_timeout_interval_us = timeout_interval_us;
|
||||
}
|
||||
|
||||
void
|
||||
DataValidatorGroup::set_equal_value_threshold(uint32_t threshold)
|
||||
{
|
||||
void DataValidatorGroup::set_equal_value_threshold(uint32_t threshold) {
|
||||
|
||||
DataValidator *next = _first;
|
||||
|
||||
while (next != nullptr) {
|
||||
@@ -115,10 +112,9 @@ DataValidatorGroup::set_equal_value_threshold(uint32_t threshold)
|
||||
}
|
||||
}
|
||||
|
||||
void DataValidatorGroup::put(unsigned index, uint64_t timestamp, const float val[3], uint64_t error_count,
|
||||
int priority) {
|
||||
|
||||
void
|
||||
DataValidatorGroup::put(unsigned index, uint64_t timestamp, const float val[3], uint64_t error_count, int priority)
|
||||
{
|
||||
DataValidator *next = _first;
|
||||
unsigned i = 0;
|
||||
|
||||
@@ -133,9 +129,8 @@ DataValidatorGroup::put(unsigned index, uint64_t timestamp, const float val[3],
|
||||
}
|
||||
}
|
||||
|
||||
float *
|
||||
DataValidatorGroup::get_best(uint64_t timestamp, int *index)
|
||||
{
|
||||
float *DataValidatorGroup::get_best(uint64_t timestamp, int *index) {
|
||||
|
||||
DataValidator *next = _first;
|
||||
|
||||
// XXX This should eventually also include voting
|
||||
@@ -164,9 +159,8 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index)
|
||||
*/
|
||||
if ((((max_confidence < MIN_REGULAR_CONFIDENCE) && (confidence >= MIN_REGULAR_CONFIDENCE)) ||
|
||||
(confidence > max_confidence && (next->priority() >= max_priority)) ||
|
||||
(fabsf(confidence - max_confidence) < 0.01f && (next->priority() > max_priority))
|
||||
) && (confidence > 0.0f)) {
|
||||
|
||||
(fabsf(confidence - max_confidence) < 0.01f && (next->priority() > max_priority))) &&
|
||||
(confidence > 0.0f)) {
|
||||
max_index = i;
|
||||
max_confidence = confidence;
|
||||
max_priority = next->priority();
|
||||
@@ -180,13 +174,11 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index)
|
||||
/* the current best sensor is not matching the previous best sensor,
|
||||
* or the only sensor went bad */
|
||||
if (max_index != _curr_best || ((max_confidence < FLT_EPSILON) && (_curr_best >= 0))) {
|
||||
|
||||
bool true_failsafe = true;
|
||||
|
||||
/* check whether the switch was a failsafe or preferring a higher priority sensor */
|
||||
if (pre_check_prio != -1 && pre_check_prio < max_priority &&
|
||||
fabsf(pre_check_confidence - max_confidence) < 0.1f) {
|
||||
|
||||
/* this is not a failover */
|
||||
true_failsafe = false;
|
||||
|
||||
@@ -222,16 +214,14 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index)
|
||||
return (best) ? best->value() : nullptr;
|
||||
}
|
||||
|
||||
float
|
||||
DataValidatorGroup::get_vibration_factor(uint64_t timestamp)
|
||||
{
|
||||
float DataValidatorGroup::get_vibration_factor(uint64_t timestamp) {
|
||||
|
||||
DataValidator *next = _first;
|
||||
|
||||
float vibe = 0.0f;
|
||||
|
||||
/* find the best RMS value of a non-timed out sensor */
|
||||
while (next != nullptr) {
|
||||
|
||||
if (next->confidence(timestamp) > 0.5f) {
|
||||
float *rms = next->rms();
|
||||
|
||||
@@ -248,16 +238,14 @@ DataValidatorGroup::get_vibration_factor(uint64_t timestamp)
|
||||
return vibe;
|
||||
}
|
||||
|
||||
float
|
||||
DataValidatorGroup::get_vibration_offset(uint64_t timestamp, int axis)
|
||||
{
|
||||
float DataValidatorGroup::get_vibration_offset(uint64_t timestamp, int axis) {
|
||||
|
||||
DataValidator *next = _first;
|
||||
|
||||
float vibe = -1.0f;
|
||||
|
||||
/* find the best vibration value of a non-timed out sensor */
|
||||
while (next != nullptr) {
|
||||
|
||||
if (next->confidence(timestamp) > 0.5f) {
|
||||
float *vibration_offset = next->vibration_offset();
|
||||
|
||||
@@ -272,13 +260,10 @@ DataValidatorGroup::get_vibration_offset(uint64_t timestamp, int axis)
|
||||
return vibe;
|
||||
}
|
||||
|
||||
void
|
||||
DataValidatorGroup::print()
|
||||
{
|
||||
/* print the group's state */
|
||||
ECL_INFO("validator: best: %d, prev best: %d, failsafe: %s (%u events)",
|
||||
_curr_best, _prev_best, (_toggle_count > 0) ? "YES" : "NO",
|
||||
_toggle_count);
|
||||
void DataValidatorGroup::print() {
|
||||
|
||||
ECL_INFO("validator: best: %d, prev best: %d, failsafe: %s (%u events)", _curr_best, _prev_best,
|
||||
(_toggle_count > 0) ? "YES" : "NO", _toggle_count);
|
||||
|
||||
DataValidator *next = _first;
|
||||
unsigned i = 0;
|
||||
@@ -303,14 +288,14 @@ DataValidatorGroup::print()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
DataValidatorGroup::failover_index()
|
||||
{
|
||||
int DataValidatorGroup::failover_index() {
|
||||
|
||||
DataValidator *next = _first;
|
||||
unsigned i = 0;
|
||||
|
||||
while (next != nullptr) {
|
||||
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) && (i == (unsigned)_prev_best)) {
|
||||
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) &&
|
||||
(i == (unsigned)_prev_best)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -321,14 +306,14 @@ DataValidatorGroup::failover_index()
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DataValidatorGroup::failover_state()
|
||||
{
|
||||
uint32_t DataValidatorGroup::failover_state() {
|
||||
|
||||
DataValidator *next = _first;
|
||||
unsigned i = 0;
|
||||
|
||||
while (next != nullptr) {
|
||||
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) && (i == (unsigned)_prev_best)) {
|
||||
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) &&
|
||||
(i == (unsigned)_prev_best)) {
|
||||
return next->state();
|
||||
}
|
||||
|
||||
@@ -339,9 +324,8 @@ DataValidatorGroup::failover_state()
|
||||
return DataValidator::ERROR_FLAG_NO_ERROR;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DataValidatorGroup::get_sensor_state(unsigned index)
|
||||
{
|
||||
uint32_t DataValidatorGroup::get_sensor_state(unsigned index) {
|
||||
|
||||
DataValidator *next = _first;
|
||||
unsigned i = 0;
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@
|
||||
|
||||
#include "data_validator.h"
|
||||
|
||||
class DataValidatorGroup
|
||||
{
|
||||
class DataValidatorGroup {
|
||||
public:
|
||||
/**
|
||||
* @param siblings initial number of DataValidator's. Must be > 0.
|
||||
@@ -67,90 +66,89 @@ public:
|
||||
* @param error_count The current error count of the sensor
|
||||
* @param priority The priority of the sensor
|
||||
*/
|
||||
void put(unsigned index, uint64_t timestamp, const float val[3], uint64_t error_count, int priority);
|
||||
void put(unsigned index, uint64_t timestamp, const float val[3], uint64_t error_count, int priority);
|
||||
|
||||
/**
|
||||
* Get the best data triplet of the group
|
||||
*
|
||||
* @return pointer to the array of best values
|
||||
*/
|
||||
float *get_best(uint64_t timestamp, int *index);
|
||||
float *get_best(uint64_t timestamp, int *index);
|
||||
|
||||
/**
|
||||
* Get the RMS / vibration factor
|
||||
*
|
||||
* @return float value representing the RMS, which a valid indicator for vibration
|
||||
*/
|
||||
float get_vibration_factor(uint64_t timestamp);
|
||||
float get_vibration_factor(uint64_t timestamp);
|
||||
|
||||
/**
|
||||
* Get the vibration offset in the sensor unit
|
||||
*
|
||||
* @return float value representing the vibration offset
|
||||
*/
|
||||
float get_vibration_offset(uint64_t timestamp, int axis);
|
||||
float get_vibration_offset(uint64_t timestamp, int axis);
|
||||
|
||||
/**
|
||||
* Get the number of failover events
|
||||
*
|
||||
* @return the number of failovers
|
||||
*/
|
||||
unsigned failover_count() const { return _toggle_count; }
|
||||
unsigned failover_count() const { return _toggle_count; }
|
||||
|
||||
/**
|
||||
* Get the index of the failed sensor in the group
|
||||
*
|
||||
* @return index of the failed sensor
|
||||
*/
|
||||
int failover_index();
|
||||
int failover_index();
|
||||
|
||||
/**
|
||||
* Get the error state of the failed sensor in the group
|
||||
*
|
||||
* @return bitmask with erro states of the failed sensor
|
||||
*/
|
||||
uint32_t failover_state();
|
||||
uint32_t failover_state();
|
||||
|
||||
/**
|
||||
* Get the error state of the sensor with the specified index
|
||||
*
|
||||
* @return bitmask with error states of the sensor
|
||||
*/
|
||||
uint32_t get_sensor_state(unsigned index);
|
||||
uint32_t get_sensor_state(unsigned index);
|
||||
|
||||
/**
|
||||
* Print the validator value
|
||||
*
|
||||
*/
|
||||
void print();
|
||||
void print();
|
||||
|
||||
/**
|
||||
* Set the timeout value for the whole group
|
||||
*
|
||||
* @param timeout_interval_us The timeout interval in microseconds
|
||||
*/
|
||||
void set_timeout(uint32_t timeout_interval_us);
|
||||
void set_timeout(uint32_t timeout_interval_us);
|
||||
|
||||
/**
|
||||
* Set the equal count threshold for the whole group
|
||||
*
|
||||
* @param threshold The number of equal values before considering the sensor stale
|
||||
*/
|
||||
void set_equal_value_threshold(uint32_t threshold);
|
||||
|
||||
void set_equal_value_threshold(uint32_t threshold);
|
||||
|
||||
private:
|
||||
DataValidator *_first{nullptr}; /**< first node in the group */
|
||||
DataValidator *_last{nullptr}; /**< last node in the group */
|
||||
DataValidator *_first{nullptr}; /**< first node in the group */
|
||||
DataValidator *_last{nullptr}; /**< last node in the group */
|
||||
|
||||
uint32_t _timeout_interval_us{0}; /**< currently set timeout */
|
||||
|
||||
int _curr_best{-1}; /**< currently best index */
|
||||
int _prev_best{-1}; /**< the previous best index */
|
||||
int _curr_best{-1}; /**< currently best index */
|
||||
int _prev_best{-1}; /**< the previous best index */
|
||||
|
||||
uint64_t _first_failover_time{0}; /**< timestamp where the first failover occured or zero if none occured */
|
||||
uint64_t _first_failover_time{0}; /**< timestamp where the first failover occured or zero if none occured */
|
||||
|
||||
unsigned _toggle_count{0}; /**< number of back and forth switches between two sensors */
|
||||
unsigned _toggle_count{0}; /**< number of back and forth switches between two sensors */
|
||||
|
||||
static constexpr float MIN_REGULAR_CONFIDENCE = 0.9f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user