// SPDX-License-Identifier: Apache-2.0 // Copyright 2020 - 2021 Pionix GmbH and Contributors to EVerest /* The ErrorHandling class handles all errors from BSP/ConnectorLock etc and classifies them for charging: If we can continue charging despite the error, we treat them as warnings and do not track them here. If e.g. the BSP raises a high temperature error it needs to limit the output power by itself. The decision whether an error requires a replug or not to clear depends on the reporting module. It will need to clear them at the appropriate time. */ #ifndef SRC_ERROR_HANDLING_H_ #define SRC_ERROR_HANDLING_H_ #include "ld-ev.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Timeout.hpp" #include "utils/thread.hpp" namespace module { class EvseManager; // ErrorHandling events enum class ErrorHandlingEvents : std::uint8_t { ForceErrorShutdown, ForceEmergencyShutdown, AllErrorsPreventingChargingCleared, AllErrorCleared }; enum class ShutdownType { None, ErrorShutdown, EmergencyShutdown }; class ErrorHandling { public: // We need the r_bsp reference to be able to talk to the bsp driver module explicit ErrorHandling(const std::unique_ptr& r_bsp, const std::vector>& r_hlc, const std::vector>& r_connector_lock, const std::vector>& r_ac_rcd, const std::unique_ptr& _p_evse, const std::vector>& _r_imd, const std::vector>& _r_powersupply, const std::vector>& _r_powermeter, const std::vector>& _r_over_voltage_monitor, bool _inoperative_error_use_vendor_id); // Signal that error set has changed. Bool argument is true if it is preventing charging at the moment and false if // charging can continue. sigslot::signal signal_error; // Signal that all errors are cleared (both those preventing charging and not) sigslot::signal<> signal_all_errors_cleared; void raise_overcurrent_error(const std::string& description); void clear_overcurrent_error(); void raise_over_voltage_error(Everest::error::Severity severity, const std::string& description); void clear_over_voltage_error(); void raise_internal_error(const std::string& description); void clear_internal_error(); void raise_authorization_timeout_error(const std::string& description); void clear_authorization_timeout_error(); void raise_powermeter_transaction_start_failed_error(const std::string& description); void clear_powermeter_transaction_start_failed_error(); void raise_isolation_resistance_fault(const std::string& description, const std::string& sub_type); void clear_isolation_resistance_fault(const std::string& sub_type); void raise_cable_check_fault(const std::string& description); void clear_cable_check_fault(); void raise_voltage_plausibility_fault(const std::string& description); void clear_voltage_plausibility_fault(); protected: void raise_inoperative_error(const Everest::error::Error& caused_by); private: void process_error(); void clear_inoperative_error(); std::optional errors_prevent_charging(); const std::unique_ptr& r_bsp; const std::vector>& r_hlc; const std::vector>& r_connector_lock; const std::vector>& r_ac_rcd; const std::unique_ptr& p_evse; const std::vector>& r_imd; const std::vector>& r_powersupply; const std::vector>& r_powermeter; const std::vector>& r_over_voltage_monitor; const bool inoperative_error_use_vendor_id; }; } // namespace module #endif // SRC_BSP_STATE_MACHINE_H_