From ae8fcc856d42ed01f6f64f2795cb5c2327a7252a Mon Sep 17 00:00:00 2001 From: Soumya Subramanya Date: Wed, 10 Jan 2024 15:34:54 +0100 Subject: [PATCH] [wip] remove get compoennt criteria match function Signed-off-by: Soumya Subramanya --- include/ocpp/v201/device_model.hpp | 12 +----------- lib/ocpp/v201/device_model.cpp | 26 +------------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/include/ocpp/v201/device_model.hpp b/include/ocpp/v201/device_model.hpp index 28a22a1e2..a469c4fea 100644 --- a/include/ocpp/v201/device_model.hpp +++ b/include/ocpp/v201/device_model.hpp @@ -66,16 +66,6 @@ class DeviceModel { const AttributeEnum& attribute_enum, std::string& value, bool allow_write_only); - /// \brief Iterates over the given \p component_criteria and converts this to the variable names - /// (Active,Available,Enabled,Problem). If any of the variables can not be found as part of a component this - /// function returns false. If any of those variable's value is true, this function returns true. If all variable's - /// value are false, this function returns false - /// \param component_id - /// \param /// component_criteria - /// \return - bool component_criteria_match(const Component& component_id, - const std::vector& component_criteria); - /// \brief Iterates over the given \p component_criteria and converts this to the variable names /// (Active,Available,Enabled,Problem). If any of the variables can not be found as part of a component this /// function returns false. If any of those variable's value is true, this function returns true (except for @@ -83,7 +73,7 @@ class DeviceModel { /// \param component_id /// \param /// component_criteria /// \return - bool component_criteria_match_custom(const Component& component_id, + bool component_criteria_match(const Component& component_id, const std::vector& component_criteria); /// @brief Iterates over the given \p component_variables and filters them according to the requirement conditions. diff --git a/lib/ocpp/v201/device_model.cpp b/lib/ocpp/v201/device_model.cpp index 92d18b9c5..e22ed2661 100644 --- a/lib/ocpp/v201/device_model.cpp +++ b/lib/ocpp/v201/device_model.cpp @@ -11,30 +11,6 @@ namespace ocpp { namespace v201 { bool DeviceModel::component_criteria_match(const Component& component, - const std::vector& component_criteria) { - if (component_criteria.empty()) { - return true; - } - for (const auto& criteria : component_criteria) { - const Variable variable = {conversions::component_criterion_enum_to_string(criteria)}; - // B08.FR.07 - // B08.FR.08 - // B08.FR.09 - // B08.FR.10 - if (!this->device_model.at(component).count(variable)) { - return true; - } else { - const auto response = this->request_value(component, variable, AttributeEnum::Actual); - auto value = response.value; - if (response.status == GetVariableStatusEnum::Accepted and value.has_value() and value.value()) { - return true; - } - } - } - return false; -} - -bool DeviceModel::component_criteria_match_custom(const Component& component, const std::vector& component_criteria) { if (component_criteria.empty()) { return false; @@ -284,7 +260,7 @@ DeviceModel::get_report_data(const std::optional> std::vector report_data_vec; for (auto const& [component, variable_map] : this->device_model) { - if (!component_criteria.has_value() or component_criteria_match_custom(component, component_criteria.value())) { + if (!component_criteria.has_value() or component_criteria_match(component, component_criteria.value())) { for (auto const& [variable, variable_meta_data] : variable_map) { if (!component_variables.has_value() or