Skip to content

Commit

Permalink
Feature/376 ocpp 201 california pricing requirements tariff and cost (#…
Browse files Browse the repository at this point in the history
…768)

* Implement california pricing requirements for OCPP 1.6.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Kai-Uwe Hermann <[email protected]>
Co-authored-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
maaikez and hikinggrass authored Aug 13, 2024
1 parent 0e86d84 commit da0da54
Show file tree
Hide file tree
Showing 28 changed files with 1,296 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ workspace.yaml
.vscode/
/bazel-*
/modules/target
CMakeLists.txt.user
.idea/
9 changes: 9 additions & 0 deletions config/config-sil-ocpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ active_modules:
security:
- module_id: evse_security
implementation_id: main
display_message:
- module_id: display_message
implementation_id: display_message
display_message:
module: TerminalCostAndPriceMessage
connections:
session_cost:
- module_id: ocpp
implementation_id: session_cost
evse_security:
module: EvseSecurity
config_module:
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ libevse-security:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: 398f0c5e3465d49a27524d708a8e8281461e69fa
git_tag: v0.15.1
cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP"
# Josev
Josev:
Expand Down
46 changes: 46 additions & 0 deletions interfaces/display_message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
description: >-
A module that implements this interface should be able to:
- store (add, remove, change) and retrieve predefined messages
- show messages on a display
When a display message contains a session id, the display message must be removed once the session has ended.
cmds:
set_display_message:
description: >-
Command to set or replace a display message.
arguments:
request:
description: >-
Request to set a display message
type: array
items:
description: The display messages to set
type: object
$ref: /display_message#/DisplayMessage
result:
description: >-
Response to the set display message request.
type: object
$ref: /display_message#/SetDisplayMessageResponse
get_display_messages:
description: Command to get one or more display messages.
arguments:
request:
description: The request for display messages
type: object
$ref: /display_message#/GetDisplayMessageRequest
result:
description: The display messages or an empty array if there are none
type: object
$ref: /display_message#/GetDisplayMessageResponse
clear_display_message:
description: Command to remove a display message
arguments:
request:
description: The request to clear a message
type: object
$ref: /display_message#/ClearDisplayMessageRequest
result:
description: Response on the clear message request
type: object
$ref: /display_message#/ClearDisplayMessageResponse
1 change: 1 addition & 0 deletions modules/OCPP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ target_sources(${MODULE_NAME}
"auth_provider/auth_token_providerImpl.cpp"
"data_transfer/ocpp_data_transferImpl.cpp"
"ocpp_generic/ocppImpl.cpp"
"session_cost/session_costImpl.cpp"
"conversions.cpp"
)

Expand Down
32 changes: 32 additions & 0 deletions modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,38 @@ void OCPP::ready() {
this->p_ocpp_generic->publish_boot_notification_response(everest_boot_notification_response);
});

this->charge_point->register_session_cost_callback(
[this](const ocpp::RunningCost& session_cost,
const uint32_t number_of_decimals) -> ocpp::v16::DataTransferResponse {
const types::session_cost::SessionCost cost =
conversions::create_session_cost(session_cost, number_of_decimals, {});
ocpp::v16::DataTransferResponse response;
this->p_session_cost->publish_session_cost(cost);
response.status = ocpp::v16::DataTransferStatus::Accepted;
return response;
});

this->charge_point->register_set_display_message_callback(
[this](const std::vector<ocpp::DisplayMessage>& messages) -> ocpp::v16::DataTransferResponse {
ocpp::v16::DataTransferResponse response;
if (this->r_display_message.empty()) {
EVLOG_warning << "No display message handler registered, dropping data transfer message";
response.status = ocpp::v16::DataTransferStatus::Rejected;
return response;
}
std::vector<types::display_message::DisplayMessage> display_messages;
for (const ocpp::DisplayMessage& message : messages) {
const types::display_message::DisplayMessage m = conversions::to_everest_display_message(message);
display_messages.push_back(m);
}

const types::display_message::SetDisplayMessageResponse display_message_response =
this->r_display_message.at(0)->call_set_display_message(display_messages);
response = conversions::to_ocpp_data_transfer_response(display_message_response);

return response;
});

if (!this->r_data_transfer.empty()) {
this->charge_point->register_data_transfer_callback([this](const ocpp::v16::DataTransferRequest& request) {
types::ocpp::DataTransferRequest data_transfer_request;
Expand Down
10 changes: 9 additions & 1 deletion modules/OCPP/OCPP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
#include <generated/interfaces/ocpp/Implementation.hpp>
#include <generated/interfaces/ocpp_1_6_charge_point/Implementation.hpp>
#include <generated/interfaces/ocpp_data_transfer/Implementation.hpp>
#include <generated/interfaces/session_cost/Implementation.hpp>

// headers for required interface implementations
#include <generated/interfaces/auth/Interface.hpp>
#include <generated/interfaces/display_message/Interface.hpp>
#include <generated/interfaces/evse_manager/Interface.hpp>
#include <generated/interfaces/evse_security/Interface.hpp>
#include <generated/interfaces/external_energy_limits/Interface.hpp>
Expand Down Expand Up @@ -71,25 +73,29 @@ class OCPP : public Everest::ModuleBase {
std::unique_ptr<auth_token_validatorImplBase> p_auth_validator,
std::unique_ptr<auth_token_providerImplBase> p_auth_provider,
std::unique_ptr<ocpp_data_transferImplBase> p_data_transfer, std::unique_ptr<ocppImplBase> p_ocpp_generic,
std::unique_ptr<session_costImplBase> p_session_cost,
std::vector<std::unique_ptr<evse_managerIntf>> r_evse_manager,
std::vector<std::unique_ptr<external_energy_limitsIntf>> r_connector_zero_sink,
std::unique_ptr<reservationIntf> r_reservation, std::unique_ptr<authIntf> r_auth,
std::unique_ptr<systemIntf> r_system, std::unique_ptr<evse_securityIntf> r_security,
std::vector<std::unique_ptr<ocpp_data_transferIntf>> r_data_transfer, Conf& config) :
std::vector<std::unique_ptr<ocpp_data_transferIntf>> r_data_transfer,
std::vector<std::unique_ptr<display_messageIntf>> r_display_message, Conf& config) :
ModuleBase(info),
mqtt(mqtt_provider),
p_main(std::move(p_main)),
p_auth_validator(std::move(p_auth_validator)),
p_auth_provider(std::move(p_auth_provider)),
p_data_transfer(std::move(p_data_transfer)),
p_ocpp_generic(std::move(p_ocpp_generic)),
p_session_cost(std::move(p_session_cost)),
r_evse_manager(std::move(r_evse_manager)),
r_connector_zero_sink(std::move(r_connector_zero_sink)),
r_reservation(std::move(r_reservation)),
r_auth(std::move(r_auth)),
r_system(std::move(r_system)),
r_security(std::move(r_security)),
r_data_transfer(std::move(r_data_transfer)),
r_display_message(std::move(r_display_message)),
config(config){};

Everest::MqttProvider& mqtt;
Expand All @@ -98,13 +104,15 @@ class OCPP : public Everest::ModuleBase {
const std::unique_ptr<auth_token_providerImplBase> p_auth_provider;
const std::unique_ptr<ocpp_data_transferImplBase> p_data_transfer;
const std::unique_ptr<ocppImplBase> p_ocpp_generic;
const std::unique_ptr<session_costImplBase> p_session_cost;
const std::vector<std::unique_ptr<evse_managerIntf>> r_evse_manager;
const std::vector<std::unique_ptr<external_energy_limitsIntf>> r_connector_zero_sink;
const std::unique_ptr<reservationIntf> r_reservation;
const std::unique_ptr<authIntf> r_auth;
const std::unique_ptr<systemIntf> r_system;
const std::unique_ptr<evse_securityIntf> r_security;
const std::vector<std::unique_ptr<ocpp_data_transferIntf>> r_data_transfer;
const std::vector<std::unique_ptr<display_messageIntf>> r_display_message;
const Conf& config;

// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
Expand Down
Loading

0 comments on commit da0da54

Please sign in to comment.