From 011b4c2e4e9c39723250ed6805daa5b0aac3a1d4 Mon Sep 17 00:00:00 2001 From: Dusan Zivkovic Date: Wed, 18 Sep 2019 16:51:19 +0200 Subject: [PATCH] data_validator_group: add a method to get the state of the sensor with the provided index --- validation/data_validator_group.cpp | 19 +++++++++++++++++++ validation/data_validator_group.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/validation/data_validator_group.cpp b/validation/data_validator_group.cpp index 82852ef21f..719275a415 100644 --- a/validation/data_validator_group.cpp +++ b/validation/data_validator_group.cpp @@ -338,3 +338,22 @@ DataValidatorGroup::failover_state() return DataValidator::ERROR_FLAG_NO_ERROR; } + +uint32_t +DataValidatorGroup::get_sensor_state(unsigned index) +{ + DataValidator *next = _first; + unsigned i = 0; + + while (next != nullptr) { + if (i == index) { + return next->state(); + } + + next = next->sibling(); + i++; + } + + // sensor index not found + return UINT32_MAX; +} diff --git a/validation/data_validator_group.h b/validation/data_validator_group.h index 094d062d28..4fd6ab0a1c 100644 --- a/validation/data_validator_group.h +++ b/validation/data_validator_group.h @@ -111,6 +111,13 @@ public: */ 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); + /** * Print the validator value *