Skip to content

Commit

Permalink
Fix build and warnings from buildserver
Browse files Browse the repository at this point in the history
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
  • Loading branch information
maaikez committed Jun 28, 2024
1 parent 7403144 commit d9b5b0e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 25 deletions.
4 changes: 2 additions & 2 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
/// \return Map containing the SetVariableData as a key and the SetVariableResult as a value for each requested
/// change
std::map<SetVariableData, SetVariableResult>
set_variables_internal(const std::vector<SetVariableData>& set_variable_data_vector, const std::string &source,
set_variables_internal(const std::vector<SetVariableData>& set_variable_data_vector, const std::string& source,
const bool allow_read_only);

MeterValue get_latest_meter_value_filtered(const MeterValue& meter_value, ReadingContextEnum context,
Expand Down Expand Up @@ -877,7 +877,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
std::vector<GetVariableResult> get_variables(const std::vector<GetVariableData>& get_variable_data_vector) override;

std::map<SetVariableData, SetVariableResult>
set_variables(const std::vector<SetVariableData>& set_variable_data_vector, const std::string &source) override;
set_variables(const std::vector<SetVariableData>& set_variable_data_vector, const std::string& source) override;

/// \brief Requests a value of a VariableAttribute specified by combination of \p component_id and \p variable_id
/// from the device model
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/device_model_storage_sqlite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DeviceModelStorageSqlite : public DeviceModelStorage {

bool set_variable_attribute_value(const Component& component_id, const Variable& variable_id,
const AttributeEnum& attribute_enum, const std::string& value,
const std::string &source) final;
const std::string& source) final;

std::optional<VariableMonitoringMeta> set_monitoring_data(const SetMonitoringData& data,
const VariableMonitorType type) final;
Expand Down
4 changes: 2 additions & 2 deletions include/ocpp/v201/init_device_model_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon {
/// \return True on success.
///
bool insert_component(const ComponentKey& component_key,
const std::vector<DeviceModelVariable> component_variables);
const std::vector<DeviceModelVariable>& component_variables);

///
/// \brief Read component schemas from given files.
Expand Down Expand Up @@ -238,7 +238,7 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon {
/// \param db_variable The variable currently in the database (that needs updating).
/// \param component_id The component id the variable belongs to.
///
void update_variable(const DeviceModelVariable& variable, const DeviceModelVariable db_variable,
void update_variable(const DeviceModelVariable& variable, const DeviceModelVariable& db_variable,
const uint64_t component_id);

///
Expand Down
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if(LIBOCPP_ENABLE_V201)
ocpp/v201/device_model_storage_sqlite.cpp
ocpp/v201/enums.cpp
ocpp/v201/evse.cpp
ocpp/v201/init_device_model_db.cpp
ocpp/v201/notify_report_requests_splitter.cpp
ocpp/v201/message_queue.cpp
ocpp/v201/ocpp_types.cpp
Expand Down
17 changes: 9 additions & 8 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <ocpp/v201/charge_point.hpp>
#include <ocpp/v201/ctrlr_component_variables.hpp>
#include <ocpp/v201/device_model_storage_sqlite.hpp>
#include <ocpp/v201/init_device_model_db.hpp>
#include <ocpp/v201/messages/FirmwareStatusNotification.hpp>
#include <ocpp/v201/messages/LogStatusNotification.hpp>
#include <ocpp/v201/notify_report_requests_splitter.hpp>
Expand Down Expand Up @@ -3211,10 +3212,10 @@ void ChargePoint::handle_set_monitoring_base_req(Call<SetMonitoringBaseRequest>
SetMonitoringBaseResponse response;
const auto& msg = call.msg;

auto result = this->device_model->set_value(ControllerComponentVariables::ActiveMonitoringBase.component,
ControllerComponentVariables::ActiveMonitoringBase.variable.value(),
AttributeEnum::Actual,
conversions::monitoring_base_enum_to_string(msg.monitoringBase), true);
auto result = this->device_model->set_value(
ControllerComponentVariables::ActiveMonitoringBase.component,
ControllerComponentVariables::ActiveMonitoringBase.variable.value(), AttributeEnum::Actual,
conversions::monitoring_base_enum_to_string(msg.monitoringBase), VARIABLE_ATTRIBUTE_VALUE_SOURCE_CSMS, true);

if (result != SetVariableStatusEnum::Accepted) {
EVLOG_warning << "Could not persist in device model new monitoring base: "
Expand Down Expand Up @@ -3245,10 +3246,10 @@ void ChargePoint::handle_set_monitoring_level_req(Call<SetMonitoringLevelRequest
if (msg.severity < MontoringLevelSeverity::MIN || msg.severity > MontoringLevelSeverity::MAX) {
response.status = GenericStatusEnum::Rejected;
} else {
auto result =
this->device_model->set_value(ControllerComponentVariables::ActiveMonitoringLevel.component,
ControllerComponentVariables::ActiveMonitoringLevel.variable.value(),
AttributeEnum::Actual, std::to_string(msg.severity), true);
auto result = this->device_model->set_value(
ControllerComponentVariables::ActiveMonitoringLevel.component,
ControllerComponentVariables::ActiveMonitoringLevel.variable.value(), AttributeEnum::Actual,
std::to_string(msg.severity), VARIABLE_ATTRIBUTE_VALUE_SOURCE_CSMS, true);

if (result != SetVariableStatusEnum::Accepted) {
EVLOG_warning << "Could not persist in device model new monitoring level: " << msg.severity;
Expand Down
6 changes: 3 additions & 3 deletions lib/ocpp/v201/init_device_model_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool InitDeviceModelDb::insert_components(const std::map<ComponentKey, std::vect
}

bool InitDeviceModelDb::insert_component(const ComponentKey& component_key,
const std::vector<DeviceModelVariable> component_variables) {
const std::vector<DeviceModelVariable>& component_variables) {
EVLOG_debug << "Inserting component " << component_key.name;

static const std::string statement = "INSERT OR REPLACE INTO COMPONENT (NAME, INSTANCE, EVSE_ID, CONNECTOR_ID) "
Expand Down Expand Up @@ -434,7 +434,7 @@ void InitDeviceModelDb::insert_variable(const DeviceModelVariable& variable, con
insert_attributes(variable.attributes, variable_id);
}

void InitDeviceModelDb::update_variable(const DeviceModelVariable& variable, const DeviceModelVariable db_variable,
void InitDeviceModelDb::update_variable(const DeviceModelVariable& variable, const DeviceModelVariable& db_variable,
const uint64_t component_id) {
if (!db_variable.db_id.has_value()) {
EVLOG_error << "Can not update variable " << variable.name << ": database id unknown";
Expand Down Expand Up @@ -1231,9 +1231,9 @@ static std::string get_string_value_from_json(const json& value) {
}
return "false";
} else if (value.is_array() || value.is_object()) {
return "";
EVLOG_warning << "String value " << value.dump()
<< " from config is an object or array, but config values should be from a primitive type.";
return "";
} else {
return value.dump();
}
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/ocpp/v16/database_stub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ struct SQLiteStatementTest : public ocpp::common::SQLiteStatementInterface {
virtual int bind_null(const std::string& param) {
return 0;
}
virtual int get_number_of_rows() override {
return 0;
}
virtual int column_type(const int idx) {
return SQLITE_INTEGER;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/ocpp/v201/test_init_device_model_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ TEST_F(InitDeviceModelDbTest, init_db) {
"VARIABLE_MONITORING"},
false));

InitDeviceModelDb db = InitDeviceModelDb(DATABASE_PATH, MIGRATION_FILES_PATH);
InitDeviceModelDb db(DATABASE_PATH, MIGRATION_FILES_PATH);

// Database should not exist yet. But since it does a filesystem check and we have an in memory database, we
// explicitly set the variable here.
db.database_exists = false;
EXPECT_TRUE(db.initialize_database(SCHEMAS_PATH, true));
EXPECT_TRUE(db.initialize_database(std::filesystem::path(SCHEMAS_PATH), true));

// Tables should have been created now.
EXPECT_TRUE(check_all_tables_exist({"COMPONENT", "VARIABLE", "DATATYPE", "MONITOR", "MUTABILITY", "SEVERITY",
Expand Down
14 changes: 7 additions & 7 deletions tests/lib/ocpp/v201/test_smart_charging_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ class ChargepointTestFixtureV201 : public testing::Test {
// Defaults
const auto& charging_rate_unit_cv = ControllerComponentVariables::ChargingScheduleChargingRateUnit;
device_model->set_value(charging_rate_unit_cv.component, charging_rate_unit_cv.variable.value(),
AttributeEnum::Actual, "A,W", true);
AttributeEnum::Actual, "A,W", "test", true);

const auto& ac_phase_switching_cv = ControllerComponentVariables::ACPhaseSwitchingSupported;
device_model->set_value(ac_phase_switching_cv.component, ac_phase_switching_cv.variable.value(),
AttributeEnum::Actual, ac_phase_switching_supported.value_or(""), true);
AttributeEnum::Actual, ac_phase_switching_supported.value_or(""), "test", true);

return device_model;
}
Expand Down Expand Up @@ -344,7 +344,7 @@ TEST_F(ChargepointTestFixtureV201,
K01FR26_IfChargingRateUnitIsNotInChargingScheduleChargingRateUnits_ThenProfileIsInvalid) {
const auto& charging_rate_unit_cv = ControllerComponentVariables::ChargingScheduleChargingRateUnit;
device_model->set_value(charging_rate_unit_cv.component, charging_rate_unit_cv.variable.value(),
AttributeEnum::Actual, "W", true);
AttributeEnum::Actual, "W", "test", true);

auto periods = create_charging_schedule_periods(0, 1, 1);
auto profile = create_charging_profile(
Expand Down Expand Up @@ -664,7 +664,7 @@ TEST_F(ChargepointTestFixtureV201, K01FR44_IfPhaseToUseProvidedForDCEVSE_ThenPro
TEST_F(ChargepointTestFixtureV201, K01FR44_IfNumberPhasesProvidedForDCChargingStation_ThenProfileIsInvalid) {
device_model->set_value(ControllerComponentVariables::ChargingStationSupplyPhases.component,
ControllerComponentVariables::ChargingStationSupplyPhases.variable.value(),
AttributeEnum::Actual, std::to_string(0), true);
AttributeEnum::Actual, std::to_string(0), "test", true);

auto periods = create_charging_schedule_periods(0, 1);
auto profile = create_charging_profile(
Expand All @@ -679,7 +679,7 @@ TEST_F(ChargepointTestFixtureV201, K01FR44_IfNumberPhasesProvidedForDCChargingSt
TEST_F(ChargepointTestFixtureV201, K01FR44_IfPhaseToUseProvidedForDCChargingStation_ThenProfileIsInvalid) {
device_model->set_value(ControllerComponentVariables::ChargingStationSupplyPhases.component,
ControllerComponentVariables::ChargingStationSupplyPhases.variable.value(),
AttributeEnum::Actual, std::to_string(0), true);
AttributeEnum::Actual, std::to_string(0), "test", true);

auto periods = create_charging_schedule_periods(0, 1, 1);
auto profile = create_charging_profile(
Expand Down Expand Up @@ -709,7 +709,7 @@ TEST_F(ChargepointTestFixtureV201,
K01FR45_IfNumberPhasesGreaterThanMaxNumberPhasesForACChargingStation_ThenProfileIsInvalid) {
device_model->set_value(ControllerComponentVariables::ChargingStationSupplyPhases.component,
ControllerComponentVariables::ChargingStationSupplyPhases.variable.value(),
AttributeEnum::Actual, std::to_string(1), true);
AttributeEnum::Actual, std::to_string(1), "test", true);

auto periods = create_charging_schedule_periods(0, 4);
auto profile = create_charging_profile(
Expand Down Expand Up @@ -741,7 +741,7 @@ TEST_F(ChargepointTestFixtureV201, K01FR49_IfNumberPhasesMissingForACEVSE_ThenSe
TEST_F(ChargepointTestFixtureV201, K01FR49_IfNumberPhasesMissingForACChargingStation_ThenSetNumberPhasesToThree) {
device_model->set_value(ControllerComponentVariables::ChargingStationSupplyPhases.component,
ControllerComponentVariables::ChargingStationSupplyPhases.variable.value(),
AttributeEnum::Actual, std::to_string(3), true);
AttributeEnum::Actual, std::to_string(3), "test", true);

auto periods = create_charging_schedule_periods(0);
auto profile = create_charging_profile(
Expand Down

0 comments on commit d9b5b0e

Please sign in to comment.