mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-27 11:20:35 +08:00
Expand auto-format coverage and tiny style changes
This commit is contained in:
committed by
Mathieu Bresciani
parent
fbdd75da2e
commit
f20726d47f
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user