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,200 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "evse_board_supportImpl.hpp"
|
||||
|
||||
namespace module {
|
||||
namespace board_support {
|
||||
|
||||
static types::board_support_common::BspEvent cast_event_type(CpState cp_state) {
|
||||
types::board_support_common::BspEvent event;
|
||||
switch (cp_state) {
|
||||
case CpState_STATE_A:
|
||||
event.event = types::board_support_common::Event::A;
|
||||
break;
|
||||
case CpState_STATE_B:
|
||||
event.event = types::board_support_common::Event::B;
|
||||
break;
|
||||
case CpState_STATE_C:
|
||||
event.event = types::board_support_common::Event::C;
|
||||
break;
|
||||
case CpState_STATE_D:
|
||||
event.event = types::board_support_common::Event::D;
|
||||
break;
|
||||
case CpState_STATE_E:
|
||||
event.event = types::board_support_common::Event::E;
|
||||
break;
|
||||
case CpState_STATE_F:
|
||||
event.event = types::board_support_common::Event::F;
|
||||
break;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
static types::board_support_common::BspEvent cast_event_type(bool relais_state) {
|
||||
types::board_support_common::BspEvent event;
|
||||
if (relais_state) {
|
||||
event.event = types::board_support_common::Event::PowerOn;
|
||||
} else {
|
||||
event.event = types::board_support_common::Event::PowerOff;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
static types::board_support_common::ProximityPilot cast_pp_type(PpState pp_state) {
|
||||
types::board_support_common::ProximityPilot pp;
|
||||
switch (pp_state) {
|
||||
case PpState_STATE_13A:
|
||||
pp.ampacity = types::board_support_common::Ampacity::A_13;
|
||||
break;
|
||||
case PpState_STATE_20A:
|
||||
pp.ampacity = types::board_support_common::Ampacity::A_20;
|
||||
break;
|
||||
case PpState_STATE_32A:
|
||||
pp.ampacity = types::board_support_common::Ampacity::A_32;
|
||||
break;
|
||||
case PpState_STATE_70A:
|
||||
pp.ampacity = types::board_support_common::Ampacity::A_63_3ph_70_1ph;
|
||||
break;
|
||||
case PpState_STATE_FAULT:
|
||||
pp.ampacity = types::board_support_common::Ampacity::None;
|
||||
break;
|
||||
case PpState_STATE_NC:
|
||||
pp.ampacity = types::board_support_common::Ampacity::None;
|
||||
break;
|
||||
}
|
||||
return pp;
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::init() {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(capsMutex);
|
||||
|
||||
caps.min_current_A_import = 6;
|
||||
caps.max_current_A_import = 16;
|
||||
caps.min_phase_count_import = 1;
|
||||
caps.max_phase_count_import = 3;
|
||||
caps.supports_changing_phases_during_charging = false;
|
||||
caps.supports_cp_state_E = false;
|
||||
caps.connector_type = types::evse_board_support::Connector_type::IEC62196Type2Cable;
|
||||
|
||||
caps.min_current_A_export = 6;
|
||||
caps.max_current_A_export = 16;
|
||||
caps.min_phase_count_export = 1;
|
||||
caps.max_phase_count_export = 3;
|
||||
}
|
||||
|
||||
mod->serial.signalCPState.connect([this](CpState cp_state) {
|
||||
if (cp_state not_eq last_cp_state) {
|
||||
auto event_cp_state = cast_event_type(cp_state);
|
||||
EVLOG_info << "CP state changed: "
|
||||
<< types::board_support_common::event_to_string(cast_event_type(last_cp_state).event) << " -> "
|
||||
<< types::board_support_common::event_to_string(event_cp_state.event);
|
||||
if (enabled) {
|
||||
publish_event(event_cp_state);
|
||||
}
|
||||
|
||||
if (cp_state == CpState_STATE_A) {
|
||||
mod->clear_errors_on_unplug();
|
||||
}
|
||||
last_cp_state = cp_state;
|
||||
}
|
||||
});
|
||||
mod->serial.signalRelaisState.connect([this](bool relais_state) {
|
||||
if (last_relais_state not_eq relais_state) {
|
||||
publish_event(cast_event_type(relais_state));
|
||||
last_relais_state = relais_state;
|
||||
}
|
||||
});
|
||||
|
||||
mod->serial.signalPPState.connect([this](PpState pp_state) {
|
||||
last_pp = cast_pp_type(pp_state);
|
||||
publish_ac_pp_ampacity(last_pp);
|
||||
});
|
||||
|
||||
mod->serial.signalKeepAliveLo.connect([this](KeepAliveLo l) {
|
||||
std::lock_guard<std::mutex> lock(capsMutex);
|
||||
|
||||
caps.min_current_A_import =
|
||||
(mod->config.caps_min_current_A >= 0 ? mod->config.caps_min_current_A : l.hwcap_min_current);
|
||||
caps.max_current_A_import =
|
||||
(mod->config.caps_max_current_A >= 0 ? mod->config.caps_max_current_A : l.hwcap_max_current);
|
||||
caps.min_phase_count_import = l.hwcap_min_phase_count;
|
||||
caps.max_phase_count_import = l.hwcap_max_phase_count;
|
||||
|
||||
caps.min_current_A_export =
|
||||
(mod->config.caps_min_current_A >= 0 ? mod->config.caps_min_current_A : l.hwcap_min_current);
|
||||
caps.max_current_A_export =
|
||||
(mod->config.caps_max_current_A >= 0 ? mod->config.caps_max_current_A : l.hwcap_max_current);
|
||||
caps.min_phase_count_export = l.hwcap_min_phase_count;
|
||||
caps.max_phase_count_export = l.hwcap_max_phase_count;
|
||||
|
||||
caps.supports_changing_phases_during_charging = l.supports_changing_phases_during_charging;
|
||||
if (not caps_received) {
|
||||
EVLOG_info << "Yeti Controller Configuration:";
|
||||
EVLOG_info << " Hardware revision: " << l.hw_revision;
|
||||
EVLOG_info << " Firmware version: " << l.sw_version_string;
|
||||
EVLOG_info << " Current Limit: " << l.hwcap_max_current;
|
||||
}
|
||||
caps_received = true;
|
||||
});
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::ready() {
|
||||
wait_for_caps();
|
||||
{
|
||||
// Publish caps once in the beginning
|
||||
std::lock_guard<std::mutex> lock(capsMutex);
|
||||
publish_capabilities(caps);
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::wait_for_caps() {
|
||||
// Wait for caps to be received at least once
|
||||
int i;
|
||||
for (i = 0; i < 50; i++) {
|
||||
if (caps_received)
|
||||
break;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
if (i == 50) {
|
||||
EVLOG_error << "Did not receive hardware capabilities from Yeti hardware, using defaults.";
|
||||
}
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_pwm_on(double& value) {
|
||||
mod->serial.setPWM(value * 100);
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_cp_state_X1() {
|
||||
mod->serial.setPWM(10001);
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_cp_state_F() {
|
||||
mod->serial.setPWM(0);
|
||||
}
|
||||
|
||||
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) {
|
||||
mod->serial.allowPowerOn(value.allow_power_on);
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_ac_set_overcurrent_limit_A(double& value) {
|
||||
// your code for cmd ac_set_overcurrent_limit_A goes here
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_ac_switch_three_phases_while_charging(bool& value) {
|
||||
mod->serial.set_number_of_phases(value);
|
||||
}
|
||||
|
||||
void evse_board_supportImpl::handle_enable(bool& value) {
|
||||
enabled = true;
|
||||
// Publish CP state once on enable
|
||||
publish_event(cast_event_type(last_cp_state));
|
||||
}
|
||||
|
||||
} // namespace board_support
|
||||
} // namespace module
|
||||
@@ -0,0 +1,76 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#ifndef BOARD_SUPPORT_EVSE_BOARD_SUPPORT_IMPL_HPP
|
||||
#define BOARD_SUPPORT_EVSE_BOARD_SUPPORT_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/evse_board_support/Implementation.hpp>
|
||||
|
||||
#include "../YetiDriver.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace board_support {
|
||||
|
||||
struct Conf {};
|
||||
|
||||
class evse_board_supportImpl : public evse_board_supportImplBase {
|
||||
public:
|
||||
evse_board_supportImpl() = delete;
|
||||
evse_board_supportImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<YetiDriver>& mod, Conf& config) :
|
||||
evse_board_supportImplBase(ev, "board_support"), 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<YetiDriver>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
// insert your private definitions here
|
||||
types::evse_board_support::HardwareCapabilities caps;
|
||||
std::atomic_bool caps_received{false};
|
||||
std::mutex capsMutex;
|
||||
CpState last_cp_state{CpState::CpState_STATE_F};
|
||||
bool last_relais_state{false};
|
||||
types::board_support_common::ProximityPilot last_pp{types::board_support_common::Ampacity::None};
|
||||
void wait_for_caps();
|
||||
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 board_support
|
||||
} // namespace module
|
||||
|
||||
#endif // BOARD_SUPPORT_EVSE_BOARD_SUPPORT_IMPL_HPP
|
||||
Reference in New Issue
Block a user