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,80 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "charger_informationImpl.hpp"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
void charger_informationImpl::init() {
|
||||
}
|
||||
|
||||
void charger_informationImpl::ready() {
|
||||
json info(handle_get_charger_information());
|
||||
|
||||
EVLOG_debug << "ChargerInformation: " << info.dump();
|
||||
}
|
||||
|
||||
std::string charger_informationImpl::load_fw_version_from_file(const std::string& fn) {
|
||||
std::ifstream fw_version_file(fn);
|
||||
std::string first_line;
|
||||
|
||||
if (!fw_version_file) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!std::getline(fw_version_file, first_line)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return first_line;
|
||||
}
|
||||
|
||||
types::charger_information::ChargerInformation charger_informationImpl::handle_get_charger_information() {
|
||||
std::vector<std::string> keys = {"vendor", "model", "chargepoint_serial", "chargebox_serial",
|
||||
"friendly_name", "manufacturer", "manufacturer_url", "model_url",
|
||||
"model_number", "model_revision", "board_revision", "firmware_version"};
|
||||
json info = {};
|
||||
|
||||
// in case we are chained, retrieve data from previous module
|
||||
if (not this->mod->r_charger_information.empty()) {
|
||||
info = this->mod->r_charger_information[0]->call_get_charger_information();
|
||||
}
|
||||
|
||||
// iterate over all linked key-value stores and merge all items,
|
||||
// when a key exists in more than one kvs then the last one wins
|
||||
for (const auto& kvs : mod->r_kvs) {
|
||||
for (const auto k : keys) {
|
||||
if (kvs->call_exists(k)) {
|
||||
const auto v = kvs->call_load(k);
|
||||
info[k] = std::get<std::string>(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finally check whether we should load the firmware version from a simple plain text file
|
||||
if (!mod->config.firmware_version_file.empty()) {
|
||||
info["firmware_version"] = load_fw_version_from_file(mod->config.firmware_version_file);
|
||||
}
|
||||
|
||||
// generate fallback friendly_name: we use the chargepoint's serial,
|
||||
// because we assume that this one is printed on a device label and not the (internal)
|
||||
// chargebox' serial number (aka controller serial number) which is usually only important for
|
||||
// the manufacturer itself
|
||||
if (info.contains("vendor") and info.contains("model") and info.contains("chargepoint_serial") and
|
||||
not info.contains("friendly_name")) {
|
||||
info["friendly_name"] = info["vendor"].get<std::string>() + " " + info["model"].get<std::string>() + " [" +
|
||||
info["chargepoint_serial"].get<std::string>() + "]";
|
||||
}
|
||||
|
||||
EVLOG_debug << "ChargerInformation: " << info.dump();
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace main
|
||||
} // namespace module
|
||||
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#ifndef MAIN_CHARGER_INFORMATION_IMPL_HPP
|
||||
#define MAIN_CHARGER_INFORMATION_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/charger_information/Implementation.hpp>
|
||||
|
||||
#include "../ChargerInfo.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
#include <string>
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
struct Conf {};
|
||||
|
||||
class charger_informationImpl : public charger_informationImplBase {
|
||||
public:
|
||||
charger_informationImpl() = delete;
|
||||
charger_informationImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<ChargerInfo>& mod, Conf& config) :
|
||||
charger_informationImplBase(ev, "main"), 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::charger_information::ChargerInformation handle_get_charger_information() override;
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<ChargerInfo>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
// insert your private definitions here
|
||||
std::string load_fw_version_from_file(const std::string& fn);
|
||||
// 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 main
|
||||
} // namespace module
|
||||
|
||||
#endif // MAIN_CHARGER_INFORMATION_IMPL_HPP
|
||||
Reference in New Issue
Block a user