Skip to content

Commit

Permalink
Merge pull request #4 from US-JOET/charin-e2e-demo-last-min-hacks
Browse files Browse the repository at this point in the history
Fixes to get the simulation to work with the current HEAD
  • Loading branch information
shankari authored Jun 13, 2024
2 parents 55378d0 + 9eaea42 commit 0ccbeb9
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 50 deletions.
39 changes: 0 additions & 39 deletions config-sil-ocpp201-pnc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,41 +43,10 @@ active_modules:
hlc:
- module_id: iso15118_charger
implementation_id: charger
evse_manager_2:
module: EvseManager
config_module:
connector_id: 2
three_phases: true
has_ventilation: true
country_code: DE
evse_id: "2"
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
ac_hlc_enabled: false
ac_hlc_use_5percent: false
ac_enforce_hlc: false
connections:
bsp:
- module_id: yeti_driver_2
implementation_id: board_support
powermeter_grid_side:
- module_id: yeti_driver_2
implementation_id: powermeter
slac:
- module_id: slac
implementation_id: evse
hlc:
- module_id: iso15118_charger
implementation_id: charger
yeti_driver_1:
module: JsYetiSimulator
config_module:
connector_id: 1
yeti_driver_2:
module: JsYetiSimulator
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
car_simulator_1:
Expand All @@ -103,8 +72,6 @@ active_modules:
evse_manager:
- module_id: evse_manager_1
implementation_id: evse
- module_id: evse_manager_2
implementation_id: evse
auth:
- module_id: auth
implementation_id: main
Expand Down Expand Up @@ -133,16 +100,12 @@ active_modules:
implementation_id: auth_provider
- module_id: evse_manager_1
implementation_id: token_provider
- module_id: evse_manager_2
implementation_id: token_provider
token_validator:
- module_id: ocpp
implementation_id: auth_validator
evse_manager:
- module_id: evse_manager_1
implementation_id: evse
- module_id: evse_manager_2
implementation_id: evse
energy_manager:
module: EnergyManager
connections:
Expand All @@ -159,8 +122,6 @@ active_modules:
energy_consumer:
- module_id: evse_manager_1
implementation_id: energy_grid
- module_id: evse_manager_2
implementation_id: energy_grid
powermeter:
- module_id: yeti_driver_1
implementation_id: powermeter
Expand Down
19 changes: 16 additions & 3 deletions demo-iso15118-2-ac-plus-ocpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,28 @@ fi
pushd everest-demo || exit 1
docker compose --project-name everest-ac-demo --file "${DEMO_COMPOSE_FILE_NAME}" up -d --wait

# Configure and restart nodered
echo "Configuring and restarting nodered"
docker cp nodered/config/config-sil-iso15118-ac-flow.json everest-ac-demo-nodered-1:/config/config-sil-two-evse-flow.json
docker restart everest-ac-demo-nodered-1

# Configure and restart EVerest
echo "Copying over all EVerest patches"
docker cp config-sil-ocpp201-pnc.yaml everest-ac-demo-manager-1:/ext/source/config/config-sil-ocpp201-pnc.yaml
docker cp manager/enable_payment_method.patch everest-ac-demo-manager-1:/tmp/
docker cp manager/support_payment_in_jsevmanager.patch everest-ac-demo-manager-1:/tmp/
docker cp manager/ocpp201.module.patch everest-ac-demo-manager-1:/tmp/
docker cp manager/libocpp.patch everest-ac-demo-manager-1:/tmp/

echo "Applying the ones that need recompile first"
docker exec everest-ac-demo-manager-1 /bin/bash -c "apk add patch && cd /ext/source && patch -p0 -i /tmp/ocpp201.module.patch"
docker exec everest-ac-demo-manager-1 /bin/bash -c "cd /ext/cache/cpm/libocpp/6502037f667273b3f55e917ec94a3fe0a2d27720 && patch -p0 -i /tmp/libocpp.patch"

echo "Recompiling"
docker exec everest-ac-demo-manager-1 /bin/bash -c "cd /ext/source/build && make install -j6"

echo "Now applying the patches that don't need recompile and will, in fact, be overridden by recompile"
docker cp manager/enable_evcc_logging.cfg everest-ac-demo-manager-1:/ext/source/build/dist/etc/everest/default_logging.cfg
docker exec everest-ac-demo-manager-1 /bin/bash -c "apk add patch && cd /ext && patch -p0 -i /tmp/enable_payment_method.patch"
docker exec everest-ac-demo-manager-1 /bin/bash -c "cd /ext && patch -p0 -i /tmp/enable_payment_method.patch"
docker exec everest-ac-demo-manager-1 /bin/bash -c "cd /ext/source/build/dist/libexec/everest && patch -p1 -i /tmp/support_payment_in_jsevmanager.patch"

if [[ "$DEMO_VERSION" =~ sp2 || "$DEMO_VERSION" =~ sp3 ]]; then
docker cp manager/cached_certs_correct_name_emaid.tar.gz everest-ac-demo-manager-1:/ext/source/build
Expand Down
5 changes: 0 additions & 5 deletions docker-compose.ocpp201.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ services:
manager:
image: ghcr.io/us-joet/everest-demo/manager:charin-e2e-demo
platform: linux/x86_64
deploy:
resources:
limits:
cpus: "${EVEREST_MANAGER_CPUS}"
memory: "${EVEREST_MANAGER_MEMORY}"
depends_on:
- mqtt-server
environment:
Expand Down
Binary file modified manager/device_model_storage_maeve_sp1.db
Binary file not shown.
Binary file modified manager/device_model_storage_maeve_sp2.db
Binary file not shown.
Binary file modified manager/device_model_storage_maeve_sp3.db
Binary file not shown.
96 changes: 96 additions & 0 deletions manager/libocpp.patch
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")) {
42 changes: 42 additions & 0 deletions manager/ocpp201.module.patch
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);
}
}
48 changes: 48 additions & 0 deletions manager/support_payment_in_jsevmanager.patch
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;
});
6 changes: 3 additions & 3 deletions nodered/config/config-sil-iso15118-ac-flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "everest_external/nodered/carsim/#/cmd/enable",
"topic": "everest_external/nodered/#/carsim/cmd/enable",
"topicType": "str",
"style": "",
"onvalue": "true",
Expand Down Expand Up @@ -2093,12 +2093,12 @@
"options": [
{
"label": "AC ISO15118-2",
"value": "sleep 1;iso_wait_slac_matched;iso_start_v2g_session ExternalPayment,AC_three_phase_core;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000#iso_stop_charging;iso_wait_v2g_session_stopped;unplug#iso_pause_charging;iso_wait_for_resume#iso_start_bcb_toogle 3;iso_wait_pwm_is_running;iso_start_v2g_session ExternalPayment,AC_three_phase_core;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000",
"value": "sleep 1;iso_wait_slac_matched;iso_start_v2g_session externalpayment,ac;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000#iso_stop_charging;iso_wait_v2g_session_stopped;unplug#iso_pause_charging;iso_wait_for_resume#iso_start_bcb_toogle 3;iso_wait_pwm_is_running;iso_start_v2g_session ExternalPayment,AC_three_phase_core;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000",
"type": "str"
},
{
"label": "AC ISO15118-2 Plug&Charge",
"value": "sleep 1;iso_wait_slac_matched;iso_start_v2g_session contract,AC_three_phase_core;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000#;iso_stop_charging;iso_wait_v2g_session_stopped;unplug#iso_pause_charging;iso_wait_for_resume#iso_start_bcb_toogle 3;iso_wait_pwm_is_running;iso_start_v2g_session contract,AC_three_phase_core;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000",
"value": "sleep 1;iso_wait_slac_matched;iso_start_v2g_session contract,ac;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000#;iso_stop_charging;iso_wait_v2g_session_stopped;unplug#iso_pause_charging;iso_wait_for_resume#iso_start_bcb_toogle 3;iso_wait_pwm_is_running;iso_start_v2g_session contract,AC_three_phase_core;iso_wait_pwr_ready;iso_draw_power_regulated 16,3;sleep 36000",
"type": "str"
}
],
Expand Down

0 comments on commit 0ccbeb9

Please sign in to comment.