Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter
- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
add_subdirectory(session)
|
||||
add_subdirectory(fsm)
|
||||
@@ -0,0 +1,21 @@
|
||||
include(Catch)
|
||||
|
||||
add_executable(test_fsm_state_b state_b.cpp)
|
||||
|
||||
target_sources(test_fsm_state_b
|
||||
PRIVATE
|
||||
helper.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(test_fsm_state_b
|
||||
PRIVATE
|
||||
ieee2030::ieee2030
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
|
||||
target_compile_options(test_fsm_state_b
|
||||
PRIVATE
|
||||
"-Wno-error=maybe-uninitialized"
|
||||
)
|
||||
|
||||
catch_discover_tests(test_fsm_state_b)
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#include "helper.hpp"
|
||||
|
||||
v20::Context& FsmStateHelper::get_context() {
|
||||
return ctx;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
#include <everest/util/fsm/fsm.hpp>
|
||||
#include <ieee2030/charger/session/callback.hpp>
|
||||
#include <ieee2030/charger/v20/context.hpp>
|
||||
#include <ieee2030/charger/v20/control_event.hpp>
|
||||
#include <ieee2030/charger/v20/states.hpp>
|
||||
#include <ieee2030/common/io/logging.hpp>
|
||||
#include <ieee2030/common/messages/messages.hpp>
|
||||
|
||||
using namespace ieee2030::charger;
|
||||
|
||||
class FsmStateHelper {
|
||||
public:
|
||||
FsmStateHelper(const callback::Callbacks& callbacks) :
|
||||
ctx(active_event, callbacks, message_100, message_101, message_102) {
|
||||
|
||||
ieee2030::io::set_logging_callback([](std::string message) { std::cout << message; });
|
||||
}
|
||||
|
||||
v20::Context& get_context();
|
||||
|
||||
void handle_can_message(const ieee2030::messages::EV100& message_100_,
|
||||
const ieee2030::messages::EV101& message_101_,
|
||||
const ieee2030::messages::EV102& message_102_) {
|
||||
|
||||
this->message_100 = message_100_;
|
||||
this->message_101 = message_101_;
|
||||
this->message_102 = message_102_;
|
||||
}
|
||||
|
||||
void handle_event(const events::Event& event) {
|
||||
active_event = event;
|
||||
}
|
||||
|
||||
private:
|
||||
std::optional<events::Event> active_event;
|
||||
|
||||
v20::Context ctx;
|
||||
|
||||
ieee2030::messages::EV100 message_100;
|
||||
ieee2030::messages::EV101 message_101;
|
||||
ieee2030::messages::EV102 message_102;
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "helper.hpp"
|
||||
|
||||
#include <ieee2030/charger/v20/state/state_b.hpp>
|
||||
#include <ieee2030/charger/v20/state/state_c.hpp>
|
||||
|
||||
using namespace ieee2030;
|
||||
|
||||
callback::Callbacks callbacks;
|
||||
|
||||
callback::HwSignal hw_signal;
|
||||
|
||||
SCENARIO("StateB state transitions") {
|
||||
|
||||
callbacks.signal = []([[maybe_unused]] callback::Signal signal_) {};
|
||||
callbacks.hw_signal = [](callback::HwSignal hw_signal_) { hw_signal = hw_signal_; };
|
||||
|
||||
hw_signal = callback::HwSignal();
|
||||
auto state_helper = FsmStateHelper(callbacks);
|
||||
auto ctx = state_helper.get_context();
|
||||
|
||||
GIVEN("Handle Timeout") {
|
||||
fsm::v2::FSM<charger::v20::StateBase> fsm{ctx.create_state<charger::v20::state::StateB>()};
|
||||
const auto result = fsm.feed(v20::Event::TIMEOUT);
|
||||
|
||||
THEN("Check state transititon") {
|
||||
REQUIRE(result.transitioned() == false);
|
||||
REQUIRE(fsm.get_current_state_id() == v20::StateID::StateB);
|
||||
|
||||
REQUIRE(hw_signal.signal == callback::ChargerSequence::CS1);
|
||||
REQUIRE(hw_signal.status == callback::Status::OFF);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Handle stop event") {
|
||||
fsm::v2::FSM<charger::v20::StateBase> fsm{ctx.create_state<charger::v20::state::StateB>()};
|
||||
state_helper.handle_event(events::StopCharging{true});
|
||||
const auto result = fsm.feed(v20::Event::EVENT);
|
||||
|
||||
THEN("Check state transititon") {
|
||||
REQUIRE(result.transitioned() == false);
|
||||
REQUIRE(fsm.get_current_state_id() == v20::StateID::StateB);
|
||||
|
||||
REQUIRE(hw_signal.signal == callback::ChargerSequence::CS1);
|
||||
REQUIRE(hw_signal.status == callback::Status::OFF);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Handle stop event - false alarm") {
|
||||
fsm::v2::FSM<charger::v20::StateBase> fsm{ctx.create_state<charger::v20::state::StateB>()};
|
||||
state_helper.handle_event(events::StopCharging{false});
|
||||
const auto result = fsm.feed(v20::Event::EVENT);
|
||||
|
||||
THEN("Check state transititon") {
|
||||
REQUIRE(result.transitioned() == false);
|
||||
REQUIRE(fsm.get_current_state_id() == v20::StateID::StateB);
|
||||
|
||||
REQUIRE(hw_signal.signal == callback::ChargerSequence::CS1);
|
||||
REQUIRE(hw_signal.status == callback::Status::ON);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Handle first can message") {
|
||||
const auto message_100 = ieee2030::messages::EV100();
|
||||
const auto message_101 = ieee2030::messages::EV101();
|
||||
const auto message_102 = ieee2030::messages::EV102();
|
||||
fsm::v2::FSM<charger::v20::StateBase> fsm{ctx.create_state<charger::v20::state::StateB>()};
|
||||
state_helper.handle_can_message(message_100, message_101, message_102);
|
||||
const auto result = fsm.feed(v20::Event::CAN_MESSAGE);
|
||||
|
||||
THEN("Check state transititon") {
|
||||
REQUIRE(result.transitioned() == true);
|
||||
REQUIRE(fsm.get_current_state_id() == v20::StateID::StateC);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Handle random HW Signal") {
|
||||
fsm::v2::FSM<charger::v20::StateBase> fsm{ctx.create_state<charger::v20::state::StateB>()};
|
||||
state_helper.handle_event(events::ChargePermission{true});
|
||||
const auto result = fsm.feed(v20::Event::EVENT);
|
||||
|
||||
THEN("Check state transititon") {
|
||||
REQUIRE(result.transitioned() == false);
|
||||
REQUIRE(fsm.get_current_state_id() == v20::StateID::StateB);
|
||||
|
||||
REQUIRE(hw_signal.signal == callback::ChargerSequence::CS1);
|
||||
REQUIRE(hw_signal.status == callback::Status::ON);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Handle random event") {
|
||||
fsm::v2::FSM<charger::v20::StateBase> fsm{ctx.create_state<charger::v20::state::StateB>()};
|
||||
state_helper.handle_event(events::CableCheckFinished{true});
|
||||
const auto result = fsm.feed(v20::Event::EVENT);
|
||||
|
||||
THEN("Check state transititon") {
|
||||
REQUIRE(result.transitioned() == false);
|
||||
REQUIRE(fsm.get_current_state_id() == v20::StateID::StateB);
|
||||
|
||||
REQUIRE(hw_signal.signal == callback::ChargerSequence::CS1);
|
||||
REQUIRE(hw_signal.status == callback::Status::ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
include(Catch)
|
||||
|
||||
add_executable(test_callback test_callback.cpp)
|
||||
|
||||
target_link_libraries(test_callback
|
||||
PRIVATE
|
||||
ieee2030::ieee2030
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
|
||||
catch_discover_tests(test_callback)
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <ieee2030/charger/session/callback.hpp>
|
||||
|
||||
using namespace ieee2030::charger;
|
||||
|
||||
callback::Signal signal;
|
||||
callback::HwSignal hw_signal;
|
||||
|
||||
SCENARIO("Testing callback") {
|
||||
GIVEN("Signal") {
|
||||
|
||||
callback::Callbacks callbacks_functions;
|
||||
|
||||
callbacks_functions.signal = [](callback::Signal signal_) { signal = signal_; };
|
||||
|
||||
auto callback = Callback(callbacks_functions);
|
||||
|
||||
callback.signal(callback::Signal::CHARGE_LOOP_STARTED);
|
||||
|
||||
THEN("Signal should be CHARGE_LOOP_STARTED") {
|
||||
REQUIRE(signal == callback::Signal::CHARGE_LOOP_STARTED);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("HwSignal") {
|
||||
|
||||
callback::Callbacks callbacks_functions;
|
||||
|
||||
callbacks_functions.hw_signal = [](callback::HwSignal hw_signal_) { hw_signal = hw_signal_; };
|
||||
|
||||
auto callback = Callback(callbacks_functions);
|
||||
|
||||
callback.hw_signal({callback::ChargerSequence::CS1, callback::Status::ON});
|
||||
|
||||
THEN("Hw Signal should be enabled CS1") {
|
||||
REQUIRE(hw_signal.signal == callback::ChargerSequence::CS1);
|
||||
REQUIRE(hw_signal.status == callback::Status::ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user