Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter
- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
# template version 3
|
||||
#
|
||||
|
||||
# module setup:
|
||||
# - ${MODULE_NAME}: module name
|
||||
ev_setup_cpp_module()
|
||||
|
||||
# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1
|
||||
# insert your custom targets and additional config variables here
|
||||
# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1
|
||||
|
||||
target_sources(${MODULE_NAME}
|
||||
PRIVATE
|
||||
"data_transfer/ocpp_data_transferImpl.cpp"
|
||||
)
|
||||
|
||||
# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
|
||||
# insert other things like install cmds etc here
|
||||
install(FILES Custom.json DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP/profile_schemas)
|
||||
# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Json schema for Custom configuration keys",
|
||||
"$comment": "This is just an example schema and can be modified according to custom requirements",
|
||||
"type": "object",
|
||||
"required": [],
|
||||
"properties": {
|
||||
"ExampleConfigurationKey": {
|
||||
"type": "string",
|
||||
"description": "Custom key",
|
||||
"readOnly": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#include "OCPPExtensionExample.hpp"
|
||||
|
||||
namespace module {
|
||||
|
||||
void OCPPExtensionExample::init() {
|
||||
invoke_init(*p_data_transfer);
|
||||
}
|
||||
|
||||
void OCPPExtensionExample::ready() {
|
||||
invoke_ready(*p_data_transfer);
|
||||
|
||||
std::istringstream ss(this->config.keys_to_monitor);
|
||||
std::vector<types::ocpp::ComponentVariable> component_variables;
|
||||
|
||||
std::string key;
|
||||
while (std::getline(ss, key, ',')) {
|
||||
// Push each token into the vector
|
||||
component_variables.push_back({{""}, {key}}); // For OCPP1.6 we only need to specify the variable.name
|
||||
}
|
||||
|
||||
// We register monitors for custom configuration keys here
|
||||
this->r_ocpp->call_monitor_variables(component_variables);
|
||||
|
||||
// anytime this configuration key is changed by the CSMS and we have
|
||||
// registered a monitor, this callback is executed
|
||||
this->r_ocpp->subscribe_event_data([](types::ocpp::EventData event_data) {
|
||||
// Add your custom handler here
|
||||
EVLOG_info << "Configuration key: " << event_data.component_variable.variable.name
|
||||
<< " has been changed by CSMS to: " << event_data.actual_value;
|
||||
});
|
||||
|
||||
std::vector<types::ocpp::SetVariableRequest> set_variable_requests;
|
||||
set_variable_requests.push_back({{{""}, {"ExampleConfigurationKey"}}, "ExampleValue"});
|
||||
|
||||
EVLOG_info << "Setting custom configuration key...";
|
||||
const auto set_variable_results = this->r_ocpp->call_set_variables(set_variable_requests, "example");
|
||||
|
||||
for (const auto& set_variable_result : set_variable_results) {
|
||||
if (set_variable_result.status == types::ocpp::SetVariableStatusEnumType::Accepted) {
|
||||
EVLOG_info << "Successfully set ExampleConfigurationKey";
|
||||
} else {
|
||||
EVLOG_info << "Could not set ExampleConfigurationKey: "
|
||||
<< types::ocpp::set_variable_status_enum_type_to_string(set_variable_result.status);
|
||||
}
|
||||
}
|
||||
|
||||
// adding a configuration key that does not exist to show that this will be
|
||||
// part of the unknown keys of the result
|
||||
component_variables.push_back({{""}, {"KeyThatIsNotConfigured"}});
|
||||
|
||||
std::vector<types::ocpp::GetVariableRequest> get_variables_requests;
|
||||
for (const auto& component_variable : component_variables) {
|
||||
get_variables_requests.push_back({component_variable});
|
||||
}
|
||||
|
||||
EVLOG_info << "Requesting configuration keys from OCPP...";
|
||||
const auto get_variables_results = this->r_ocpp->call_get_variables(get_variables_requests);
|
||||
|
||||
for (const auto& get_variables_result : get_variables_results) {
|
||||
if (get_variables_result.status == types::ocpp::GetVariableStatusEnumType::Accepted) {
|
||||
EVLOG_info << "Key: " << get_variables_result.component_variable.variable.name << ": "
|
||||
<< get_variables_result.value.value();
|
||||
} else {
|
||||
EVLOG_info << "Unknown: " << get_variables_result.component_variable.variable.name;
|
||||
}
|
||||
}
|
||||
|
||||
types::ocpp::DataTransferRequest data_transfer_request;
|
||||
data_transfer_request.vendor_id = "EVerest";
|
||||
data_transfer_request.data.emplace("hi");
|
||||
auto data_transfer_response = this->r_data_transfer->call_data_transfer(data_transfer_request);
|
||||
switch (data_transfer_response.status) {
|
||||
case types::ocpp::DataTransferStatus::Accepted:
|
||||
EVLOG_info << "Data transfer was accepted";
|
||||
break;
|
||||
case types::ocpp::DataTransferStatus::Rejected:
|
||||
EVLOG_info << "Data transfer was rejected";
|
||||
break;
|
||||
case types::ocpp::DataTransferStatus::UnknownVendorId:
|
||||
EVLOG_info << "Data transfer was rejected (UnknownVendorId)";
|
||||
break;
|
||||
case types::ocpp::DataTransferStatus::UnknownMessageId:
|
||||
EVLOG_info << "Data transfer was rejected (UnknownMessageId)";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace module
|
||||
@@ -0,0 +1,72 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#ifndef OCPPEXTENSION_EXAMPLE_HPP
|
||||
#define OCPPEXTENSION_EXAMPLE_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 2
|
||||
//
|
||||
|
||||
#include "ld-ev.hpp"
|
||||
|
||||
// headers for provided interface implementations
|
||||
#include <generated/interfaces/ocpp_data_transfer/Implementation.hpp>
|
||||
|
||||
// headers for required interface implementations
|
||||
#include <generated/interfaces/ocpp/Interface.hpp>
|
||||
#include <generated/interfaces/ocpp_data_transfer/Interface.hpp>
|
||||
|
||||
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1
|
||||
// insert your custom include headers here
|
||||
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1
|
||||
|
||||
namespace module {
|
||||
|
||||
struct Conf {
|
||||
std::string keys_to_monitor;
|
||||
};
|
||||
|
||||
class OCPPExtensionExample : public Everest::ModuleBase {
|
||||
public:
|
||||
OCPPExtensionExample() = delete;
|
||||
OCPPExtensionExample(const ModuleInfo& info, std::unique_ptr<ocpp_data_transferImplBase> p_data_transfer,
|
||||
std::unique_ptr<ocppIntf> r_ocpp, std::unique_ptr<ocpp_data_transferIntf> r_data_transfer,
|
||||
Conf& config) :
|
||||
ModuleBase(info),
|
||||
p_data_transfer(std::move(p_data_transfer)),
|
||||
r_ocpp(std::move(r_ocpp)),
|
||||
r_data_transfer(std::move(r_data_transfer)),
|
||||
config(config){};
|
||||
|
||||
const std::unique_ptr<ocpp_data_transferImplBase> p_data_transfer;
|
||||
const std::unique_ptr<ocppIntf> r_ocpp;
|
||||
const std::unique_ptr<ocpp_data_transferIntf> r_data_transfer;
|
||||
const Conf& config;
|
||||
|
||||
// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
|
||||
// insert your public definitions here
|
||||
// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
|
||||
|
||||
protected:
|
||||
// ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1
|
||||
// insert your protected definitions here
|
||||
// ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1
|
||||
|
||||
private:
|
||||
friend class LdEverest;
|
||||
void init();
|
||||
void ready();
|
||||
|
||||
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
|
||||
// insert your private definitions here
|
||||
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
|
||||
};
|
||||
|
||||
// ev@087e516b-124c-48df-94fb-109508c7cda9:v1
|
||||
// insert other definitions here
|
||||
// ev@087e516b-124c-48df-94fb-109508c7cda9:v1
|
||||
|
||||
} // namespace module
|
||||
|
||||
#endif // OCPPEXTENSION_EXAMPLE_HPP
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "ocpp_data_transferImpl.hpp"
|
||||
|
||||
namespace module {
|
||||
namespace data_transfer {
|
||||
|
||||
void ocpp_data_transferImpl::init() {
|
||||
}
|
||||
|
||||
void ocpp_data_transferImpl::ready() {
|
||||
}
|
||||
|
||||
types::ocpp::DataTransferResponse
|
||||
ocpp_data_transferImpl::handle_data_transfer(types::ocpp::DataTransferRequest& request) {
|
||||
types::ocpp::DataTransferResponse response;
|
||||
response.status = types::ocpp::DataTransferStatus::Rejected;
|
||||
|
||||
if (request.vendor_id == "EVerest") {
|
||||
response.data = "hello there";
|
||||
response.status = types::ocpp::DataTransferStatus::Accepted;
|
||||
} else {
|
||||
response.status = types::ocpp::DataTransferStatus::UnknownVendorId;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
} // namespace data_transfer
|
||||
} // namespace module
|
||||
@@ -0,0 +1,62 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#ifndef DATA_TRANSFER_OCPP_DATA_TRANSFER_IMPL_HPP
|
||||
#define DATA_TRANSFER_OCPP_DATA_TRANSFER_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/ocpp_data_transfer/Implementation.hpp>
|
||||
|
||||
#include "../OCPPExtensionExample.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace data_transfer {
|
||||
|
||||
struct Conf {};
|
||||
|
||||
class ocpp_data_transferImpl : public ocpp_data_transferImplBase {
|
||||
public:
|
||||
ocpp_data_transferImpl() = delete;
|
||||
ocpp_data_transferImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<OCPPExtensionExample>& mod,
|
||||
Conf& config) :
|
||||
ocpp_data_transferImplBase(ev, "data_transfer"), mod(mod), config(config){};
|
||||
|
||||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
|
||||
// insert your public definitions here
|
||||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
|
||||
|
||||
protected:
|
||||
// command handler functions (virtual)
|
||||
virtual types::ocpp::DataTransferResponse handle_data_transfer(types::ocpp::DataTransferRequest& request) override;
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<OCPPExtensionExample>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
// insert your private definitions here
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
};
|
||||
|
||||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
|
||||
// insert other definitions here
|
||||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
|
||||
|
||||
} // namespace data_transfer
|
||||
} // namespace module
|
||||
|
||||
#endif // DATA_TRANSFER_OCPP_DATA_TRANSFER_IMPL_HPP
|
||||
@@ -0,0 +1,25 @@
|
||||
description: >-
|
||||
This is an example module that shows how the OCPP module of EVerest could be extended using the DataTransfer functionality
|
||||
and custom configuration keys
|
||||
config:
|
||||
keys_to_monitor:
|
||||
description: Commad seperated list of keys that should be monitored
|
||||
type: string
|
||||
default: "HeartbeatInterval,SecurityProfile,ExampleConfigurationKey"
|
||||
provides:
|
||||
data_transfer:
|
||||
description: OCPP data transfer
|
||||
interface: ocpp_data_transfer
|
||||
requires:
|
||||
ocpp:
|
||||
interface: ocpp
|
||||
min_connections: 1
|
||||
max_connections: 1
|
||||
data_transfer:
|
||||
interface: ocpp_data_transfer
|
||||
min_connections: 1
|
||||
max_connections: 1
|
||||
metadata:
|
||||
license: https://opensource.org/licenses/Apache-2.0
|
||||
authors:
|
||||
- Piet Gömpel
|
||||
Reference in New Issue
Block a user