Skip to content

Commit 3fb3544

Browse files
committed
feat: added checking for behind the scenes supported feature profiles
Signed-off-by: James Chapman <james.chapman@pionix.de>
1 parent 16a4196 commit 3fb3544

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

lib/everest/ocpp/lib/ocpp/v16/charge_point_configuration_devicemodel.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@
2323
#include <string_view>
2424
#include <type_traits>
2525
#include <utility>
26-
#include <vector>
2726

2827
namespace {
2928
using namespace ocpp;
3029
using SetResult = v16::ChargePointConfigurationDeviceModel::SetResult;
3130
using DeviceModelInterface = v2::DeviceModelInterface;
3231
using SupportedFeatureProfiles = v16::SupportedFeatureProfiles;
3332

34-
constexpr const char* custom_component = "Custom";
33+
constexpr const char* cost_and_price_component = "OCPP16LegacyCtrlr";
34+
constexpr const char* cost_and_price_feature = "CostAndPrice";
35+
constexpr const char* custom_component = "CustomizationCtrlr";
36+
constexpr const char* custom_feature = "Custom";
37+
constexpr const char* pnc_component = "ISO15118Ctrlr";
38+
constexpr const char* pnc_feature = "PnC";
39+
40+
constexpr bool starts_with(const std::string_view& str, const std::string_view& looking_for) {
41+
return str.rfind(looking_for, 0) == 0;
42+
}
3543

3644
constexpr v16::ConfigurationStatus convert(SetResult res) {
3745
switch (res) {
@@ -1144,32 +1152,40 @@ ChargePointConfigurationDeviceModel::ChargePointConfigurationDeviceModel(
11441152
const auto measurands = calculateSupportedMeasurands();
11451153
ProfilesSet initial;
11461154

1147-
// TODO(james-ctc): check how to determine this for v2
1148-
// get from the device model e.g. perhaps:
1149-
// CustomizationCtrlr, ISO15118Ctrlr, TariffCostCtrlr
1155+
bool PnC_found{false};
1156+
bool CostAndPrice_found{false};
1157+
bool Custom_found{false};
11501158

1151-
#if 0
1152-
// If supported add to initial set
1159+
// check the device model to identify other supported feature profiles
1160+
const auto report = storage->get_base_report_data(v2::ReportBaseEnum::ConfigurationInventory);
1161+
for (const auto& entry : report) {
1162+
const std::string component = entry.component.name;
1163+
const std::string variable = entry.variable.name;
1164+
EVLOG_debug << "Component: " << component << " Variable: " << variable;
1165+
if (component == custom_component && variable == "CustomImplementationEnabled") {
1166+
Custom_found = true;
1167+
} else if (component == pnc_component && variable == "PnCEnabled") {
1168+
PnC_found = true;
1169+
} else if (component == cost_and_price_component &&
1170+
(variable == "CustomDisplayCostAndPrice" || starts_with(variable, "DefaultPrice"))) {
1171+
CostAndPrice_found = true;
1172+
}
1173+
}
11531174

1154-
if (config.contains("PnC")) {
1175+
if (PnC_found) {
11551176
// add PnC behind the scenes as supported feature profile
1156-
initial.insert(conversions::string_to_supported_feature_profiles("PnC"));
1177+
initial.insert(conversions::string_to_supported_feature_profiles(pnc_feature));
11571178
}
11581179

1159-
if (config.contains("CostAndPrice")) {
1180+
if (CostAndPrice_found) {
11601181
// Add California Pricing Requirements behind the scenes as supported feature profile
1161-
initial.insert(conversions::string_to_supported_feature_profiles("CostAndPrice"));
1182+
initial.insert(conversions::string_to_supported_feature_profiles(cost_and_price_feature));
11621183
}
11631184

1164-
if (config.contains(custom_component)) {
1185+
if (Custom_found) {
11651186
// add Custom behind the scenes as supported feature profile
1166-
initial.insert(conversions::string_to_supported_feature_profiles(custom_component));
1187+
initial.insert(conversions::string_to_supported_feature_profiles(custom_feature));
11671188
}
1168-
#else
1169-
// TODO(james-ctc): remove these - just added for unit tests
1170-
initial.insert(SupportedFeatureProfiles::PnC);
1171-
initial.insert(SupportedFeatureProfiles::CostAndPrice);
1172-
#endif
11731189

11741190
initialise(initial, profiles, measurands);
11751191
}

0 commit comments

Comments
 (0)