mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-01 19:34:07 +08:00
* Reverse the linked list of data_validator_group and maintain a first node for search from index 0 Fixes issue PX4/Firmware#8644 * fix code style * validator: fix shadowing of 'sibling' argument
This commit is contained in:
parent
337cdcc59a
commit
d078d68f64
@ -42,7 +42,7 @@
|
||||
#include "data_validator.h"
|
||||
#include <ecl/ecl.h>
|
||||
|
||||
DataValidator::DataValidator(DataValidator *prev_sibling) :
|
||||
DataValidator::DataValidator() :
|
||||
_error_mask(ERROR_FLAG_NO_ERROR),
|
||||
_timeout_interval(20000),
|
||||
_time_last(0),
|
||||
@ -58,7 +58,7 @@ DataValidator::DataValidator(DataValidator *prev_sibling) :
|
||||
_vibe{0.0f},
|
||||
_value_equal_count(0),
|
||||
_value_equal_count_threshold(VALUE_EQUAL_COUNT_DEFAULT),
|
||||
_sibling(prev_sibling)
|
||||
_sibling(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class __EXPORT DataValidator {
|
||||
public:
|
||||
static const unsigned dimensions = 3;
|
||||
|
||||
DataValidator(DataValidator *prev_sibling = nullptr);
|
||||
DataValidator();
|
||||
virtual ~DataValidator() = default;
|
||||
|
||||
/**
|
||||
@ -72,6 +72,12 @@ public:
|
||||
*/
|
||||
DataValidator* sibling() { return _sibling; }
|
||||
|
||||
/**
|
||||
* Set the sibling to the next node in the group
|
||||
*
|
||||
*/
|
||||
void setSibling(DataValidator* new_sibling) { _sibling = new_sibling; }
|
||||
|
||||
/**
|
||||
* Get the confidence of this validator
|
||||
* @return the confidence between 0 and 1
|
||||
|
||||
@ -45,19 +45,30 @@
|
||||
|
||||
DataValidatorGroup::DataValidatorGroup(unsigned siblings) :
|
||||
_first(nullptr),
|
||||
_last(nullptr),
|
||||
_curr_best(-1),
|
||||
_prev_best(-1),
|
||||
_first_failover_time(0),
|
||||
_toggle_count(0)
|
||||
{
|
||||
DataValidator *next = _first;
|
||||
DataValidator *next = nullptr;
|
||||
DataValidator *prev = nullptr;
|
||||
|
||||
for (unsigned i = 0; i < siblings; i++) {
|
||||
next = new DataValidator(next);
|
||||
next = new DataValidator();
|
||||
if(i == 0) {
|
||||
_first = next;
|
||||
} else {
|
||||
prev->setSibling(next);
|
||||
}
|
||||
prev = next;
|
||||
}
|
||||
|
||||
_first = next;
|
||||
_timeout_interval_us = _first->get_timeout();
|
||||
_last = next;
|
||||
|
||||
if(_first) {
|
||||
_timeout_interval_us = _first->get_timeout();
|
||||
}
|
||||
}
|
||||
|
||||
DataValidatorGroup::~DataValidatorGroup()
|
||||
@ -71,13 +82,14 @@ DataValidatorGroup::~DataValidatorGroup()
|
||||
|
||||
DataValidator *DataValidatorGroup::add_new_validator()
|
||||
{
|
||||
DataValidator *validator = new DataValidator(_first);
|
||||
DataValidator *validator = new DataValidator();
|
||||
if (!validator) {
|
||||
return nullptr;
|
||||
}
|
||||
_first = validator;
|
||||
_first->set_timeout(_timeout_interval_us);
|
||||
return _first;
|
||||
_last->setSibling(validator);
|
||||
_last = validator;
|
||||
_last->set_timeout(_timeout_interval_us);
|
||||
return _last;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -133,7 +133,8 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
DataValidator *_first; /**< sibling in the group */
|
||||
DataValidator *_first; /**< first node in the group */
|
||||
DataValidator *_last; /**< last node in the group */
|
||||
uint32_t _timeout_interval_us; /**< currently set timeout */
|
||||
int _curr_best; /**< currently best index */
|
||||
int _prev_best; /**< the previous best index */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user