Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions interfaces/ev_slac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ vars:
state:
description: Provides the state enum.
type: string
enum:
- UNMATCHED
- MATCHING
- MATCHED
$ref: /slac#/State
dlink_ready:
description: >-
Inform higher layers about a change in data link status. Emits true
Expand Down
5 changes: 1 addition & 4 deletions interfaces/slac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ vars:
state:
description: Provides the state enum.
type: string
enum:
- UNMATCHED
- MATCHING
- MATCHED
$ref: /slac#/State
dlink_ready:
description: >-
Inform higher layers about a change in data link status. Emits true
Expand Down
1 change: 1 addition & 0 deletions lib/everest/everest_api_types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ target_sources(everest_api_types

src/everest_api_types/slac/codec.cpp
src/everest_api_types/slac/json_codec.cpp
src/everest_api_types/slac/wrapper.cpp

src/everest_api_types/system/codec.cpp
src/everest_api_types/system/json_codec.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest

#include <everest_api_types/slac/API.hpp>

Check warning on line 4 in lib/everest/everest_api_types/private_include/everest_api_types/slac/wrapper.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/everest/everest_api_types/private_include/everest_api_types/slac/wrapper.hpp#L4

Include file: <everest_api_types/slac/API.hpp> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-function"
#include "generated/types/slac.hpp"
#pragma GCC diagnostic pop

namespace everest::lib::API::V1_0::types::slac {

using SlacState_Internal = ::types::slac::State;
using SlacState_External = State;

SlacState_Internal to_internal_api(SlacState_External const& val);
SlacState_External to_external_api(SlacState_Internal const& val);

} // namespace everest::lib::API::V1_0::types::slac
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest

#include "slac/wrapper.hpp"
#include "slac/codec.hpp"
#include <stdexcept>

Check warning on line 6 in lib/everest/everest_api_types/src/everest_api_types/slac/wrapper.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/everest/everest_api_types/src/everest_api_types/slac/wrapper.cpp#L6

Include file: <stdexcept> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <string>

Check warning on line 7 in lib/everest/everest_api_types/src/everest_api_types/slac/wrapper.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/everest/everest_api_types/src/everest_api_types/slac/wrapper.cpp#L7

Include file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace everest::lib::API::V1_0::types::slac {

SlacState_Internal to_internal_api(SlacState_External const& val) {
using SrcT = SlacState_External;
using TarT = SlacState_Internal;
switch (val) {
case SrcT::UNMATCHED:
return TarT::UNMATCHED;
case SrcT::MATCHING:
return TarT::MATCHING;
case SrcT::MATCHED:
return TarT::MATCHED;
}
throw std::out_of_range("Unexpected value for everest::lib::API::V1_0::types::slac::SlacState_External");
}

SlacState_External to_external_api(SlacState_Internal const& val) {
using SrcT = SlacState_Internal;
using TarT = SlacState_External;
switch (val) {
case SrcT::UNMATCHED:
return TarT::UNMATCHED;
case SrcT::MATCHING:
return TarT::MATCHING;
case SrcT::MATCHED:
return TarT::MATCHED;
}
throw std::out_of_range("Unexpected value for everest::lib::API::V1_0::types::slac::SlacState_Internal");
}

} // namespace everest::lib::API::V1_0::types::slac
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ interfaces/over_voltage_monitor.yaml,e900756a2058fca6c24434ac153c34afdf109ad582c
interfaces/power_supply_DC.yaml,7cc64002367143c4898589610739acd80063962e97a1456f66897b0856f916b3
interfaces/powermeter.yaml,e976a19789e0e9dee51a4682821399b8e5e546e0f8770571044e8757bd5f6eb9
interfaces/session_cost.yaml,4afd6dd67938dbc50e3d92751b27313cdcc083fb016998236d32f329df0ac806
interfaces/slac.yaml,ab465ca66e2f4a4be70128228126f8a17338e9f127afaad87c638ddd1df8db44
interfaces/slac.yaml,973bb6d035e7ada95a0a589e0c1453000d37f637cecac53af5c12afe73be05e7
interfaces/system.yaml,4a5eb3f88d7934c3b7d0945aed369e4a6d95028a2c97d4e3090a0f73c1e0dcaf
interfaces/uk_random_delay.yaml,1c2f75ba15d4d5f9a2b1eb4d48ef98a0ba1747deaf9341c8ca610f6fda7c99c1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ types/money.yaml,4a7001c50216fcf96caac4fe16db17e23ce5149d000be1de4ac1f0135f5bdb0
types/ocpp.yaml,2181f239b0366de85189dbe6cc210ad6b3ab7b6bdeb9ea8aad20fe4410b93bd7
types/power_supply_DC.yaml,eaf73bbd55ca202d8a7723f3f80e3b194a9a698e02aa280e17c87ed4ab3fc772
types/powermeter.yaml,37cae475b16778b7eca641fcee4ecc6c71391d0072ff5c16e11a8a7d7ea9e632
types/slac.yaml,67cef1d0e02e189b64b3e4afb6e5d8e0a152143a19266aefbc313c3f723da330
types/session_cost.yaml,3abb02f95f2e99488f51eefa82a82aaf77d16269bd3cf58d7234ab21d494c3b9
types/system.yaml,75240df8ffe248055e7cab6b5df97dc8d9b8805e557f95b65a200e385218c665
types/temperature.yaml,4c0af04b3cece98f1309779c69dd61f3895c5cc7e0274a1c4d681155141d2cc4
Expand Down
3 changes: 2 additions & 1 deletion modules/API/slac_API/slac_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <everest_api_types/generic/string.hpp>
#include <everest_api_types/slac/API.hpp>
#include <everest_api_types/slac/codec.hpp>
#include <everest_api_types/slac/wrapper.hpp>

Check warning on line 9 in modules/API/slac_API/slac_API.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/API/slac_API/slac_API.cpp#L9

Include file: <everest_api_types/slac/wrapper.hpp> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <everest_api_types/utilities/codec.hpp>

namespace module {
Expand Down Expand Up @@ -60,7 +61,7 @@
subscribe_api_topic("state", [=](const std::string& data) {
API_types_ext::State val;
if (deserialize(data, val)) {
p_main->publish_state(serialize(val));
p_main->publish_state(to_internal_api(val));
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions modules/BringUp/BUSlac/BUSlac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ void BUSlac::init() {
void BUSlac::ready() {
auto screen = ScreenInteractive::Fullscreen();

r_slac->subscribe_state([this, &screen](const std::string& new_state) {
r_slac->subscribe_state([this, &screen](const types::slac::State new_state) {
{
std::scoped_lock lock(data_mutex);
state = new_state;
state = types::slac::state_to_string(new_state);
}
screen.PostEvent(Event::Custom);
});
Expand Down
8 changes: 4 additions & 4 deletions modules/EV/EvManager/main/car_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void CarSimulation::state_machine() {
r_ev_board_support->call_allow_power_on(false);
// Wait for physical plugin (ev BSP sees state A on CP and not Disconnected)

sim_data.slac_state = "UNMATCHED";
sim_data.slac_state = types::slac::State::UNMATCHED;
if (!r_ev.empty()) {
r_ev[0]->call_stop_charging();
}
Expand Down Expand Up @@ -245,16 +245,16 @@ bool CarSimulation::rcd_current(const CmdArguments& arguments) {
bool CarSimulation::iso_wait_slac_matched(const CmdArguments& arguments) {
sim_data.state = SimState::PLUGGED_IN;

if (sim_data.slac_state == "UNMATCHED") {
if (sim_data.slac_state == types::slac::State::UNMATCHED) {
EVLOG_debug << "Slac UNMATCHED";
if (!r_slac.empty()) {
EVLOG_debug << "Slac trigger matching";
r_slac[0]->call_reset();
r_slac[0]->call_trigger_matching();
sim_data.slac_state = "TRIGGERED";
sim_data.slac_state = types::slac::State::MATCHING;
}
}
if (sim_data.slac_state == "MATCHED") {
if (sim_data.slac_state == types::slac::State::MATCHED) {
EVLOG_debug << "Slac Matched";
return true;
}
Expand Down
10 changes: 9 additions & 1 deletion modules/EV/EvManager/main/car_simulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ class CarSimulation {
}

void set_slac_state(std::string slac_state) {
sim_data.slac_state = std::move(slac_state);
try {
sim_data.slac_state = types::slac::string_to_state(slac_state);
} catch (const std::exception& e) {
EVLOG_error << fmt::format("Tried to set unknown SLAC state '{}'. Error: {}", slac_state, e.what());
}
}

void set_slac_state(types::slac::State slac_state) {
sim_data.slac_state = slac_state;
}

void set_iso_pwr_ready(bool iso_pwr_ready) {
Expand Down
3 changes: 2 additions & 1 deletion modules/EV/EvManager/main/car_simulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ void car_simulatorImpl::subscribe_to_variables_on_init() {
// subscribe slac_state
if (!mod->r_slac.empty()) {
const auto& slac = mod->r_slac.at(0);
slac->subscribe_state([this](const auto& state) { car_simulation->set_slac_state(state); });
slac->subscribe_state(
[this](const auto& state) { car_simulation->set_slac_state(types::slac::state_to_string(state)); });
}

// subscribe ev events
Expand Down
3 changes: 2 additions & 1 deletion modules/EV/EvManager/main/simulation_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "command_registry.hpp"
#include "simulation_command.hpp"
#include <generated/types/board_support_common.hpp>
#include <generated/types/slac.hpp>

Check warning on line 9 in modules/EV/EvManager/main/simulation_data.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EV/EvManager/main/simulation_data.hpp#L9

Include file: <generated/types/slac.hpp> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <optional>
#include <queue>
#include <string>
Expand Down Expand Up @@ -36,7 +37,7 @@

SimState state{SimState::UNPLUGGED};
SimState last_state{SimState::UNDEFINED};
std::string slac_state{"UNMATCHED"};
types::slac::State slac_state{types::slac::State::UNMATCHED};
std::optional<size_t> sleep_ticks_left{};

bool v2g_finished{false};
Expand Down
7 changes: 6 additions & 1 deletion modules/EV/EvSlac/main/ev_slacImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ void ev_slacImpl::run() {
} else if (value == "UNMATCHED") {
publish_dlink_ready(false);
}
publish_state(value);
try {
publish_state(types::slac::string_to_state(value));
} catch (const std::exception& e) {
EVLOG_error << fmt::format("Tried to publish unknown SLAC state '{}'. Error: {}", value, e.what());
publish_dlink_ready(false);
}
};

callbacks.log_debug = [](const std::string& text) { EVLOG_debug << "EvSlac: " << text; };
Expand Down
6 changes: 3 additions & 3 deletions modules/EVSE/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,10 +1266,10 @@ void EvseManager::ready() {
}

if (slac_enabled) {
r_slac[0]->subscribe_state([this](const std::string& s) {
session_log.evse(true, fmt::format("SLAC {}", s));
r_slac[0]->subscribe_state([this](const types::slac::State s) {
session_log.evse(true, fmt::format("SLAC {}", types::slac::state_to_string(s)));
// Notify charger whether matching was started (or is done) or not
if (s == "UNMATCHED") {
if (s == types::slac::State::UNMATCHED) {
charger->set_matching_started(false);
slac_unmatched = true;
} else {
Expand Down
8 changes: 7 additions & 1 deletion modules/EVSE/EvseSlac/main/slacImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ void slacImpl::run() {

callbacks.signal_dlink_ready = [this](bool value) { publish_dlink_ready(value); };

callbacks.signal_state = [this](const std::string& value) { publish_state(value); };
callbacks.signal_state = [this](const std::string& value) {
try {
publish_state(types::slac::string_to_state(value));
} catch (const std::exception& e) {
EVLOG_error << fmt::format("Tried to publish unknown SLAC state '{}'. Error: {}", value, e.what());
}
};

callbacks.signal_error_routine_request = [this]() { publish_request_error_routine(nullptr); };

Expand Down
5 changes: 1 addition & 4 deletions modules/Simulation/SlacSimulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ target_sources(${MODULE_NAME}

# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
# insert other things like install cmds etc here
target_sources(${MODULE_NAME}
PRIVATE
"util/state.cpp"
)

# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
2 changes: 1 addition & 1 deletion modules/Simulation/SlacSimulator/SlacSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace module {

using util::State;
using State = types::slac::State;

void SlacSimulator::init() {
invoke_init(*p_evse);
Expand Down
2 changes: 1 addition & 1 deletion modules/Simulation/SlacSimulator/SlacSimulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1
// insert your custom include headers here
#include "util/state.hpp"

// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1

namespace module {
Expand Down
10 changes: 5 additions & 5 deletions modules/Simulation/SlacSimulator/ev/ev_slacImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
namespace module {
namespace ev {

using util::State;
using types::slac::State;

void ev_slacImpl::init() {
}

void ev_slacImpl::ready() {
publish_state(state_to_string(state));
publish_state(state);
}

void ev_slacImpl::handle_reset() {
if (state != State::UNMATCHED) {
state = State::UNMATCHED;
publish_state(state_to_string(state));
publish_state(state);
publish_dlink_ready(false);
}
}

bool ev_slacImpl::handle_trigger_matching() {
state = State::MATCHING;
mod->cntmatching = 0;
publish_state(state_to_string(state));
publish_state(state);
return true;
}

Expand All @@ -36,7 +36,7 @@ State ev_slacImpl::get_state() const {

void ev_slacImpl::set_state_matched() {
state = State::MATCHED;
publish_state(state_to_string(state));
publish_state(state);
publish_dlink_ready(true);
}

Expand Down
6 changes: 3 additions & 3 deletions modules/Simulation/SlacSimulator/ev/ev_slacImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
// insert your custom include headers here
#include "../util/state.hpp"

// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1

namespace module {
Expand All @@ -30,7 +30,7 @@ class ev_slacImpl : public ev_slacImplBase {

// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
// insert your public definitions here
util::State get_state() const;
types::slac::State get_state() const;
void set_state_matched();
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1

Expand All @@ -52,7 +52,7 @@ class ev_slacImpl : public ev_slacImplBase {

// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
// insert your private definitions here
util::State state{util::State::UNMATCHED};
types::slac::State state{types::slac::State::UNMATCHED};
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
};

Expand Down
10 changes: 5 additions & 5 deletions modules/Simulation/SlacSimulator/evse/slacImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
namespace module {
namespace evse {

using util::State;
using types::slac::State;

void slacImpl::init() {
}

void slacImpl::ready() {
publish_state(state_to_string(state));
publish_state(state);
}

void slacImpl::handle_reset(bool& enable) {
Expand Down Expand Up @@ -42,15 +42,15 @@ void slacImpl::handle_dlink_pause() {
void slacImpl::set_state_to_unmatched() {
if (state != State::UNMATCHED) {
state = State::UNMATCHED;
publish_state(state_to_string(state));
publish_state(state);
publish_dlink_ready(false);
}
}

void slacImpl::set_state_to_matching() {
state = State::MATCHING;
mod->cntmatching = 0;
publish_state(state_to_string(state));
publish_state(state);
}

State slacImpl::get_state() const {
Expand All @@ -59,7 +59,7 @@ State slacImpl::get_state() const {

void slacImpl::set_state_matched() {
state = State::MATCHED;
publish_state(state_to_string(state));
publish_state(state);
publish_dlink_ready(true);
};
} // namespace evse
Expand Down
Loading
Loading