Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/ocpp201-immediate-reset-stop-transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
hikinggrass authored Jun 25, 2024
2 parents 2dc53c4 + 65b8e2c commit efc3de1
Show file tree
Hide file tree
Showing 44 changed files with 368 additions and 795 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/bazel_build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ jobs:
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'third-party/bazel/*') }}
key: ${{ runner.os }}-bazel-${{ hashFiles('dependencies.yaml', '.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'third-party/bazel/*') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Setup edm
run: |
pip install git+https://github.com/Everest/everest-dev-environment.git#subdirectory=dependency_manager
- name: Build all
run: >
bazelisk build //...
- name: Test all
run: bazelisk test //...
run: bazelisk test //... --test_output=errors
25 changes: 0 additions & 25 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,3 @@ filegroup(
)

exports_files(["dependencies.yaml"])

_GENERATED = {
"third-party/bazel/deps_versions.bzl": "//third-party/bazel:deps_versions.bzl.new",
}

write_file(
name = "gen_update",
out = "update.sh",
content = [
"#!/bin/sh",
"set -xe",
"cd $BUILD_WORKSPACE_DIRECTORY",
] + [
"cp -fv bazel-bin/{1} {0} && chmod u+w {0}".format(
k, v[2:].replace(":", "/")
)
for k, v in _GENERATED.items()
]
)

sh_binary(
name = "update",
srcs = [":gen_update"],
data = _GENERATED.values(),
)
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ else()
find_package(everest-framework REQUIRED)
find_package(everest-modbus REQUIRED)
find_package(everest-ocpp REQUIRED)
find_package(libcbv2g REQUIRED)
find_package(cbv2g REQUIRED)

find_package(PalSigslot REQUIRED)

Expand Down
13 changes: 0 additions & 13 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,7 @@ load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencie

crate_universe_dependencies()

load("@rules_rust//crate_universe:defs.bzl", "crates_repository")

crates_repository(
name = "dep_tool_crate_index",
cargo_lockfile = "//third-party/bazel/dep_tool:Cargo.lock",
isolated = False,
manifests = [
"//third-party/bazel/dep_tool:Cargo.toml",
],
)

load("@dep_tool_crate_index//:defs.bzl", dep_tool_crate_repositories = "crate_repositories")

dep_tool_crate_repositories()


load("//third-party/bazel:repos.bzl", "everest_core_repos")
Expand Down
26 changes: 14 additions & 12 deletions cmake/ev-cli.cmake
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
macro(setup_ev_cli)
add_custom_target(ev-cli)
if(NOT TARGET ev-cli)
add_custom_target(ev-cli)
endif()
if(${EV_CLI})
message(FATAL_ERROR "EV_CLI is already defined.")
return()
endif()
if(NOT ${${PROJECT_NAME}_USE_PYTHON_VENV})
find_program(EV_CLI ev-cli REQUIRED)
return()
endif()
ev_is_python_venv_active(
RESULT_VAR IS_PYTHON_VENV_ACTIVE
)
if(NOT ${IS_PYTHON_VENV_ACTIVE})
message(FATAL_ERROR "Python venv is not active. Please activate the python venv before running this command.")
else()
ev_is_python_venv_active(
RESULT_VAR IS_PYTHON_VENV_ACTIVE
)
if(NOT ${IS_PYTHON_VENV_ACTIVE})
message(FATAL_ERROR "Python venv is not active. Please activate the python venv before running this command.")
endif()
set(EV_CLI "${${PROJECT_NAME}_PYTHON_VENV_PATH}/bin/ev-cli")
add_dependencies(ev-cli
ev-dev-tools_pip_install_dist
)
endif()
set(EV_CLI "${${PROJECT_NAME}_PYTHON_VENV_PATH}/bin/ev-cli")
add_dependencies(ev-cli
ev-dev-tools_pip_install_dist
)
endmacro()

function(require_ev_cli_version EV_CLI_VERSION_REQUIRED)
Expand Down
5 changes: 2 additions & 3 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ ext-mbedtls:
- ENABLE_PROGRAMS OFF
- ENABLE_TESTING OFF
- MBEDTLS_FATAL_WARNINGS OFF # disables setting warnings as errors FIXME: workaround until upstream-fixes are included
# everest-testing
# everest-testing and ev-dev-tools
everest-utils:
git: https://github.com/EVerest/everest-utils.git
git_tag: v0.3.0
cmake_condition: "EVEREST_CORE_BUILD_TESTING"
git_tag: v0.3.1

# unit testing
gtest:
Expand Down
4 changes: 4 additions & 0 deletions interfaces/evse_board_support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,9 @@ vars:
need to be implemented and the returned value is not used in those cases.
type: object
$ref: /board_support_common#/ProximityPilot
request_stop_transaction:
description: Publish to stop the transaction gracefully (e.g. user pressed the stop button)
type: object
$ref: /evse_manager#/StopTransactionRequest
errors:
- reference: /errors/evse_board_support
8 changes: 8 additions & 0 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,18 @@ void EvseManager::init() {
[this](const auto& caps) { update_powersupply_capabilities(caps); });
}
}

r_bsp->subscribe_request_stop_transaction(
[this](types::evse_manager::StopTransactionRequest r) { charger->cancel_transaction(r); });
}

void EvseManager::ready() {
bsp = std::unique_ptr<IECStateMachine>(new IECStateMachine(r_bsp));

if (config.hack_simplified_mode_limit_10A) {
bsp->set_ev_simplified_mode_evse_limit(true);
}

error_handling =
std::unique_ptr<ErrorHandling>(new ErrorHandling(r_bsp, r_hlc, r_connector_lock, r_ac_rcd, p_evse));

Expand Down
1 change: 1 addition & 0 deletions modules/EvseManager/EvseManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct Conf {
int hack_present_current_offset;
bool hack_pause_imd_during_precharge;
bool hack_allow_bpt_with_iso2;
bool hack_simplified_mode_limit_10A;
bool autocharge_use_slac_instead_of_hlc;
bool enable_autocharge;
std::string logfile_suffix;
Expand Down
6 changes: 6 additions & 0 deletions modules/EvseManager/IECStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ void IECStateMachine::set_pwm(double value) {
}
}

if (ev_simplified_mode_evse_limit and ev_simplified_mode and value > ev_simplified_mode_evse_limit_pwm) {
EVLOG_warning
<< "Simplified mode: Limiting output PWM to 10A due to config option \"hack_simplified_mode_limit_10A\"";
value = ev_simplified_mode_evse_limit_pwm;
}

r_bsp->call_pwm_on(value * 100);

feed_state_machine();
Expand Down
7 changes: 7 additions & 0 deletions modules/EvseManager/IECStateMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class IECStateMachine {

void connector_force_unlock();

void set_ev_simplified_mode_evse_limit(bool l) {
ev_simplified_mode_evse_limit = l;
}

// Signal for internal events type
sigslot::signal<CPEvent> signal_event;
sigslot::signal<> signal_lock;
Expand All @@ -103,6 +107,9 @@ class IECStateMachine {
bool pwm_running{false};
bool last_pwm_running{false};

static constexpr float ev_simplified_mode_evse_limit_pwm{10 / 0.6 / 100.}; // Fixed 10A limit
// If set to true, EVSE will limit to 10A in case of simplified charging
bool ev_simplified_mode_evse_limit{false};
bool ev_simplified_mode{false};
bool has_ventilation{false};
bool power_on_allowed{false};
Expand Down
7 changes: 7 additions & 0 deletions modules/EvseManager/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ config:
always be positive but power supply may actually discharge the car.
type: boolean
default: false
hack_simplified_mode_limit_10A:
description: >-
Limit PWM to 10A if EV uses simplified charging mode. Set to false to be compliant with IEC61851-1:2019 section A.2.3.
It is the responsibility of the EV to limit to 10A according to the norm. Enable this option to deviate from the norm
and limit from the EVSE side.
type: boolean
default: false
autocharge_use_slac_instead_of_hlc:
description: Use slac ev mac address for autocharge instead of EVCCID from HLC
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion modules/EvseManager/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_dependencies(${TEST_TARGET_NAME} ${MODULE_NAME})
get_target_property(GENERATED_INCLUDE_DIR generate_cpp_files EVEREST_GENERATED_INCLUDE_DIR)

target_include_directories(${TEST_TARGET_NAME} PRIVATE
. ..
. .. ../../../tests/include
${GENERATED_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/generated/modules/${MODULE_NAME}
)
Expand Down
2 changes: 1 addition & 1 deletion modules/EvseManager/tests/EvseManagerStub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef EVSEMANAGERSTUB_H_
#define EVSEMANAGERSTUB_H_

#include "ModuleAdapterStub.hpp"
#include <ErrorHandling.hpp>
#include <ModuleAdapterStub.hpp>

//-----------------------------------------------------------------------------
namespace module::stub {
Expand Down
18 changes: 10 additions & 8 deletions modules/MicroMegaWattBSP/MicroMegaWattBSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,35 @@ void MicroMegaWattBSP::init() {
return;
}

invoke_init(*p_powermeter);
invoke_init(*p_board_support);
invoke_init(*p_dc_supply);
invoke_init(*p_powermeter);
}

void MicroMegaWattBSP::ready() {
serial.run();

if (!serial.reset(config.reset_gpio)) {
EVLOG_error << "uMWC reset not successful.";
if (not config.reset_gpio_chip.empty()) {
EVLOG_info << "Perform HW reset with gpio chip " << config.reset_gpio_chip << " line " << config.reset_gpio;
if (!serial.reset(config.reset_gpio_chip, config.reset_gpio)) {
EVLOG_error << "uMWC reset not successful.";
}
}

serial.signalSpuriousReset.connect([this]() { EVLOG_error << "uMWC uC spurious reset!"; });
serial.signalConnectionTimeout.connect([this]() { EVLOG_error << "uMWC UART timeout!"; });
serial.signalSpuriousReset.connect([this]() { EVLOG_warning << "uMWC uC spurious reset!"; });
serial.signalConnectionTimeout.connect([this]() { EVLOG_warning << "uMWC UART timeout!"; });

serial.signalTelemetry.connect([this](Telemetry t) {
mqtt.publish("everest_external/umwc/cp_hi", t.cp_hi);
mqtt.publish("everest_external/umwc/cp_lo", t.cp_lo);
mqtt.publish("everest_external/umwc/pwm_dc", t.pwm_dc);
mqtt.publish("everest_external/umwc/relais_on", t.relais_on);
mqtt.publish("everest_external/umwc/output_voltage", t.voltage);
});
serial.signalPowerMeter.connect(
[this](PowerMeter p) { mqtt.publish("everest_external/umwc/output_voltage", p.voltage); });

invoke_ready(*p_powermeter);
invoke_ready(*p_board_support);
invoke_ready(*p_dc_supply);
invoke_ready(*p_powermeter);

if (not serial.is_open()) {
auto err = p_board_support->error_factory->create_error("evse_board_support/CommunicationFault", "",
Expand Down
1 change: 1 addition & 0 deletions modules/MicroMegaWattBSP/MicroMegaWattBSP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace module {
struct Conf {
std::string serial_port;
int baud_rate;
std::string reset_gpio_chip;
int reset_gpio;
int dc_max_voltage;
};
Expand Down
Loading

0 comments on commit efc3de1

Please sign in to comment.