Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Replace get_vector_from_csv with split_string #791

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ std::string to_csl(const std::vector<std::string>& vec) {
}

void ChargePointConfiguration::init_supported_measurands() {
const auto _supported_measurands = ocpp::get_vector_from_csv(this->config["Internal"]["SupportedMeasurands"]);
const auto _supported_measurands = ocpp::split_string(this->config["Internal"]["SupportedMeasurands"], ',');
for (const auto& measurand : _supported_measurands) {
try {
const auto _measurand = conversions::string_to_measurand(measurand);
Expand Down
2 changes: 1 addition & 1 deletion lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4165,7 +4165,7 @@ void ChargePointImpl::stop_transaction(int32_t connector, Reason reason, std::op

std::vector<Measurand> ChargePointImpl::get_measurands_vec(const std::string& measurands_csv) {
std::vector<Measurand> measurands;
std::vector<std::string> measurands_strings = ocpp::get_vector_from_csv(measurands_csv);
std::vector<std::string> measurands_strings = ocpp::split_string(measurands_csv, ',');

for (const auto& measurand_string : measurands_strings) {
try {
Expand Down
6 changes: 3 additions & 3 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,8 @@ void ChargePoint::remove_network_connection_profiles_below_actual_security_profi
VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL);

// Update the NetworkConfigurationPriority so only remaining profiles are in there
const auto network_priority = ocpp::get_vector_from_csv(
this->device_model->get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority));
const auto network_priority = ocpp::split_string(
this->device_model->get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority), ',');

auto in_network_profiles = [&network_connection_profiles](const std::string& item) {
auto is_same_slot = [&item](const SetNetworkProfileRequest& profile) {
Expand Down Expand Up @@ -1679,7 +1679,7 @@ void ChargePoint::handle_variables_changed(const std::map<SetVariableData, SetVa
bool ChargePoint::validate_set_variable(const SetVariableData& set_variable_data) {
ComponentVariable cv = {set_variable_data.component, std::nullopt, set_variable_data.variable};
if (cv == ControllerComponentVariables::NetworkConfigurationPriority) {
const auto network_configuration_priorities = ocpp::get_vector_from_csv(set_variable_data.attributeValue.get());
const auto network_configuration_priorities = ocpp::split_string(set_variable_data.attributeValue.get(), ',');
const auto active_security_profile =
this->device_model->get_value<int>(ControllerComponentVariables::SecurityProfile);
for (const auto configuration_slot : network_configuration_priorities) {
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/v201/connectivity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ void ConnectivityManager::cache_network_connection_profiles() {
this->network_connection_profiles =
json::parse(this->device_model.get_value<std::string>(ControllerComponentVariables::NetworkConnectionProfiles));

this->network_connection_priorities = ocpp::get_vector_from_csv(
this->device_model.get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority));
this->network_connection_priorities = ocpp::split_string(
this->device_model.get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority), ',');

if (this->network_connection_priorities.empty()) {
EVLOG_AND_THROW(std::runtime_error("NetworkConfigurationPriority must not be empty"));
Expand Down
6 changes: 3 additions & 3 deletions lib/ocpp/v201/device_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ bool validate_value(const VariableCharacteristics& characteristics, const std::s
if (!characteristics.valuesList.has_value()) {
return true;
}
const auto values_list = ocpp::get_vector_from_csv(characteristics.valuesList.value().get());
const auto values_list = ocpp::split_string(characteristics.valuesList.value().get(), ',');
return std::find(values_list.begin(), values_list.end(), value) != values_list.end();
}
default: // same validation for MemberList or SequenceList
Expand All @@ -186,8 +186,8 @@ bool validate_value(const VariableCharacteristics& characteristics, const std::s
if (!characteristics.valuesList.has_value()) {
return true;
}
const auto values_list = ocpp::get_vector_from_csv(characteristics.valuesList.value().get());
const auto value_csv = get_vector_from_csv(value);
const auto values_list = ocpp::split_string(characteristics.valuesList.value().get(), ',');
const auto value_csv = ocpp::split_string(value, ',');
for (const auto& v : value_csv) {
if (std::find(values_list.begin(), values_list.end(), v) == values_list.end()) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/ocpp/v201/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace utils {

std::vector<MeasurandEnum> get_measurands_vec(const std::string& measurands_csv) {
std::vector<MeasurandEnum> measurands;
std::vector<std::string> measurands_strings = ocpp::get_vector_from_csv(measurands_csv);
std::vector<std::string> measurands_strings = ocpp::split_string(measurands_csv, ',');

for (const auto& measurand_string : measurands_strings) {
try {
Expand Down
Loading