Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umwc: move external MQTT to MicroMegaWattBSP, throw MREC8 emergencyst… #953

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/EvseManager/Charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,15 @@ bool Charger::cancel_transaction(const types::evse_manager::StopTransactionReque
Everest::scoped_lock_timeout lock(state_machine_mutex, Everest::MutexDescription::Charger_cancel_transaction);

if (shared_context.transaction_active) {

if (shared_context.hlc_charging_active) {

if (request.reason == types::evse_manager::StopTransactionReason::EmergencyStop) {
signal_hlc_error(types::iso15118_charger::EvseError::Error_EmergencyShutdown);
} else if (request.reason == types::evse_manager::StopTransactionReason::PowerLoss) {
signal_hlc_error(types::iso15118_charger::EvseError::Error_UtilityInterruptEvent);
}

shared_context.current_state = EvseState::StoppingCharging;
signal_hlc_stop_charging();
} else {
Expand Down
1 change: 1 addition & 0 deletions modules/EvseManager/Charger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class Charger {
sigslot::signal<> signal_slac_start;

sigslot::signal<> signal_hlc_stop_charging;
sigslot::signal<types::iso15118_charger::EvseError> signal_hlc_error;

void process_event(CPEvent event);

Expand Down
4 changes: 4 additions & 0 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ void EvseManager::ready() {
// Ask HLC to stop charging session
charger->signal_hlc_stop_charging.connect([this] { r_hlc[0]->call_stop_charging(true); });

// Charger needs to inform ISO stack about emergency stop
charger->signal_hlc_error.connect(
[this](types::iso15118_charger::EvseError error) { r_hlc[0]->call_send_error(error); });

auto sae_mode = types::iso15118_charger::SaeJ2847BidiMode::None;

// Set up energy transfer modes for HLC. For now we only support either DC or AC, not both at the same time.
Expand Down
39 changes: 0 additions & 39 deletions modules/EvseManager/evse/evse_managerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,45 +70,6 @@ void evse_managerImpl::init() {
mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/resume_charging", mod->config.connector_id),
[&charger = mod->charger](const std::string& data) { charger->resume_charging(); });

mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/stop_transaction", mod->config.connector_id),
[this](const std::string& data) {
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::Local;
mod->charger->cancel_transaction(request);
});

mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/emergency_stop", mod->config.connector_id),
[this](const std::string& data) {
if (mod->get_hlc_enabled()) {
mod->r_hlc[0]->call_send_error(
types::iso15118_charger::EvseError::Error_EmergencyShutdown);
}
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::EmergencyStop;
mod->charger->cancel_transaction(request);
});

mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/evse_malfunction", mod->config.connector_id),
[this](const std::string& data) {
if (mod->get_hlc_enabled()) {
mod->r_hlc[0]->call_send_error(types::iso15118_charger::EvseError::Error_Malfunction);
}
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::Other;
mod->charger->cancel_transaction(request);
});

mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/evse_utility_int", mod->config.connector_id),
[this](const std::string& data) {
if (mod->get_hlc_enabled()) {
mod->r_hlc[0]->call_send_error(
types::iso15118_charger::EvseError::Error_UtilityInterruptEvent);
}
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::Other;
mod->charger->cancel_transaction(request);
});

// /Interface to Node-RED debug UI

if (mod->r_powermeter_billing().size() > 0) {
Expand Down
1 change: 1 addition & 0 deletions modules/MicroMegaWattBSP/MicroMegaWattBSP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
std::string reset_gpio_chip;
int reset_gpio;
int dc_max_voltage;
int connector_id;

Check notice on line 31 in modules/MicroMegaWattBSP/MicroMegaWattBSP.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/MicroMegaWattBSP/MicroMegaWattBSP.hpp#L31

struct member 'Conf::connector_id' is never used.
};

class MicroMegaWattBSP : public Everest::ModuleBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,46 @@ void evse_board_supportImpl::init() {
EVLOG_info << "CP state changed: " << types::board_support_common::event_to_string(event_cp_state.event);
publish_event(event_cp_state);
last_cp_state = cp_state;

if (cp_state == CpState::CpState_STATE_A) {
if (error_state_monitor->is_error_active("evse_board_support/MREC8EmergencyStop", "")) {
clear_error("evse_board_support/MREC8EmergencyStop");
}
}
}
});

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->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/emergency_stop", mod->config.connector_id),
[this](const std::string& data) {
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::EmergencyStop;
mod->p_board_support->publish_request_stop_transaction(request);
Everest::error::Error error_object = error_factory->create_error(
"evse_board_support/MREC8EmergencyStop", "", "Emergency stop button pushed by user",
Everest::error::Severity::High);
raise_error(error_object);
});

mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/evse_utility_int", mod->config.connector_id),
[this](const std::string& data) {
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::PowerLoss;
mod->p_board_support->publish_request_stop_transaction(request);
});

mod->mqtt.subscribe(fmt::format("everest_external/nodered/{}/cmd/stop_transaction", mod->config.connector_id),
[this](const std::string& data) {
types::evse_manager::StopTransactionRequest request;
request.reason = types::evse_manager::StopTransactionReason::Local;
mod->p_board_support->publish_request_stop_transaction(request);
});
}

void evse_board_supportImpl::ready() {
Expand Down
4 changes: 4 additions & 0 deletions modules/MicroMegaWattBSP/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ config:
minimum: 50
maximum: 1000
default: 1000
connector_id:
description: Connector id
type: integer
default: 1
provides:
dc_supply:
interface: power_supply_DC
Expand Down
Loading