Skip to content

Commit

Permalink
addressed requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
  • Loading branch information
Pietfried committed Oct 10, 2024
1 parent 81489a4 commit b88570e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
37 changes: 20 additions & 17 deletions modules/API/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,15 @@ void API::init() {

std::string cmd_set_limit = cmd_base + "set_limit_amps";

this->mqtt.subscribe(cmd_set_limit, [&evse, &r_evse_manager_energy_sink = this->r_evse_manager_energy_sink,
const auto& evse_energy_sink = this->r_evse_manager_energy_sink.at(evse_id);

this->mqtt.subscribe(cmd_set_limit, [&evse_manager_check = this->evse_manager_check,
&evse_energy_sink = evse_energy_sink,
evse_id](const std::string& data) {
try {
const auto external_limits = get_external_limits(data, false);
this->evse_manager_check.wait_ready();
r_evse_manager_energy_sink.at(evse_id - 1)->call_set_external_limits(external_limits);
evse_manager_check.wait_ready();
evse_energy_sink->call_set_external_limits(external_limits);
} catch (const std::invalid_argument& e) {
EVLOG_warning << "Invalid limit: No conversion of given input could be performed.";
} catch (const std::out_of_range& e) {
Expand All @@ -504,20 +507,20 @@ void API::init() {

std::string cmd_set_limit_watts = cmd_base + "set_limit_watts";

this->mqtt.subscribe(
cmd_set_limit_watts,
[&evse, &r_evse_manager_energy_sink = this->r_evse_manager_energy_sink, evse_id](const std::string& data) {
try {
const auto external_limits = get_external_limits(data, true);
this->evse_manager_check.wait_ready();
r_evse_manager_energy_sink.at(evse_id - 1)->call_set_external_limits(external_limits); // FIX access
} catch (const std::invalid_argument& e) {
EVLOG_warning << "Invalid limit: No conversion of given input could be performed.";
} catch (const std::out_of_range& e) {
EVLOG_warning << "Invalid limit: Out of range.";
}
});
this->mqtt.subscribe(cmd_set_limit_watts, [&evse_manager_check = this->evse_manager_check,
&evse_energy_sink = evse_energy_sink,
evse_id](const std::string& data) {
try {
const auto external_limits = get_external_limits(data, true);
evse_manager_check.wait_ready();
evse_energy_sink->call_set_external_limits(external_limits);
} catch (const std::invalid_argument& e) {
EVLOG_warning << "Invalid limit: No conversion of given input could be performed.";
} catch (const std::out_of_range& e) {
EVLOG_warning << "Invalid limit: Out of range.";
}
});

std::string cmd_force_unlock = cmd_base + "force_unlock";
this->mqtt.subscribe(cmd_force_unlock, [this, &evse](const std::string& data) {
int connector_id = 1;
Expand Down
2 changes: 1 addition & 1 deletion modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void OCPP::set_external_limits(const std::map<int32_t, ocpp::v16::EnhancedChargi
if (connector_id == 0) {
if (!this->r_evse_manager_energy_sink.empty()) {
EVLOG_debug << "OCPP sets the following external limits for connector 0: \n" << limits;
this->r_evse_manager_energy_sink.at(0)->call_set_external_limits(limits);
this->r_evse_manager_energy_sink.first()->call_set_external_limits(limits);
} else {
EVLOG_debug << "OCPP cannot set external limits for connector 0. No "
"sink is configured.";
Expand Down
2 changes: 1 addition & 1 deletion modules/OCPP/doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ OCPP1.6 defines the SmartCharging feature profile to allow the CSMS to control o
This module integrates the composite schedule(s) within EVerests energy management. For further information about smart charging and the
composite schedule calculation please refer to the OCPP1.6 specification.

The integration of the composite schedules are turned out by the optional requirement(s) `evse_manager_energy_sink`(interface: `external_energy_limits`)
The integration of the composite schedules are implemented through the optional requirement(s) `evse_manager_energy_sink`(interface: `external_energy_limits`)
of this module. Depending on the number of EVSEs configured, each composite limit is communicated via a seperate sink, including the composite schedule
for EVSE with id 0 (representing the whole charging station). The easiest way to explain this is with an example. If your charging station
has two EVSEs you need to connect three modules that implement the `external_energy_limits` interface: One representing evse id 0 and
Expand Down

0 comments on commit b88570e

Please sign in to comment.