Skip to content

Commit

Permalink
added support for SummaryInventory in OCPP201 (#716)
Browse files Browse the repository at this point in the history
Signed-off-by: pietfried <pietgoempel@gmail.com>
  • Loading branch information
Pietfried authored Jul 26, 2024
1 parent f7b26ec commit ebe4fd5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
9 changes: 7 additions & 2 deletions include/ocpp/v201/ctrlr_component_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ extern const Component& AuthCacheCtrlr;
extern const Component& AuthCtrlr;
extern const Component& ChargingStation;
extern const Component& ClockCtrlr;
extern const Component& Connector;
extern const Component& CustomizationCtrlr;
extern const Component& DeviceDataCtrlr;
extern const Component& DisplayMessageCtrlr;
extern const Component& EVSE;
extern const Component& ISO15118Ctrlr;
extern const Component& LocalAuthListCtrlr;
extern const Component& MonitoringCtrlr;
Expand All @@ -33,6 +31,13 @@ extern const Component& TariffCostCtrlr;
extern const Component& TxCtrlr;
} // namespace ControllerComponents

namespace StandardizedVariables {
extern const Variable& Problem;
extern const Variable& Tripped;
extern const Variable& Overload;
extern const Variable& Fallback;
}; // namespace StandardizedVariables

// Provides access to standardized variables of OCPP2.0.1 spec
namespace ControllerComponentVariables {
extern const ComponentVariable& InternalCtrlrEnabled;
Expand Down
4 changes: 0 additions & 4 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2404,10 +2404,6 @@ void ChargePoint::handle_get_base_report_req(Call<GetBaseReportRequest> call) {
GetBaseReportResponse response;
response.status = GenericDeviceModelStatusEnum::Accepted;

if (msg.reportBase == ReportBaseEnum::SummaryInventory) {
response.status = GenericDeviceModelStatusEnum::NotSupported;
}

ocpp::CallResult<GetBaseReportResponse> call_result(response, call.uniqueId);
this->send<GetBaseReportResponse>(call_result);

Expand Down
7 changes: 7 additions & 0 deletions lib/ocpp/v201/ctrlr_component_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const Component& TariffCostCtrlr = {"TariffCostCtrlr"};
const Component& TxCtrlr = {"TxCtrlr"};
} // namespace ControllerComponents

namespace StandardizedVariables {
const Variable& Problem = {"Problem"};
const Variable& Tripped = {"Tripped"};
const Variable& Overload = {"Overload"};
const Variable& Fallback = {"Fallback"};
}; // namespace StandardizedVariables

namespace ControllerComponentVariables {

const ComponentVariable& InternalCtrlrEnabled = {
Expand Down
27 changes: 24 additions & 3 deletions lib/ocpp/v201/device_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ bool validate_value(const VariableCharacteristics& characteristics, const std::s
}
}

bool include_in_summary_inventory(const ComponentVariable& cv, const VariableAttribute& attribute) {
if (cv == ControllerComponentVariables::ChargingStationAvailabilityState) {
return true;
}
if (cv.component.name == "EVSE" and cv.variable == EvseComponentVariables::AvailabilityState) {
return true;
}
if (cv.component.name == "Connector" and cv.variable == ConnectorComponentVariables::AvailabilityState) {
return true;
}
if ((cv.variable == StandardizedVariables::Fallback or cv.variable == StandardizedVariables::Overload or
cv.variable == StandardizedVariables::Problem or cv.variable == StandardizedVariables::Tripped) and
attribute.value.value_or("") == "true") {
return true;
}
return false;
}

GetVariableStatusEnum DeviceModel::request_value_internal(const Component& component_id, const Variable& variable_id,
const AttributeEnum& attribute_enum, std::string& value,
bool allow_write_only) {
Expand Down Expand Up @@ -327,14 +345,13 @@ std::vector<ReportData> DeviceModel::get_base_report_data(const ReportBaseEnum&
report_data.component = component;
report_data.variable = variable;

ComponentVariable cv = {component, std::nullopt, variable};

// request the variable attribute from the device model storage
const auto variable_attributes = this->storage->get_variable_attributes(component, variable);

// iterate over possibly (Actual, Target, MinSet, MaxSet)
for (const auto& variable_attribute : variable_attributes) {
// FIXME(piet): Right now this reports only FullInventory (ReadOnly,
// ReadWrite or WriteOnly) and ConfigurationInventory (ReadWrite or WriteOnly) correctly
// TODO(piet): SummaryInventory
if (report_base == ReportBaseEnum::FullInventory or
(report_base == ReportBaseEnum::ConfigurationInventory and
(variable_attribute.mutability == MutabilityEnum::ReadWrite or
Expand All @@ -345,6 +362,10 @@ std::vector<ReportData> DeviceModel::get_base_report_data(const ReportBaseEnum&
report_data.variableAttribute.back().value.reset();
}
report_data.variableCharacteristics = variable_map.at(variable).characteristics;
} else if (report_base == ReportBaseEnum::SummaryInventory) {
if (include_in_summary_inventory(cv, variable_attribute)) {
report_data.variableAttribute.push_back(variable_attribute);
}
}
}
if (!report_data.variableAttribute.empty()) {
Expand Down

0 comments on commit ebe4fd5

Please sign in to comment.