Skip to content

Commit

Permalink
Merge branch 'main' into feature/enable_disable_source
Browse files Browse the repository at this point in the history
  • Loading branch information
james-ctc authored May 15, 2024
2 parents 5c74944 + e8ec2c4 commit a364314
Show file tree
Hide file tree
Showing 41 changed files with 2,845 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ev_add_module(OCPPExtensionExample)
ev_add_module(DummyTokenValidator)
ev_add_module(DummyTokenProvider)
ev_add_module(DummyTokenProviderManual)
ev_add_module(PhyVersoBSP)

add_subdirectory(examples)
add_subdirectory(simulation)
Expand Down
6 changes: 4 additions & 2 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void EvseManager::init() {
}

// Use SLAC MAC address for Autocharge if configured.
if (config.autocharge_use_slac_instead_of_hlc and slac_enabled) {
if (config.autocharge_use_slac_instead_of_hlc and slac_enabled and config.enable_autocharge) {
r_slac[0]->subscribe_ev_mac_address([this](const std::string& token) {
p_token_provider->publish_provided_token(create_autocharge_token(token, config.connector_id));
});
Expand Down Expand Up @@ -474,7 +474,9 @@ void EvseManager::ready() {
r_hlc[0]->call_authorization_response(types::authorization::AuthorizationStatus::Accepted,
types::authorization::CertificateStatus::NoCertificateAvailable);
} else {
p_token_provider->publish_provided_token(autocharge_token);
if (config.enable_autocharge) {
p_token_provider->publish_provided_token(autocharge_token);
}
Everest::scoped_lock_timeout lock(hlc_mutex, Everest::MutexDescription::EVSE_publish_provided_token);
hlc_waiting_for_auth_eim = true;
hlc_waiting_for_auth_pnc = false;
Expand Down
2 changes: 1 addition & 1 deletion modules/EvseManager/EvseManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct Conf {
bool hack_pause_imd_during_precharge;
bool hack_allow_bpt_with_iso2;
bool autocharge_use_slac_instead_of_hlc;
bool enable_autocharge;
std::string logfile_suffix;
double soft_over_current_tolerance_percent;
double soft_over_current_measurement_noise_A;
Expand Down Expand Up @@ -204,7 +205,6 @@ class EvseManager : public Everest::ModuleBase {
powersupply_capabilities.max_import_current_A = caps.max_import_current_A;
powersupply_capabilities.max_import_power_W = caps.max_import_power_W;
}

// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1

protected:
Expand Down
5 changes: 5 additions & 0 deletions modules/EvseManager/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ config:
description: Use slac ev mac address for autocharge instead of EVCCID from HLC
type: boolean
default: false
enable_autocharge:
description: >-
Enables Autocharge (i.e. Mac address for authorization). Disabled by default as PnC should be used instead.
type: boolean
default: false
logfile_suffix:
description: Use the string given for the log folder name. Special string session_uuid will be replaced with session uuid.
type: string
Expand Down
55 changes: 55 additions & 0 deletions modules/PhyVersoBSP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# AUTO GENERATED - MARKED REGIONS WILL BE KEPT
# template version 3
#

# module setup:
# - ${MODULE_NAME}: module name
ev_setup_cpp_module()

# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1
# insert your custom targets and additional config variables here
add_subdirectory(phyverso_mcu_comms)
add_subdirectory(phyverso_cli)
add_subdirectory(phyverso_config)

target_include_directories(${MODULE_NAME}
PRIVATE
"common"
"phyverso_mcu_comms"
"phyverso_mcu_comms/nanopb"
"phyverso_mcu_comms/protobuf"
"phyverso_config"
)

target_link_libraries(${MODULE_NAME}
PRIVATE
Pal::Sigslot
phyverso_mcu_comms
phyverso_config
)
# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1

target_sources(${MODULE_NAME}
PRIVATE
"connector_1/evse_board_supportImpl.cpp"
"connector_2/evse_board_supportImpl.cpp"
"rcd_1/ac_rcdImpl.cpp"
"rcd_2/ac_rcdImpl.cpp"
"connector_lock_1/connector_lockImpl.cpp"
"connector_lock_2/connector_lockImpl.cpp"
)

# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
target_sources(${MODULE_NAME}
PRIVATE
"board_support_common.cpp"
)

# install MCU configs
install(
DIRECTORY "."
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/everest"
FILES_MATCHING PATTERN "*.json"
)
# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
52 changes: 52 additions & 0 deletions modules/PhyVersoBSP/PhyVersoBSP.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include "PhyVersoBSP.hpp"
#include <filesystem>

namespace module {

void PhyVersoBSP::init() {
// initialize serial driver
if (!serial.open_device(config.serial_port.c_str(), config.baud_rate)) {
EVLOG_AND_THROW(EVEXCEPTION(Everest::EverestConfigError, "Could not open serial port ", config.serial_port,
" with baud rate ", config.baud_rate));
return;
}

invoke_init(*p_connector_1);
invoke_init(*p_connector_2);
invoke_init(*p_rcd_1);
invoke_init(*p_rcd_2);
invoke_init(*p_connector_lock_1);
invoke_init(*p_connector_lock_2);

std::filesystem::path mcu_config_file = config.mcu_config_file;

if (mcu_config_file.is_relative()) {
// Add everest config folder prefix if relative path is given
mcu_config_file = info.paths.etc / mcu_config_file;
}

if (!verso_config.open_file(mcu_config_file.string())) {
EVLOG_AND_THROW(EVEXCEPTION(Everest::EverestConfigError, "Could not open config file ", mcu_config_file));
}

serial.signal_config_request.connect([&]() {
serial.send_config(verso_config);
EVLOG_info << "Sent config packet to MCU";
});
}

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

invoke_ready(*p_connector_1);
invoke_ready(*p_connector_2);
invoke_ready(*p_rcd_1);
invoke_ready(*p_rcd_2);
invoke_ready(*p_connector_lock_1);
invoke_ready(*p_connector_lock_2);
}

} // namespace module
109 changes: 109 additions & 0 deletions modules/PhyVersoBSP/PhyVersoBSP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#ifndef PHY_VERSO_BSP_HPP
#define PHY_VERSO_BSP_HPP

//
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
// template version 2
//

#include "ld-ev.hpp"

// headers for provided interface implementations
#include <generated/interfaces/ac_rcd/Implementation.hpp>
#include <generated/interfaces/connector_lock/Implementation.hpp>
#include <generated/interfaces/evse_board_support/Implementation.hpp>

// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1
// insert your custom include headers here
#include "phyverso_mcu_comms/evSerial.h"
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1

namespace module {

struct Conf {
std::string serial_port;
int baud_rate;
int reset_gpio;
std::string mcu_config_file;
int conn1_max_current_A_import;
int conn1_min_current_A_import;
int conn1_min_phase_count_import;
int conn1_max_phase_count_import;
int conn1_min_current_A_export;
int conn1_max_current_A_export;
int conn1_min_phase_count_export;
int conn1_max_phase_count_export;
bool conn1_has_socket;
bool conn1_dc;
int conn2_max_current_A_import;
int conn2_min_current_A_import;
int conn2_min_phase_count_import;
int conn2_max_phase_count_import;
int conn2_min_current_A_export;
int conn2_max_current_A_export;
int conn2_min_phase_count_export;
int conn2_max_phase_count_export;
bool conn2_has_socket;
bool conn2_dc;
};

class PhyVersoBSP : public Everest::ModuleBase {
public:
PhyVersoBSP() = delete;
PhyVersoBSP(const ModuleInfo& info, Everest::MqttProvider& mqtt_provider, Everest::TelemetryProvider& telemetry,
std::unique_ptr<evse_board_supportImplBase> p_connector_1,
std::unique_ptr<evse_board_supportImplBase> p_connector_2, std::unique_ptr<ac_rcdImplBase> p_rcd_1,
std::unique_ptr<ac_rcdImplBase> p_rcd_2, std::unique_ptr<connector_lockImplBase> p_connector_lock_1,
std::unique_ptr<connector_lockImplBase> p_connector_lock_2, Conf& config) :
ModuleBase(info),
mqtt(mqtt_provider),
telemetry(telemetry),
p_connector_1(std::move(p_connector_1)),
p_connector_2(std::move(p_connector_2)),
p_rcd_1(std::move(p_rcd_1)),
p_rcd_2(std::move(p_rcd_2)),
p_connector_lock_1(std::move(p_connector_lock_1)),
p_connector_lock_2(std::move(p_connector_lock_2)),
config(config){};

Everest::MqttProvider& mqtt;
Everest::TelemetryProvider& telemetry;
const std::unique_ptr<evse_board_supportImplBase> p_connector_1;
const std::unique_ptr<evse_board_supportImplBase> p_connector_2;
const std::unique_ptr<ac_rcdImplBase> p_rcd_1;
const std::unique_ptr<ac_rcdImplBase> p_rcd_2;
const std::unique_ptr<connector_lockImplBase> p_connector_lock_1;
const std::unique_ptr<connector_lockImplBase> p_connector_lock_2;
const Conf& config;

// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
// insert your public definitions here
evSerial serial;
// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1

protected:
// ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1
// insert your protected definitions here
// ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1

private:
friend class LdEverest;
void init();
void ready();

// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
// insert your private definitions here
evConfig verso_config;
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
};

// ev@087e516b-124c-48df-94fb-109508c7cda9:v1
// insert other definitions here
// ev@087e516b-124c-48df-94fb-109508c7cda9:v1

} // namespace module

#endif // PHY_VERSO_BSP_HPP
36 changes: 36 additions & 0 deletions modules/PhyVersoBSP/board_support_common.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include "board_support_common.hpp"

namespace module {

types::board_support_common::BspEvent to_bsp_event(CpState s) {
switch (s) {
case CpState_STATE_A:
return {types::board_support_common::Event::A};
case CpState_STATE_B:
return {types::board_support_common::Event::B};
case CpState_STATE_C:
return {types::board_support_common::Event::C};
case CpState_STATE_D:
return {types::board_support_common::Event::D};
case CpState_STATE_E:
return {types::board_support_common::Event::E};
case CpState_STATE_F:
return {types::board_support_common::Event::F};
// This should never happen
default:
return {types::board_support_common::Event::F};
}
}

types::board_support_common::BspEvent to_bsp_event(CoilState s) {
// TODO: implement coil type handling
if (s.coil_state) {
return {types::board_support_common::Event::PowerOn};
} else {
return {types::board_support_common::Event::PowerOff};
}
}
} // namespace module
15 changes: 15 additions & 0 deletions modules/PhyVersoBSP/board_support_common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#ifndef EVSE_BOARD_SUPPORT_COMMON_HPP
#define EVSE_BOARD_SUPPORT_COMMON_HPP

#include "phyverso.pb.h"
#include <generated/interfaces/evse_board_support/Implementation.hpp>

namespace module {
types::board_support_common::BspEvent to_bsp_event(CpState s);
types::board_support_common::BspEvent to_bsp_event(CoilState s);
} // namespace module

#endif // EVSE_BOARD_SUPPORT_COMMON_HPP
Loading

0 comments on commit a364314

Please sign in to comment.