forked from EVerest/everest-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from US-JOET/charin-e2e-demo-last-min-hacks
Fixes to get the simulation to work with the current HEAD
- Loading branch information
Showing
10 changed files
with
205 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
diff -r -uw libocpp_unmod/lib/ocpp/v201/charge_point.cpp libocpp/lib/ocpp/v201/charge_point.cpp | ||
--- libocpp_unmod/lib/ocpp/v201/charge_point.cpp 2024-06-11 14:29:41 | ||
+++ libocpp/lib/ocpp/v201/charge_point.cpp 2024-06-12 13:31:16 | ||
@@ -14,6 +14,7 @@ | ||
#include <string> | ||
|
||
using namespace std::chrono_literals; | ||
+using namespace nlohmann; | ||
|
||
const auto DEFAULT_MAX_CUSTOMER_INFORMATION_DATA_LENGTH = 51200; | ||
|
||
@@ -1195,7 +1196,9 @@ | ||
} | ||
|
||
void ChargePoint::handle_message(const EnhancedMessage<v201::MessageType>& message) { | ||
+ EVLOG_error << "Handle_message called: " << message.message; | ||
const auto& json_message = message.message; | ||
+ EVLOG_error << "json_message called: " << json_message; | ||
switch (message.messageType) { | ||
case MessageType::BootNotificationResponse: | ||
this->handle_boot_notification_response(json_message); | ||
@@ -1278,6 +1281,22 @@ | ||
case MessageType::CustomerInformation: | ||
this->handle_customer_information_req(json_message); | ||
break; | ||
+ case MessageType::SetChargingProfile: | ||
+ { | ||
+ EVLOG_error << "before calling, json_message: " << json_message; | ||
+ EVLOG_error << "before calling, actual message part: " << json_message[3]; | ||
+ /* | ||
+ json manual_json = { | ||
+ {"evseId", 1}, | ||
+ {"chargingProfile", json_message[3]}, | ||
+ }; | ||
+ EVLOG_error << "before calling, json_wrapped message: " << manual_json; | ||
+ json_message[3] = manual_json; | ||
+ */ | ||
+ EVLOG_error << "before calling, reconstructed call: " << json_message; | ||
+ this->handle_set_charging_profile_req(json_message); | ||
+ break; | ||
+ } | ||
default: | ||
if (message.messageTypeId == MessageTypeId::CALL) { | ||
const auto call_error = CallError(message.uniqueId, "NotImplemented", "", json({})); | ||
@@ -3073,8 +3092,11 @@ | ||
} | ||
|
||
// Functional Block K: Smart Charging | ||
+// void ChargePoint::handle_set_charging_profile_req(json& manual_json) { | ||
void ChargePoint::handle_set_charging_profile_req(Call<SetChargingProfileRequest> call) { | ||
+ EVLOG_error << "here before initializing response"; | ||
SetChargingProfileResponse response; | ||
+ EVLOG_error << "Received SetChargingProfile: " << call.msg << "\nwith messageId: " << call.uniqueId; | ||
auto validity = this->smart_charging_handler->validate_profile(call.msg.chargingProfile, call.msg.evseId); | ||
|
||
if (validity != ProfileValidationResultEnum::Valid) { | ||
@@ -3085,6 +3107,7 @@ | ||
this->callbacks.signal_set_charging_profiles_callback.value()(); | ||
} | ||
} | ||
+ EVLOG_error << "Received profile validity: " << validity << "setting response to " << response; | ||
ocpp::CallResult<SetChargingProfileResponse> call_result(response, call.uniqueId); | ||
this->send<SetChargingProfileResponse>(call_result); | ||
} | ||
Only in libocpp/lib/ocpp/v201: charge_point.cpp.orig | ||
diff -r -uw libocpp_unmod/lib/ocpp/v201/messages/SetChargingProfile.cpp libocpp/lib/ocpp/v201/messages/SetChargingProfile.cpp | ||
--- libocpp_unmod/lib/ocpp/v201/messages/SetChargingProfile.cpp 2024-06-11 14:29:41 | ||
+++ libocpp/lib/ocpp/v201/messages/SetChargingProfile.cpp 2024-06-12 12:25:48 | ||
@@ -7,6 +7,15 @@ | ||
#include <optional> | ||
|
||
#include <ocpp/v201/messages/SetChargingProfile.hpp> | ||
+#include <ocpp/common/types.hpp> | ||
+#include <ocpp/v201/charge_point.hpp> | ||
+#include <ocpp/v201/ctrlr_component_variables.hpp> | ||
+#include <ocpp/v201/device_model_storage_sqlite.hpp> | ||
+#include <ocpp/v201/enums.hpp> | ||
+#include <ocpp/v201/messages/FirmwareStatusNotification.hpp> | ||
+#include <ocpp/v201/messages/LogStatusNotification.hpp> | ||
+#include <ocpp/v201/notify_report_requests_splitter.hpp> | ||
+#include <ocpp/v201/smart_charging.hpp> | ||
|
||
using json = nlohmann::json; | ||
|
||
@@ -31,8 +40,9 @@ | ||
|
||
void from_json(const json& j, SetChargingProfileRequest& k) { | ||
// the required parts of the message | ||
- k.evseId = j.at("evseId"); | ||
- k.chargingProfile = j.at("chargingProfile"); | ||
+ EVLOG_error << "In the message class, parsing from JSON: " << j; | ||
+ k.evseId = j.value("evseId", 1); | ||
+ k.chargingProfile = j.value("chargingProfile", j.at("ChargingProfile")); | ||
|
||
// the optional parts of the message | ||
if (j.contains("customData")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
diff -r -uw modules/OCPP201/OCPP201.cpp modules/OCPP201/OCPP201.cpp | ||
--- modules/OCPP201/OCPP201.cpp 2024-06-11 22:16:13 | ||
+++ modules/OCPP201/OCPP201.cpp 2024-06-12 15:05:09 | ||
@@ -421,9 +421,11 @@ | ||
}; | ||
|
||
// Smart Charging support | ||
+ EVLOG_warning << "Launching timer for calling set_external_limits function"; | ||
this->charging_schedules_timer = std::make_unique<Everest::SteadyTimer>([this]() { | ||
const auto charging_schedules = | ||
this->charge_point->get_all_composite_charging_schedules(this->config.PublishChargingScheduleDurationS); | ||
+ EVLOG_warning << "Timer complete, calling set_external_limits function"; | ||
this->set_external_limits(charging_schedules); | ||
this->publish_charging_schedules(charging_schedules); | ||
}); | ||
@@ -434,7 +436,7 @@ | ||
}; | ||
|
||
callbacks.signal_set_charging_profiles_callback = [this]() { | ||
- EVLOG_info << "Received a new Charging Schedules from the CSMS or another actor."; | ||
+ EVLOG_warning << "Received a new Charging Schedules from the CSMS or another actor."; | ||
const auto charging_schedules = | ||
this->charge_point->get_all_composite_charging_schedules(this->config.PublishChargingScheduleDurationS); | ||
this->set_external_limits(charging_schedules); | ||
@@ -577,6 +579,8 @@ | ||
// for each EVSE | ||
for (auto const& [evse_id, schedule] : charging_schedules) { | ||
types::energy::ExternalLimits limits; | ||
+ // SORRY!! | ||
+ if (evse_id == 0) continue; | ||
std::vector<types::energy::ScheduleReqEntry> schedule_import; | ||
for (const auto period : schedule.chargingSchedulePeriod) { | ||
types::energy::ScheduleReqEntry schedule_req_entry; | ||
@@ -597,7 +601,7 @@ | ||
limits.schedule_import.emplace(schedule_import); | ||
|
||
// FIXME: Support EVSE ID 0 | ||
- EVLOG_debug << "OCPP sets the following external limits for EVSE " << evse_id << ": \n" << limits; | ||
+ EVLOG_warning << "OCPP sets the following external limits for EVSE " << evse_id << " at index " << (evse_id -1) << " : \n" << limits; | ||
this->r_evse_manager.at(evse_id-1)->call_set_external_limits(limits); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
diff --git a/modules/PyEvJosev/module.py b/modules/PyEvJosev/module.py | ||
index fabc388..c8961fc 100644 | ||
--- a/modules/PyEvJosev/module.py | ||
+++ b/modules/PyEvJosev/module.py | ||
@@ -95,6 +95,7 @@ class PyEVJosevModule(): | ||
|
||
def _handler_start_charging(self, args) -> bool: | ||
|
||
+ self._es.PaymentOption =args['PaymentOption'] | ||
self._es.EnergyTransferMode = args['EnergyTransferMode'] | ||
|
||
self._ready_event.set() | ||
diff --git a/modules/simulation/JsEvManager/index.js b/modules/simulation/JsEvManager/index.js | ||
index e5b4e9c..4bce5f5 100644 | ||
--- a/modules/JsEvManager/index.js | ||
+++ b/modules/JsEvManager/index.js | ||
@@ -362,17 +362,27 @@ function registerAllCmds(mod) { | ||
}); | ||
|
||
if (mod.uses_list.ev.length > 0) { | ||
- registerCmd(mod, 'iso_start_v2g_session', 1, (mod, c) => { | ||
- switch (c.args[0]) { | ||
+ registerCmd(mod, 'iso_start_v2g_session', 2, (mod, c) => { | ||
+ if (c.args[0] === 'externalpayment') mod.payment = 'ExternalPayment'; | ||
+ else if (c.args[0] === 'contract') mod.payment = 'Contract'; | ||
+ else { | ||
+ evlog.debug('Found invalid payment method' + c.args[0]); | ||
+ return false; | ||
+ } | ||
+ | ||
+ switch (c.args[1]) { | ||
case 'ac': | ||
if (mod.config.module.three_phases !== true) mod.energymode = 'AC_single_phase_core'; | ||
else mod.energymode = 'AC_three_phase_core'; | ||
break; | ||
case 'dc': mod.energymode = 'DC_extended'; break; | ||
- default: return false; | ||
+ default: | ||
+ evlog.debug('Found invalid payment method' + c.args[1]); | ||
+ return false; | ||
} | ||
|
||
- mod.uses_list.ev[0].call.start_charging({ EnergyTransferMode: mod.energymode }); | ||
+ args = { PaymentOption: mod.payment, EnergyTransferMode: mod.energymode }; | ||
+ mod.uses_list.ev[0].call.start_charging(args); | ||
|
||
return true; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters