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,181 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "evse_board_supportImpl.hpp"
|
||||
|
||||
namespace module {
|
||||
namespace connector_1 {
|
||||
|
||||
void evse_board_supportImpl::init() {
|
||||
{
|
||||
std::scoped_lock lock(caps_mutex);
|
||||
|
||||
caps.min_current_A_import = mod->config.conn1_min_current_A_import;
|
||||
caps.max_current_A_import = mod->config.conn1_max_current_A_import;
|
||||
caps.min_phase_count_import = mod->config.conn1_min_phase_count_import;
|
||||
caps.max_phase_count_import = mod->config.conn1_max_phase_count_import;
|
||||
caps.supports_changing_phases_during_charging = false;
|
||||
caps.supports_cp_state_E = false;
|
||||
|
||||
caps.min_current_A_export = mod->config.conn1_min_current_A_export;
|
||||
caps.max_current_A_export = mod->config.conn1_max_current_A_export;
|
||||
caps.min_phase_count_export = mod->config.conn1_min_phase_count_export;
|
||||
caps.max_phase_count_export = mod->config.conn1_max_phase_count_export;
|
||||
|
||||
if (mod->config.conn1_has_socket) {
|
||||
caps.connector_type = types::evse_board_support::Connector_type::IEC62196Type2Socket;
|
||||
} else {
|
||||
caps.connector_type = types::evse_board_support::Connector_type::IEC62196Type2Cable;
|
||||
}
|
||||
}
|
||||
|
||||
mod->serial.signal_cp_state.connect([this](int connector, CpState s) {
|
||||
if (connector == 1 && s != last_cp_state) {
|
||||
publish_event(to_bsp_event(s));
|
||||
EVLOG_info << "[1] CP State changed: " << to_bsp_event(s);
|
||||
last_cp_state = s;
|
||||
}
|
||||
});
|
||||
mod->serial.signal_set_coil_state_response.connect([this](int connector, CoilState s) {
|
||||
if (connector == 1) {
|
||||
EVLOG_info << "[1] Relais: " << (s.coil_state ? "ON" : "OFF");
|
||||
publish_event(to_bsp_event(s));
|
||||
}
|
||||
});
|
||||
|
||||
mod->serial.signal_telemetry.connect([this](int connector, Telemetry t) {
|
||||
if (connector == 1) {
|
||||
EVLOG_info << "[1] CP Voltage: " << t.cp_voltage_hi << " " << t.cp_voltage_lo;
|
||||
}
|
||||
});
|
||||
|
||||
mod->serial.signal_pp_state.connect([this](int connector, PpState s) {
|
||||
if (connector == 1) {
|
||||
if (last_pp_state != s) {
|
||||
EVLOG_info << "[1] PpState " << s;
|
||||
publish_ac_pp_ampacity(to_pp_ampacity(s));
|
||||
}
|
||||
last_pp_state = s;
|
||||
}
|
||||
});
|
||||
|
||||
mod->gpio.signal_stop_button_state.connect([this](int connector, bool state) {
|
||||
if (connector == 1 && (state != last_stop_button_state)) {
|
||||
types::evse_manager::StopTransactionRequest request;
|
||||
request.reason = types::evse_manager::StopTransactionReason::Local;
|
||||
this->publish_request_stop_transaction(request);
|
||||
EVLOG_info << "[1] Request stop button state: " << (state ? "PUSHED" : "RELEASED");
|
||||
last_stop_button_state = state;
|
||||
}
|
||||
});
|
||||
|
||||
mod->serial.signal_error_flags.connect([this](int connector, ErrorFlags error_flags) {
|
||||
if (connector == 1) {
|
||||
// Contactor feedback divergence
|
||||
if (error_flags.coil_feedback_diverges != last_error_flags.coil_feedback_diverges) {
|
||||
if (error_flags.coil_feedback_diverges) {
|
||||
Everest::error::Error error_object = this->error_factory->create_error(
|
||||
"evse_board_support/MREC17EVSEContactorFault", "",
|
||||
"Port 1 contactor feedback diverges from target state", Everest::error::Severity::High);
|
||||
this->raise_error(error_object);
|
||||
} else {
|
||||
this->clear_error("evse_board_support/MREC17EVSEContactorFault");
|
||||
}
|
||||
}
|
||||
|
||||
// Diode fault
|
||||
if (error_flags.diode_fault != last_error_flags.diode_fault) {
|
||||
if (error_flags.diode_fault) {
|
||||
Everest::error::Error error_object = this->error_factory->create_error(
|
||||
"evse_board_support/DiodeFault", "", "Port 1 diode fault", Everest::error::Severity::High);
|
||||
this->raise_error(error_object);
|
||||
} else {
|
||||
this->clear_error("evse_board_support/DiodeFault");
|
||||
}
|
||||
}
|
||||
|
||||
// PP fault
|
||||
if (error_flags.pp_signal_fault != last_error_flags.pp_signal_fault) {
|
||||
if (error_flags.pp_signal_fault) {
|
||||
Everest::error::Error error_object =
|
||||
this->error_factory->create_error("evse_board_support/MREC23ProximityFault", "",
|
||||
"Port 1 PP signal fault", Everest::error::Severity::High);
|
||||
this->raise_error(error_object);
|
||||
} else {
|
||||
this->clear_error("evse_board_support/MREC23ProximityFault");
|
||||
}
|
||||
}
|
||||
|
||||
last_error_flags = error_flags;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::ready() {
|
||||
{
|
||||
std::scoped_lock lock(caps_mutex);
|
||||
publish_capabilities(caps);
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_enable(bool& value) {
|
||||
enabled = value;
|
||||
if (enabled) {
|
||||
mod->serial.set_pwm(1, last_pwm_raw);
|
||||
} else {
|
||||
mod->serial.set_pwm(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_pwm_on(double& value) {
|
||||
if (value >= 0 && value <= 100.) {
|
||||
last_pwm_raw = value * 100;
|
||||
if (enabled) {
|
||||
mod->serial.set_pwm(1, last_pwm_raw);
|
||||
}
|
||||
} else {
|
||||
EVLOG_warning << "Invalid pwm value " << value;
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_cp_state_X1() {
|
||||
last_pwm_raw = 10000;
|
||||
if (enabled) {
|
||||
mod->serial.set_pwm(1, last_pwm_raw);
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_cp_state_F() {
|
||||
last_pwm_raw = 0;
|
||||
if (enabled) {
|
||||
mod->serial.set_pwm(1, last_pwm_raw);
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_cp_state_E() {
|
||||
EVLOG_warning << "Command cp_state_E is not supported. Ignoring command.";
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_allow_power_on(types::evse_board_support::PowerOnOff& value) {
|
||||
if (mod->config.conn1_disable_port) {
|
||||
EVLOG_error << "[1] Port disabled; Cannot set power_on!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (mod->config.conn1_dc) {
|
||||
mod->serial.set_coil_state_request(1, CoilType_COIL_DC1, value.allow_power_on);
|
||||
} else {
|
||||
mod->serial.set_coil_state_request(1, CoilType_COIL_AC, value.allow_power_on);
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_ac_switch_three_phases_while_charging(bool& value) {
|
||||
// your code for cmd ac_switch_three_phases_while_charging goes here
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_ac_set_overcurrent_limit_A(double& value) {
|
||||
// your code for cmd ac_set_overcurrent_limit_A goes here
|
||||
}
|
||||
|
||||
} // namespace connector_1
|
||||
} // namespace module
|
||||
@@ -0,0 +1,78 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#ifndef CONNECTOR_1_EVSE_BOARD_SUPPORT_IMPL_HPP
|
||||
#define CONNECTOR_1_EVSE_BOARD_SUPPORT_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/evse_board_support/Implementation.hpp>
|
||||
|
||||
#include "../PhyVersoBSP.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
#include "board_support_common.hpp"
|
||||
#include "evGpio.h"
|
||||
#include <atomic>
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace connector_1 {
|
||||
|
||||
struct Conf {};
|
||||
|
||||
class evse_board_supportImpl : public evse_board_supportImplBase {
|
||||
public:
|
||||
evse_board_supportImpl() = delete;
|
||||
evse_board_supportImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<PhyVersoBSP>& mod, Conf& config) :
|
||||
evse_board_supportImplBase(ev, "connector_1"), mod(mod), config(config){};
|
||||
|
||||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
|
||||
// insert your public definitions here
|
||||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
|
||||
|
||||
protected:
|
||||
// command handler functions (virtual)
|
||||
virtual void handle_enable(bool& value) override;
|
||||
virtual void handle_pwm_on(double& value) override;
|
||||
virtual void handle_cp_state_X1() override;
|
||||
virtual void handle_cp_state_F() override;
|
||||
virtual void handle_cp_state_E() override;
|
||||
virtual void handle_allow_power_on(types::evse_board_support::PowerOnOff& value) override;
|
||||
virtual void handle_ac_switch_three_phases_while_charging(bool& value) override;
|
||||
virtual void handle_ac_set_overcurrent_limit_A(double& value) override;
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<PhyVersoBSP>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
types::evse_board_support::HardwareCapabilities caps;
|
||||
std::mutex caps_mutex;
|
||||
CpState last_cp_state;
|
||||
PpState last_pp_state; ///< The last pp state received from the MCU.
|
||||
bool last_stop_button_state;
|
||||
ErrorFlags last_error_flags;
|
||||
int last_pwm_raw{10000};
|
||||
std::atomic_bool enabled{false};
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
};
|
||||
|
||||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
|
||||
// insert other definitions here
|
||||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
|
||||
|
||||
} // namespace connector_1
|
||||
} // namespace module
|
||||
|
||||
#endif // CONNECTOR_1_EVSE_BOARD_SUPPORT_IMPL_HPP
|
||||
Reference in New Issue
Block a user