Skip to content

Commit ebd13d4

Browse files
Pietfriedmaaikez
authored andcommitted
Extended RequiredComponentVariable with additional property to specify for which ocpp version a variable is required. This is the base to continue implementing a device model integrity check inside libocpps DeviceModel class
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
1 parent 562096d commit ebd13d4

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

include/ocpp/v201/ctrlr_component_variables.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
namespace ocpp {
1010
namespace v201 {
1111

12+
std::vector<RequiredComponentVariable> required_variables;
13+
1214
namespace ControllerComponents {
1315
extern const Component InternalCtrlr;
1416
extern const Component AlignedDataCtrlr;

include/ocpp/v201/ocpp_types.hpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef OCPP_V201_OCPP_TYPES_HPP
66
#define OCPP_V201_OCPP_TYPES_HPP
77

8+
#include <set>
89
#include <string>
910

1011
#include <nlohmann/json_fwd.hpp>
@@ -2239,7 +2240,19 @@ void from_json(const json& j, Firmware& k);
22392240
/// \returns an output stream with the Firmware written to
22402241
std::ostream& operator<<(std::ostream& os, const Firmware& k);
22412242

2242-
struct RequiredComponentVariable : ComponentVariable {};
2243+
struct RequiredComponentVariable : ComponentVariable {
2244+
RequiredComponentVariable() : required_for({OcppProtocolVersion::v201, OcppProtocolVersion::v21}) {};
2245+
RequiredComponentVariable(const Component component, const std::optional<CustomData> custom_data,
2246+
const std::optional<Variable> variable,
2247+
const std::set<OcppProtocolVersion> required_for = {OcppProtocolVersion::v201,
2248+
OcppProtocolVersion::v21}) :
2249+
ComponentVariable(), required_for(required_for) {
2250+
this->component = component;
2251+
this->variable = variable;
2252+
this->customData = custom_data;
2253+
};
2254+
std::set<OcppProtocolVersion> required_for;
2255+
};
22432256
} // namespace v201
22442257
} // namespace ocpp
22452258

lib/ocpp/v201/ctrlr_component_variables.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,12 @@ const ComponentVariable TariffCostCtrlrAvailableTariff = {
10801080
ControllerComponents::TariffCostCtrlr,
10811081
std::optional<Variable>({"Available", "Tariff"}),
10821082
};
1083+
const ComponentVariable EvseSleep = {
1084+
ControllerComponents::SmartChargingCtrlr,
1085+
std::nullopt,
1086+
std::optional<Variable>({"EvseSleep", std::nullopt}),
1087+
{OcppProtocolVersion::v21}
1088+
};
10831089
const ComponentVariable TariffCostCtrlrAvailableCost = {
10841090
ControllerComponents::TariffCostCtrlr,
10851091
std::optional<Variable>({"Available", "Cost"}),

lib/ocpp/v201/device_model.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ void DeviceModel::check_integrity(const std::map<int32_t, int32_t>& evse_connect
429429
try {
430430
this->device_model->check_integrity();
431431

432+
// TODO: add required variable check here.
433+
432434
int32_t nr_evse_components = 0;
433435
std::map<int32_t, int32_t> evse_id_nr_connector_components;
434436

0 commit comments

Comments
 (0)