|
23 | 23 | #include <string_view> |
24 | 24 | #include <type_traits> |
25 | 25 | #include <utility> |
26 | | -#include <vector> |
27 | 26 |
|
28 | 27 | namespace { |
29 | 28 | using namespace ocpp; |
30 | 29 | using SetResult = v16::ChargePointConfigurationDeviceModel::SetResult; |
31 | 30 | using DeviceModelInterface = v2::DeviceModelInterface; |
32 | 31 | using SupportedFeatureProfiles = v16::SupportedFeatureProfiles; |
33 | 32 |
|
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 | +} |
35 | 43 |
|
36 | 44 | constexpr v16::ConfigurationStatus convert(SetResult res) { |
37 | 45 | switch (res) { |
@@ -1144,32 +1152,40 @@ ChargePointConfigurationDeviceModel::ChargePointConfigurationDeviceModel( |
1144 | 1152 | const auto measurands = calculateSupportedMeasurands(); |
1145 | 1153 | ProfilesSet initial; |
1146 | 1154 |
|
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}; |
1150 | 1158 |
|
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 | + } |
1153 | 1174 |
|
1154 | | - if (config.contains("PnC")) { |
| 1175 | + if (PnC_found) { |
1155 | 1176 | // 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)); |
1157 | 1178 | } |
1158 | 1179 |
|
1159 | | - if (config.contains("CostAndPrice")) { |
| 1180 | + if (CostAndPrice_found) { |
1160 | 1181 | // 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)); |
1162 | 1183 | } |
1163 | 1184 |
|
1164 | | - if (config.contains(custom_component)) { |
| 1185 | + if (Custom_found) { |
1165 | 1186 | // 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)); |
1167 | 1188 | } |
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 |
1173 | 1189 |
|
1174 | 1190 | initialise(initial, profiles, measurands); |
1175 | 1191 | } |
|
0 commit comments