Skip to content

Commit

Permalink
[wip] remove get compoennt criteria match function
Browse files Browse the repository at this point in the history
Signed-off-by: Soumya Subramanya <[email protected]>
  • Loading branch information
SNSubramanya committed Jan 10, 2024
1 parent 3ae465d commit c8bed6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
12 changes: 1 addition & 11 deletions include/ocpp/v201/device_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,14 @@ 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<ComponentCriterionEnum>& 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
/// criteria problem). If all variable's value are false, this function returns false
/// \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<ComponentCriterionEnum>& component_criteria);

/// @brief Iterates over the given \p component_variables and filters them according to the requirement conditions.
Expand Down
26 changes: 1 addition & 25 deletions lib/ocpp/v201/device_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,6 @@ namespace ocpp {
namespace v201 {

bool DeviceModel::component_criteria_match(const Component& component,
const std::vector<ComponentCriterionEnum>& 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<bool>(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<ComponentCriterionEnum>& component_criteria) {
if (component_criteria.empty()) {
return false;
Expand Down Expand Up @@ -284,7 +260,7 @@ DeviceModel::get_report_data(const std::optional<std::vector<ComponentVariable>>
std::vector<ReportData> 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
Expand Down

0 comments on commit c8bed6e

Please sign in to comment.