|
PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <data_validator_group.h>
Public Member Functions | |
| DataValidatorGroup (unsigned siblings) | |
| ~DataValidatorGroup () | |
| DataValidator * | add_new_validator () |
| Create a new Validator (with index equal to the number of currently existing validators) More... | |
| void | put (unsigned index, uint64_t timestamp, const float val[3], uint64_t error_count, int priority) |
| Put an item into the validator group. More... | |
| float * | get_best (uint64_t timestamp, int *index) |
| Get the best data triplet of the group. More... | |
| float | get_vibration_factor (uint64_t timestamp) |
| Get the RMS / vibration factor. More... | |
| float | get_vibration_offset (uint64_t timestamp, int axis) |
| Get the vibration offset in the sensor unit. More... | |
| unsigned | failover_count () const |
| Get the number of failover events. More... | |
| int | failover_index () |
| Get the index of the failed sensor in the group. More... | |
| uint32_t | failover_state () |
| Get the error state of the failed sensor in the group. More... | |
| void | print () |
| Print the validator value. More... | |
| void | set_timeout (uint32_t timeout_interval_us) |
| Set the timeout value for the whole group. More... | |
| void | set_equal_value_threshold (uint32_t threshold) |
| Set the equal count threshold for the whole group. More... | |
Private Member Functions | |
| DataValidatorGroup (const DataValidatorGroup &) | |
| DataValidatorGroup | operator= (const DataValidatorGroup &) |
Private Attributes | |
| DataValidator * | _first {nullptr} |
| first node in the group More... | |
| DataValidator * | _last {nullptr} |
| last node in the group More... | |
| uint32_t | _timeout_interval_us {0} |
| currently set timeout More... | |
| int | _curr_best {-1} |
| currently best index More... | |
| int | _prev_best {-1} |
| the previous best index More... | |
| uint64_t | _first_failover_time {0} |
| timestamp where the first failover occured or zero if none occured More... | |
| unsigned | _toggle_count {0} |
| number of back and forth switches between two sensors More... | |
Static Private Attributes | |
| static constexpr float | MIN_REGULAR_CONFIDENCE = 0.9f |
Definition at line 46 of file data_validator_group.h.
| DataValidatorGroup::DataValidatorGroup | ( | unsigned | siblings | ) |
| siblings | initial number of DataValidator's. Must be > 0. |
Definition at line 46 of file data_validator_group.cpp.
References _first, _last, _timeout_interval_us, DataValidator::get_timeout(), and DataValidator::setSibling().
| DataValidatorGroup::~DataValidatorGroup | ( | ) |
Definition at line 71 of file data_validator_group.cpp.
References _first, and DataValidator::sibling().
|
private |
| DataValidator * DataValidatorGroup::add_new_validator | ( | ) |
Create a new Validator (with index equal to the number of currently existing validators)
Definition at line 80 of file data_validator_group.cpp.
References _last, _timeout_interval_us, DataValidator::set_timeout(), and DataValidator::setSibling().
Referenced by add_validator_to_group(), and sensors::VotedSensorsUpdate::initSensorClass().
|
inline |
Get the number of failover events.
Definition at line 98 of file data_validator_group.h.
References _toggle_count, failover_index(), failover_state(), print(), set_equal_value_threshold(), and set_timeout().
Referenced by sensors::VotedSensorsUpdate::checkFailover(), setup_base_group(), test_priority_switch(), and test_simple_failover().
| int DataValidatorGroup::failover_index | ( | ) |
Get the index of the failed sensor in the group.
Definition at line 307 of file data_validator_group.cpp.
References _first, _prev_best, DataValidator::ERROR_FLAG_NO_ERROR, DataValidator::sibling(), DataValidator::state(), and DataValidator::used().
Referenced by sensors::VotedSensorsUpdate::checkFailover(), failover_count(), setup_base_group(), test_sensor_failure(), and test_simple_failover().
| uint32_t DataValidatorGroup::failover_state | ( | ) |
Get the error state of the failed sensor in the group.
Definition at line 325 of file data_validator_group.cpp.
References _first, _prev_best, DataValidator::ERROR_FLAG_NO_ERROR, DataValidator::sibling(), DataValidator::state(), and DataValidator::used().
Referenced by sensors::VotedSensorsUpdate::checkFailover(), failover_count(), setup_base_group(), and test_simple_failover().
| float * DataValidatorGroup::get_best | ( | uint64_t | timestamp, |
| int * | index | ||
| ) |
Get the best data triplet of the group.
Definition at line 137 of file data_validator_group.cpp.
References _curr_best, _first, _first_failover_time, _prev_best, _toggle_count, DataValidator::confidence(), f(), FLT_EPSILON, MIN_REGULAR_CONFIDENCE, DataValidator::priority(), DataValidator::reset_state(), DataValidator::sibling(), and DataValidator::value().
Referenced by sensors::VotedSensorsUpdate::accelPoll(), sensors::VotedSensorsUpdate::baroPoll(), fill_one_with_valid_data(), fill_two_with_valid_data(), sensors::VotedSensorsUpdate::gyroPoll(), sensors::VotedSensorsUpdate::magPoll(), test_init(), test_priority_switch(), test_put(), test_sensor_failure(), and test_simple_failover().
| float DataValidatorGroup::get_vibration_factor | ( | uint64_t | timestamp | ) |
Get the RMS / vibration factor.
Definition at line 226 of file data_validator_group.cpp.
References _first, DataValidator::confidence(), DataValidator::rms(), and DataValidator::sibling().
Referenced by setup_base_group(), and test_vibration().
| float DataValidatorGroup::get_vibration_offset | ( | uint64_t | timestamp, |
| int | axis | ||
| ) |
Get the vibration offset in the sensor unit.
Definition at line 252 of file data_validator_group.cpp.
References _first, DataValidator::confidence(), f(), DataValidator::sibling(), and DataValidator::vibration_offset().
Referenced by setup_base_group(), and test_vibration().
|
private |
| void DataValidatorGroup::print | ( | ) |
Print the validator value.
Definition at line 276 of file data_validator_group.cpp.
References _curr_best, _first, _prev_best, _toggle_count, ECL_INFO, DataValidator::ERROR_FLAG_HIGH_ERRCOUNT, DataValidator::ERROR_FLAG_HIGH_ERRDENSITY, DataValidator::ERROR_FLAG_NO_DATA, DataValidator::ERROR_FLAG_NO_ERROR, DataValidator::ERROR_FLAG_STALE_DATA, DataValidator::ERROR_FLAG_TIMEOUT, DataValidator::print(), DataValidator::priority(), DataValidator::sibling(), DataValidator::state(), and DataValidator::used().
Referenced by failover_count(), sensors::VotedSensorsUpdate::printStatus(), and setup_base_group().
| void DataValidatorGroup::put | ( | unsigned | index, |
| uint64_t | timestamp, | ||
| const float | val[3], | ||
| uint64_t | error_count, | ||
| int | priority | ||
| ) |
Put an item into the validator group.
| index | Sensor index |
| timestamp | The timestamp of the measurement |
| val | The 3D vector |
| error_count | The current error count of the sensor |
| priority | The priority of the sensor |
Definition at line 120 of file data_validator_group.cpp.
References _first, DataValidator::put(), and DataValidator::sibling().
Referenced by sensors::VotedSensorsUpdate::accelPoll(), sensors::VotedSensorsUpdate::baroPoll(), fill_one_with_valid_data(), fill_two_with_valid_data(), sensors::VotedSensorsUpdate::gyroPoll(), sensors::VotedSensorsUpdate::magPoll(), test_priority_switch(), and test_simple_failover().
| void DataValidatorGroup::set_equal_value_threshold | ( | uint32_t | threshold | ) |
Set the equal count threshold for the whole group.
| threshold | The number of equal values before considering the sensor stale |
Definition at line 108 of file data_validator_group.cpp.
References _first, DataValidator::set_equal_value_threshold(), and DataValidator::sibling().
Referenced by failover_count(), setup_base_group(), and sensors::VotedSensorsUpdate::VotedSensorsUpdate().
| void DataValidatorGroup::set_timeout | ( | uint32_t | timeout_interval_us | ) |
Set the timeout value for the whole group.
| timeout_interval_us | The timeout interval in microseconds |
Definition at line 95 of file data_validator_group.cpp.
References _first, _timeout_interval_us, DataValidator::set_timeout(), and DataValidator::sibling().
Referenced by failover_count(), setup_base_group(), and sensors::VotedSensorsUpdate::VotedSensorsUpdate().
|
private |
currently best index
Definition at line 141 of file data_validator_group.h.
Referenced by get_best(), and print().
|
private |
first node in the group
Definition at line 136 of file data_validator_group.h.
Referenced by DataValidatorGroup(), failover_index(), failover_state(), get_best(), get_vibration_factor(), get_vibration_offset(), print(), put(), set_equal_value_threshold(), set_timeout(), and ~DataValidatorGroup().
|
private |
timestamp where the first failover occured or zero if none occured
Definition at line 144 of file data_validator_group.h.
Referenced by get_best().
|
private |
last node in the group
Definition at line 137 of file data_validator_group.h.
Referenced by add_new_validator(), and DataValidatorGroup().
|
private |
the previous best index
Definition at line 142 of file data_validator_group.h.
Referenced by failover_index(), failover_state(), get_best(), and print().
|
private |
currently set timeout
Definition at line 139 of file data_validator_group.h.
Referenced by add_new_validator(), DataValidatorGroup(), and set_timeout().
|
private |
number of back and forth switches between two sensors
Definition at line 146 of file data_validator_group.h.
Referenced by failover_count(), get_best(), and print().
|
staticprivate |
Definition at line 148 of file data_validator_group.h.
Referenced by get_best().