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

Introduce EVSE Manager configuration option for failing charging if t… #993

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
23 changes: 20 additions & 3 deletions modules/EvseManager/ErrorHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static const struct IgnoreErrors {
ErrorList ac_rcd{"ac_rcd/VendorWarning"};
ErrorList imd{"isolation_monitor/VendorWarning"};
ErrorList powersupply{"power_supply_DC/VendorWarning"};
ErrorList powermeter{};
} ignore_errors;

ErrorHandling::ErrorHandling(const std::unique_ptr<evse_board_supportIntf>& _r_bsp,
Expand All @@ -23,14 +24,16 @@ ErrorHandling::ErrorHandling(const std::unique_ptr<evse_board_supportIntf>& _r_b
const std::vector<std::unique_ptr<ac_rcdIntf>>& _r_ac_rcd,
const std::unique_ptr<evse_managerImplBase>& _p_evse,
const std::vector<std::unique_ptr<isolation_monitorIntf>>& _r_imd,
const std::vector<std::unique_ptr<power_supply_DCIntf>>& _r_powersupply) :
const std::vector<std::unique_ptr<power_supply_DCIntf>>& _r_powersupply,
const std::vector<std::unique_ptr<powermeterIntf>>& _r_powermeter) :
r_bsp(_r_bsp),
r_hlc(_r_hlc),
r_connector_lock(_r_connector_lock),
r_ac_rcd(_r_ac_rcd),
p_evse(_p_evse),
r_imd(_r_imd),
r_powersupply(_r_powersupply) {
r_powersupply(_r_powersupply),
r_powermeter(_r_powermeter) {

// Subscribe to bsp driver to receive Errors from the bsp hardware
r_bsp->subscribe_all_errors([this](const Everest::error::Error& error) { process_error(); },
Expand Down Expand Up @@ -59,6 +62,12 @@ ErrorHandling::ErrorHandling(const std::unique_ptr<evse_board_supportIntf>& _r_b
r_powersupply[0]->subscribe_all_errors([this](const Everest::error::Error& error) { process_error(); },
[this](const Everest::error::Error& error) { process_error(); });
}

// Subscribe to powermeter to receive errors from powermeter hardware
if (r_powermeter.size() > 0) {
r_powermeter[0]->subscribe_all_errors([this](const Everest::error::Error& error) { process_error(); },
[this](const Everest::error::Error& error) { process_error(); });
}
}

void ErrorHandling::raise_overcurrent_error(const std::string& description) {
Expand Down Expand Up @@ -102,7 +111,8 @@ void ErrorHandling::process_error() {
const int error_count = p_evse->error_state_monitor->get_active_errors().size() +
r_bsp->error_state_monitor->get_active_errors().size() +
number_of_active_errors(r_connector_lock) + number_of_active_errors(r_ac_rcd) +
number_of_active_errors(r_imd) + number_of_active_errors(r_powersupply);
number_of_active_errors(r_imd) + number_of_active_errors(r_powersupply) +
number_of_active_errors(r_powermeter);

if (error_count == 0) {
signal_all_errors_cleared();
Expand Down Expand Up @@ -159,6 +169,13 @@ std::optional<std::string> ErrorHandling::errors_prevent_charging() {
}
}

if (r_powermeter.size() > 0) {
fatal = is_fatal(r_powermeter[0]->error_state_monitor->get_active_errors(), ignore_errors.powermeter);
if (fatal) {
return fatal;
}
}

return std::nullopt;
}

Expand Down
5 changes: 4 additions & 1 deletion modules/EvseManager/ErrorHandling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <generated/interfaces/evse_manager/Interface.hpp>
#include <generated/interfaces/isolation_monitor/Interface.hpp>
#include <generated/interfaces/power_supply_DC/Interface.hpp>
#include <generated/interfaces/powermeter/Interface.hpp>
#include <sigslot/signal.hpp>

#include "Timeout.hpp"
Expand All @@ -47,7 +48,8 @@ class ErrorHandling {
const std::vector<std::unique_ptr<ac_rcdIntf>>& r_ac_rcd,
const std::unique_ptr<evse_managerImplBase>& _p_evse,
const std::vector<std::unique_ptr<isolation_monitorIntf>>& _r_imd,
const std::vector<std::unique_ptr<power_supply_DCIntf>>& _r_powersupply);
const std::vector<std::unique_ptr<power_supply_DCIntf>>& _r_powersupply,
const std::vector<std::unique_ptr<powermeterIntf>>& _r_powermeter);

// Signal that error set has changed. Bool argument is true if it is preventing charging at the moment and false if
// charging can continue.
Expand Down Expand Up @@ -77,6 +79,7 @@ class ErrorHandling {
const std::unique_ptr<evse_managerImplBase>& p_evse;
const std::vector<std::unique_ptr<isolation_monitorIntf>>& r_imd;
const std::vector<std::unique_ptr<power_supply_DCIntf>>& r_powersupply;
const std::vector<std::unique_ptr<powermeterIntf>>& r_powermeter;
};

} // namespace module
Expand Down
7 changes: 6 additions & 1 deletion modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,13 @@ void EvseManager::ready() {
bsp->set_ev_simplified_mode_evse_limit(true);
}

// we provide the powermeter interface to the ErrorHandling only if we need to react to powermeter errors
// otherwise we provide an empty vector of pointers to the powermeter interface
const std::vector<std::unique_ptr<powermeterIntf>> empty;
error_handling = std::unique_ptr<ErrorHandling>(
new ErrorHandling(r_bsp, r_hlc, r_connector_lock, r_ac_rcd, p_evse, r_imd, r_powersupply_DC));
new ErrorHandling(r_bsp, r_hlc, r_connector_lock, r_ac_rcd, p_evse, r_imd, r_powersupply_DC,
config.fail_on_powermeter_errors ? r_powermeter_billing() : empty));

if (not config.lock_connector_in_state_b) {
EVLOG_warning << "Unlock connector in CP state B. This violates IEC61851-1:2019 D.6.5 Table D.9 line 4 and "
"should not be used in public environments!";
Expand Down
6 changes: 3 additions & 3 deletions modules/EvseManager/EvseManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct Conf {
int soft_over_current_timeout_ms;
bool lock_connector_in_state_b;
int state_F_after_fault_ms;
bool fail_on_powermeter_errors;
};

class EvseManager : public Everest::ModuleBase {
Expand Down Expand Up @@ -136,8 +137,7 @@ class EvseManager : public Everest::ModuleBase {
r_imd(std::move(r_imd)),
r_powersupply_DC(std::move(r_powersupply_DC)),
r_store(std::move(r_store)),
config(config) {
}
config(config){};

Everest::MqttProvider& mqtt;
Everest::TelemetryProvider& telemetry;
Expand Down Expand Up @@ -194,7 +194,7 @@ class EvseManager : public Everest::ModuleBase {

const std::vector<std::unique_ptr<powermeterIntf>>& r_powermeter_billing();

// FIXME: this will be removed with proper intergration of BPT on ISO-20
// FIXME: this will be removed with proper integration of BPT on ISO-20
// on DIN SPEC and -2 we claim a positive charging current on ISO protocol,
// but the power supply switches to discharge if this flag is set.
std::atomic_bool is_actually_exporting_to_grid{false};
Expand Down
125 changes: 65 additions & 60 deletions modules/EvseManager/doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ EvseManager

See also module's :ref:`auto-generated reference <everest_modules_EvseManager>`.

The module ``EvseManager`` is a central module that manages one EVSE
The module ``EvseManager`` is a central module that manages one EVSE
(i.e. one connector to charge a car).
It may control multiple physical connectors if they are not usable at the same
time and share one connector id,
but one EvseManager always shows as one connector in OCPP for example. So in
but one EvseManager always shows as one connector in OCPP for example. So in
general each connector should have a dedicated EvseManager module loaded.

The EvseManager contains the high level charging logic (Basic charging and
HLC/SLAC interaction), collects all relevant data for the charging session
(e.g. energy delivered during this charging session) and provides control over
the charging port/session. For HLC it uses two helper protocol modules that it
The EvseManager contains the high level charging logic (Basic charging and
HLC/SLAC interaction), collects all relevant data for the charging session
(e.g. energy delivered during this charging session) and provides control over
the charging port/session. For HLC it uses two helper protocol modules that it
controls (SLAC and ISO15118).

Protocol modules such as OCPP or other APIs use EvseManagers to control the
Protocol modules such as OCPP or other APIs use EvseManagers to control the
charging session and get all relevant data.

The following charge modes are supported:
Expand All @@ -32,7 +32,7 @@ Additional features:

* Autocharge support (PnC coming soon)
* Seamlessly integrates into EVerest Energy Management
* The lowest level IEC61851 state machine can be run on a dedicated
* The lowest level IEC61851 state machine can be run on a dedicated
microcontroller for improved electrical safety
* Support for seperate AC and DC side metering in DC application

Expand All @@ -47,18 +47,18 @@ AC Configuration
DC Configuration
----------------

In DC applications, the EvseManager still has an AC side that behaves similar
to a normal AC charger. The board_support module therefore still has to report
In DC applications, the EvseManager still has an AC side that behaves similar
to a normal AC charger. The board_support module therefore still has to report
AC capabilities which refer to the AC input of the AC/DC power supply. If an AC
side RCD is used it also belongs to the board_support driver.
An AC side power meter can be connected and it will be used for Energy
side RCD is used it also belongs to the board_support driver.
An AC side power meter can be connected and it will be used for Energy
management.

In addition, on the DC side the following hardware modules can be connected:

* A DC powermeter: This will be used for billing purposes if present.
* A DC powermeter: This will be used for billing purposes if present.
If not connected, billing will fall back to the AC side power meter.
* Isolation monitoring: This will be used to monitor isolation during
* Isolation monitoring: This will be used to monitor isolation during
CableCheck, PreCharge and CurrentDemand steps.
* DC power supply: This is the AC/DC converter that actually charges the car.

Expand All @@ -68,37 +68,37 @@ Published variables
session_events
--------------

EvseManager publishes the session_events variable whenever an event happens.
It does not publish its internal state but merely events that happen that can
EvseManager publishes the session_events variable whenever an event happens.
It does not publish its internal state but merely events that happen that can
be used to drive an state machine within another module.

Example: Write a simple module that lights up an LED if the evse is reserved.
This module requires an EvseManager and subscribes to the session_events
variable. Internally it has only two states: Reserved (LED on), NotReserved
Example: Write a simple module that lights up an LED if the evse is reserved.
This module requires an EvseManager and subscribes to the session_events
variable. Internally it has only two states: Reserved (LED on), NotReserved
(LED off).

The state machine transitions are driven by the two events from EvseManager:
The state machine transitions are driven by the two events from EvseManager:
ReservationStart and ReservationEnd.

All other events are ignored in this module as they are not needed.

powermeter
----------

EvseManager republishes the power meter struct that if it has a powermeter
connected. This struct should be used for OCPP and display purposes. It comes
from the power meter that can be used for billing (DC side on DC, AC side on
AC). If no powermeter is connected EvseManager will never publish this
EvseManager republishes the power meter struct that if it has a powermeter
connected. This struct should be used for OCPP and display purposes. It comes
from the power meter that can be used for billing (DC side on DC, AC side on
AC). If no powermeter is connected EvseManager will never publish this
variable.


Authentication
==============

The Auth modules validates tokens and assignes tokens to EvseManagers, see Auth
documentation. It will call ``Authorize(id_tag, pnc)`` on EvseManager to
indicated that the EvseManager may start the charging session.
Auth module may revoke authorization (``withdraw_authorization`` command) if
documentation. It will call ``Authorize(id_tag, pnc)`` on EvseManager to
indicated that the EvseManager may start the charging session.
Auth module may revoke authorization (``withdraw_authorization`` command) if
the charging session has not begun yet (typically due to timeout), but not once
charging has started.

Expand All @@ -107,79 +107,79 @@ Autocharge / PnC
----------------

Autocharge is fully supported, PnC support is coming soon and will use the same
logic. The car itself is a token provider that can provide an auth token to be
validated by the Auth system (see Auth documentation for more details).
logic. The car itself is a token provider that can provide an auth token to be
validated by the Auth system (see Auth documentation for more details).
EvseManager provides a ``token_provider`` interface for that purpose.

If external identification (EIM) is used in HLC (no PnC) then Autocharge is
If external identification (EIM) is used in HLC (no PnC) then Autocharge is
enabled by connecting the ``token_provider`` interface to Auth module. When the
car sends its EVCCID in the HLC protocol it is converted to Autocharge format
car sends its EVCCID in the HLC protocol it is converted to Autocharge format
and published as Auth token. It is based on the following specification:

https://github.com/openfastchargingalliance/openfastchargingalliance/blob/master/autocharge-final.pdf

To enable PnC the config option ``payment_enable_contract`` must be set to
true. If the car selects Contract instead of EIM PnC will be used instead of
To enable PnC the config option ``payment_enable_contract`` must be set to
true. If the car selects Contract instead of EIM PnC will be used instead of
Autocharge.

Reservation
-----------

Reservation handling logic is implemented in the Auth module. If the Auth
module wants to reserve a specific EvseManager (or cancel the reservation) it
needs to call the reserve/cancel_reservation commands. EvseManager does not
check reservation id against the token id when it should start charging, this
must be handled in Auth module. EvseManager only needs to know whether it is
Reservation handling logic is implemented in the Auth module. If the Auth
module wants to reserve a specific EvseManager (or cancel the reservation) it
needs to call the reserve/cancel_reservation commands. EvseManager does not
check reservation id against the token id when it should start charging, this
must be handled in Auth module. EvseManager only needs to know whether it is
reserved or not to emit an ReservatonStart/ReservationEnd event to notify other
modules such as OCPP and API or e.g. switch on a specific LED signal on the
modules such as OCPP and API or e.g. switch on a specific LED signal on the
charging port.

Energy Management
=================

EvseManager seamlessly intergrates into the EVerest Energy Management.
EvseManager seamlessly intergrates into the EVerest Energy Management.
For further details refer to the documentation of the EnergyManager module.

EvseManager has a grid facing Energy interface which the energy tree uses to
provide energy for the charging sessions. New energy needs to be provided on
regular intervals (with a timeout).
EvseManager has a grid facing Energy interface which the energy tree uses to
provide energy for the charging sessions. New energy needs to be provided on
regular intervals (with a timeout).

If the supplied energy limits time out, EvseManager will stop charging.
This prevents e.g. overload conditions when the network connection drops
This prevents e.g. overload conditions when the network connection drops
between the energy tree and EvseManager.

EvseManager will send out its wishes at regular intervals: It sends a
requested energy schedule into the energy tree that is merged from hardware
capabilities (as reported by board_support module), EvseManager module
configuration settings
(max_current, three_phases) and external limts (via ``set_external_limits``
EvseManager will send out its wishes at regular intervals: It sends a
requested energy schedule into the energy tree that is merged from hardware
capabilities (as reported by board_support module), EvseManager module
configuration settings
(max_current, three_phases) and external limts (via ``set_external_limits``
command) e.g. set by OCPP module.

Note that the ``set_external_limits`` should not be used by multiple modules,
as the last one always wins. If you have multiple sources of exernal limits
that you want to combine, add extra EnergyNode modules in the chain and
that you want to combine, add extra EnergyNode modules in the chain and
feed in limits via those.

The combined schedule sent to the energy tree is the minimum of all energy
The combined schedule sent to the energy tree is the minimum of all energy
limits.

After traversing the energy tree the EnergyManager will use this information
to assign limits (and a schedule)
for this EvseManager and will call enforce_limits on the energy interface.
After traversing the energy tree the EnergyManager will use this information
to assign limits (and a schedule)
for this EvseManager and will call enforce_limits on the energy interface.
These values will then be used
to configure PWM/DC power supplies to actually charge the car and must not
to configure PWM/DC power supplies to actually charge the car and must not
be confused with the original wishes that
were sent to the energy tree.
were sent to the energy tree.

The EvseManager will never assign energy to itself, it always requests energy
The EvseManager will never assign energy to itself, it always requests energy
from the energy manager and only charges
if the energy manager responds with an assignment.

Limits in the energy object can be specified in ampere (per phase) and/or watt.
Currently watt limits are unsupported, but it should behave according to that
Currently watt limits are unsupported, but it should behave according to that
logic:

If both are specified also both limits will be applied, whichever is lower.
If both are specified also both limits will be applied, whichever is lower.
With DC charging, ampere limits apply
to the AC side and watt limits apply to both AC and DC side.

Expand Down Expand Up @@ -230,12 +230,13 @@ This module subscribes to all errors of the following requirements:
* ac_rcd
* isolation_monitor
* power_supply_DC
* powermeter (if the config option fail_on_powermeter_errors is set true)

A raised error can cause the EvseManager to become Inoperative. This means that charging is not possible until the error is cleared.
If no charging session is currently running, it will prevent sessions from being started. If a charging session is currently running and an error is raised
this will interrupt the charging session.

Almost all errors that are reported from the requirements of this module cause the EvseManager to become Inoperative until the error is cleared.
Almost all errors that are reported from the requirements of this module cause the EvseManager to become Inoperative until the error is cleared.
The following sections provide an overview of the errors that do **not** cause the EvseManager to become Inoperative.

evse_board_support
Expand Down Expand Up @@ -265,4 +266,8 @@ power_supply_DC

* power_supply_DC/VendorWarning

powermeter
----------

* powermeter/CommunicationFault

Loading