Skip to content

Commit

Permalink
refactored error and fault handling in everest-core by extending erro…
Browse files Browse the repository at this point in the history
…r type and changing error enum and refactored respective modules accordingly

Signed-off-by: pietfried <pietgoempel@gmail.com>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
  • Loading branch information
Pietfried committed Jul 31, 2023
1 parent dfe28df commit a75d73a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RISE-V2G:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: v0.8.5
git_tag: v0.8.6
# Josev
Josev:
git: https://github.com/EVerest/ext-switchev-iso15118.git
Expand Down
2 changes: 1 addition & 1 deletion modules/API/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void API::init() {
&session_info](types::evse_manager::SessionEvent session_event) {
auto event = types::evse_manager::session_event_enum_to_string(session_event.event);
if (session_event.error) {
session_info->update_state(event, types::evse_manager::error_to_string(session_event.error.value()));
session_info->update_state(event, types::evse_manager::error_enum_to_string(session_event.error.value().error_code));
} else {
session_info->update_state(event, "");
}
Expand Down
22 changes: 11 additions & 11 deletions modules/EvseManager/Charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void Charger::runStateMachine() {
} else {
// unsupported charging mode, give up here.
currentState = EvseState::Error;
errorState = types::evse_manager::Error::Internal;
errorState = types::evse_manager::ErrorEnum::Internal;
}

if (hlc_use_5percent_current_session) {
Expand Down Expand Up @@ -277,7 +277,7 @@ void Charger::runStateMachine() {
// unsupported charging mode, give up here.
EVLOG_error << "Unsupported charging mode.";
currentState = EvseState::Error;
errorState = types::evse_manager::Error::Internal;
errorState = types::evse_manager::ErrorEnum::Internal;
}
} else if (AuthorizedPnC()) {

Expand Down Expand Up @@ -306,7 +306,7 @@ void Charger::runStateMachine() {
// unsupported charging mode, give up here.
EVLOG_error << "Unsupported charging mode.";
currentState = EvseState::Error;
errorState = types::evse_manager::Error::Internal;
errorState = types::evse_manager::ErrorEnum::Internal;
}
}

Expand Down Expand Up @@ -662,27 +662,27 @@ void Charger::processCPEventsIndependent(ControlPilotEvent cp_event) {
break;
case ControlPilotEvent::Error_E:
currentState = EvseState::Error;
errorState = types::evse_manager::Error::Car;
errorState = types::evse_manager::ErrorEnum::Car;
break;
case ControlPilotEvent::Error_DF:
currentState = EvseState::Error;
errorState = types::evse_manager::Error::CarDiodeFault;
errorState = types::evse_manager::ErrorEnum::CarDiodeFault;
break;
case ControlPilotEvent::Error_Relais:
currentState = EvseState::Error;
errorState = types::evse_manager::Error::Relais;
errorState = types::evse_manager::ErrorEnum::Relais;
break;
case ControlPilotEvent::Error_RCD:
currentState = EvseState::Error;
errorState = types::evse_manager::Error::RCD;
errorState = types::evse_manager::ErrorEnum::RCD;
break;
case ControlPilotEvent::Error_VentilationNotAvailable:
currentState = EvseState::Error;
errorState = types::evse_manager::Error::VentilationNotAvailable;
errorState = types::evse_manager::ErrorEnum::VentilationNotAvailable;
break;
case ControlPilotEvent::Error_OverCurrent:
currentState = EvseState::Error;
errorState = types::evse_manager::Error::OverCurrent;
errorState = types::evse_manager::ErrorEnum::OverCurrent;
break;
default:
break;
Expand Down Expand Up @@ -1049,7 +1049,7 @@ bool Charger::DeAuthorize() {
return false;
}

types::evse_manager::Error Charger::getErrorState() {
types::evse_manager::ErrorEnum Charger::getErrorState() {
std::lock_guard<std::recursive_mutex> lock(stateMutex);
return errorState;
}
Expand Down Expand Up @@ -1182,7 +1182,7 @@ void Charger::checkSoftOverCurrent() {
currentDrawnByVehicle[0], currentDrawnByVehicle[1],
currentDrawnByVehicle[2], limit));
currentState = EvseState::Error;
errorState = types::evse_manager::Error::OverCurrent;
errorState = types::evse_manager::ErrorEnum::OverCurrent;
}
}

Expand Down
6 changes: 3 additions & 3 deletions modules/EvseManager/Charger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Charger {
sigslot::signal<> signal_DC_supply_off;

// Request more details about the error that happend
types::evse_manager::Error getErrorState();
types::evse_manager::ErrorEnum getErrorState();

void processEvent(types::board_support::Event event);

Expand Down Expand Up @@ -186,7 +186,7 @@ class Charger {

EvseState getCurrentState();
sigslot::signal<EvseState> signalState;
sigslot::signal<types::evse_manager::Error> signalError;
sigslot::signal<types::evse_manager::ErrorEnum> signalError;
// /Deprecated

void inform_new_evse_max_hlc_limits(const types::iso15118_charger::DC_EVSEMaximumLimits& l);
Expand Down Expand Up @@ -230,7 +230,7 @@ class Charger {

EvseState currentState;
EvseState lastState;
types::evse_manager::Error errorState{types::evse_manager::Error::Internal};
types::evse_manager::ErrorEnum errorState{types::evse_manager::ErrorEnum::Internal};
std::chrono::system_clock::time_point currentStateStarted;

float ampereToDutyCycle(float ampere);
Expand Down
8 changes: 5 additions & 3 deletions modules/EvseManager/evse/evse_managerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ void evse_managerImpl::ready() {

se.transaction_finished.emplace(transaction_finished);
} else if (e == types::evse_manager::SessionEventEnum::Error) {
se.error = mod->charger->getErrorState();
types::evse_manager::Error error;
error.error_code = mod->charger->getErrorState();
se.error = error;
}

se.uuid = session_uuid;
Expand Down Expand Up @@ -252,11 +254,11 @@ void evse_managerImpl::ready() {
static_cast<int>(s));
});

mod->charger->signalError.connect([this](types::evse_manager::Error s) {
mod->charger->signalError.connect([this](types::evse_manager::ErrorEnum s) {
mod->mqtt.publish(fmt::format("everest_external/nodered/{}/state/error_type", mod->config.connector_id),
static_cast<int>(s));
mod->mqtt.publish(fmt::format("everest_external/nodered/{}/state/error_string", mod->config.connector_id),
types::evse_manager::error_to_string(s));
types::evse_manager::error_enum_to_string(s));
});
// /Deprecated
}
Expand Down
10 changes: 9 additions & 1 deletion modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ static ocpp::v16::ChargePointErrorCode get_ocpp_error_code(const std::string& ev
return ocpp::v16::ChargePointErrorCode::EVCommunicationError;
} else if (evse_error == "HLC") {
return ocpp::v16::ChargePointErrorCode::EVCommunicationError;
} else if (evse_error == "NoError") {
return ocpp::v16::ChargePointErrorCode::NoError;
} else {
return ocpp::v16::ChargePointErrorCode::OtherError;
}
Expand Down Expand Up @@ -518,9 +520,15 @@ void OCPP::init() {
} else if (event == "Error") {
EVLOG_debug << "Connector#" << connector << ": "
<< "Received Error";
const auto evse_error = types::evse_manager::error_to_string(session_event.error.value());
const auto evse_error = types::evse_manager::error_enum_to_string(session_event.error.value().error_code);
ocpp::v16::ChargePointErrorCode ocpp_error_code = get_ocpp_error_code(evse_error);
this->charge_point->on_error(connector, ocpp_error_code);
} else if (event == "AllErrorsCleared") {
this->charge_point->on_fault(connector, ocpp::v16::ChargePointErrorCode::NoError);
} else if (event == "PermanentFault") {
const auto evse_error = types::evse_manager::error_enum_to_string(session_event.error.value().error_code);
ocpp::v16::ChargePointErrorCode ocpp_error_code = get_ocpp_error_code(evse_error);
this->charge_point->on_fault(connector, ocpp_error_code);
} else if (event == "ReservationStart") {
this->charge_point->on_reservation_start(connector);
} else if (event == "ReservationEnd") {
Expand Down
24 changes: 20 additions & 4 deletions types/evse_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ types:
ChargingFinished: Charging is finished. Essentially the same as TransactionFinished, but emitted for clarity
TransactionFinished: Signaled when the transaction finished. Transaction finishes at the point where one of the preconditions for charging irrevocably becomes false: When a user swipes to stop the transaction and the stop is authorized.
SessionFinished: Session finishes at the point that the EVSE is available again (no cable plugged)
Error: Signaled when an error occured
Error: Signaled when an error occured. An error doesnt prevent further charging operations.
AllErrorsCleared: Signalled when all errors are cleared
PermanentFault: Signaled when there is a permanent fault at the EVSE
PermanentFault: Signaled when there is a permanent fault at the EVSE. A permanent fault prevents further charging operations
ReservationStart: Signaled when a reservation starts
ReservationEnd: Signaled when a reservation ends
ReplugStarted: Signaled when the EVSE Manager virtually replugs without interrupting the session or transaction
Expand Down Expand Up @@ -208,7 +208,7 @@ types:
id_tag:
description: Id tag that was used to stop the transaction
type: string
Error:
ErrorEnum:
description: >-
Details on error type
Car: Signals a car error
Expand All @@ -231,6 +231,22 @@ types:
- Internal
- SLAC
- HLC
- Other
Error:
description: >-
Error object that contains information about the error and optional vendor error information
type: object
additionalProperties: false
required:
- error_code
properties:
error_code:
description: The error enum
type: string
$ref: /evse_manager#/ErrorEnum
vendor_error:
description: The error code of the vendor
type: string
SessionEvent:
description: Emits all events related to sessions
type: object
Expand Down Expand Up @@ -266,7 +282,7 @@ types:
$ref: /evse_manager#/TransactionFinished
error:
description: Details on error type
type: string
type: object
$ref: /evse_manager#/Error
Limits:
description: Limits of this EVSE
Expand Down

0 comments on commit a75d73a

Please sign in to comment.