Skip to content

Commit c0c4e42

Browse files
committed
Review comments.
Signed-off-by: Maaike Zijderveld, iolar <git.mail@iolar.nl>
1 parent 1212a82 commit c0c4e42

File tree

6 files changed

+32
-34
lines changed

6 files changed

+32
-34
lines changed

include/ocpp/v201/ctrlr_component_variables.hpp

+27
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,33 @@
88

99
namespace ocpp {
1010
namespace v201 {
11+
///
12+
/// \brief Required ComponentVariable.
13+
///
14+
struct RequiredComponentVariable : ComponentVariable {
15+
/// \brief Constructor
16+
RequiredComponentVariable() : required_for({OcppProtocolVersion::v201, OcppProtocolVersion::v21}) {};
17+
18+
///
19+
/// \brief RequiredComponentVariable
20+
/// \param component Component
21+
/// \param variable Variable
22+
/// \param custom_data Custom data (default nullopt)
23+
/// \param required_for Required for which version. Multiple versions can be given.
24+
///
25+
RequiredComponentVariable(const Component component, const std::optional<Variable> variable,
26+
const std::optional<CustomData> custom_data = std::nullopt,
27+
const std::set<OcppProtocolVersion> required_for = {OcppProtocolVersion::v201,
28+
OcppProtocolVersion::v21}) :
29+
ComponentVariable(), required_for(required_for) {
30+
this->component = component;
31+
this->variable = variable;
32+
this->customData = custom_data;
33+
};
34+
35+
/// \brief For which ocpp protocol version(s) this component variable is required.
36+
std::set<OcppProtocolVersion> required_for;
37+
};
1138

1239
///
1340
/// \brief Required variables per component.

include/ocpp/v201/device_model.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <everest/logging.hpp>
1010

11+
#include <ocpp/v201/ctrlr_component_variables.hpp>
1112
#include <ocpp/v201/device_model_storage_interface.hpp>
1213

1314
namespace ocpp {

include/ocpp/v201/ocpp_types.hpp

-28
Original file line numberDiff line numberDiff line change
@@ -2239,34 +2239,6 @@ void from_json(const json& j, Firmware& k);
22392239
/// \brief Writes the string representation of the given Firmware \p k to the given output stream \p os
22402240
/// \returns an output stream with the Firmware written to
22412241
std::ostream& operator<<(std::ostream& os, const Firmware& k);
2242-
2243-
///
2244-
/// \brief Required ComponentVariable.
2245-
///
2246-
struct RequiredComponentVariable : ComponentVariable {
2247-
/// \brief Constructor
2248-
RequiredComponentVariable() : required_for({OcppProtocolVersion::v201, OcppProtocolVersion::v21}) {};
2249-
2250-
///
2251-
/// \brief RequiredComponentVariable
2252-
/// \param component Component
2253-
/// \param variable Variable
2254-
/// \param custom_data Custom data (default nullopt)
2255-
/// \param required_for Required for which version. Multiple versions can be given.
2256-
///
2257-
RequiredComponentVariable(const Component component, const std::optional<Variable> variable,
2258-
const std::optional<CustomData> custom_data = std::nullopt,
2259-
const std::set<OcppProtocolVersion> required_for = {OcppProtocolVersion::v201,
2260-
OcppProtocolVersion::v21}) :
2261-
ComponentVariable(), required_for(required_for) {
2262-
this->component = component;
2263-
this->variable = variable;
2264-
this->customData = custom_data;
2265-
};
2266-
2267-
/// \brief For which ocpp protocol version(s) this component variable is required.
2268-
std::set<OcppProtocolVersion> required_for;
2269-
};
22702242
} // namespace v201
22712243
} // namespace ocpp
22722244

lib/ocpp/v201/device_model_storage_sqlite.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ int32_t DeviceModelStorageSqlite::clear_custom_variable_monitors() {
456456
}
457457

458458
void DeviceModelStorageSqlite::check_integrity() {
459+
// Function is now empty because checks are already done elsewhere (for example the check for 'required' variables).
459460
}
460461

461462
} // namespace v201

src/code_generator/common/templates/ocpp_types.hpp.jinja

-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ struct {{type.name}} {
5151
{% endif %}
5252
{% endfor %}
5353
{%- endif %}
54-
{% if last %}
55-
{% if namespace == "v201" %}
56-
struct RequiredComponentVariable : ComponentVariable {};
57-
{% endif %}
5854
} // namespace {{namespace}}
5955
} // namespace ocpp
6056

tests/lib/ocpp/v201/test_device_model.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class DeviceModelTest : public ::testing::Test {
2323
}
2424
};
2525

26-
TEST_F(DeviceModelTest, test_allow_zero2) {
26+
/// \brief Test if value can be changed. And test if setting a value of 0 is allowed for a value that is allowed to be 0.
27+
TEST_F(DeviceModelTest, test_set_value_and_allow_zero) {
2728
// default value is 900
2829
auto r = dm->get_value<int>(cv, ocpp::v201::AttributeEnum::Actual);
2930
ASSERT_EQ(r, 900);
@@ -42,7 +43,7 @@ TEST_F(DeviceModelTest, test_allow_zero2) {
4243

4344
/// \brief Test if value of 0 is allowed for ControllerComponentVariables::AlignedDataInterval although the minLimit is
4445
/// set to 5
45-
TEST_F(DeviceModelTest, test_allow_zero) {
46+
TEST_F(DeviceModelTest, test_min_limit_and_allow_zero) {
4647
// Set a min limit to 'Interval' of 'AlignedDataCtrlr'.
4748
VariableCharacteristics c;
4849
c.minLimit = 10;

0 commit comments

Comments
 (0)