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,119 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "power_supply_DCImpl.hpp"
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
void power_supply_DCImpl::init() {
|
||||
|
||||
caps.bidirectional = false;
|
||||
|
||||
caps.current_regulation_tolerance_A = 1;
|
||||
caps.peak_current_ripple_A = 0.5;
|
||||
|
||||
caps.min_export_current_A = 0;
|
||||
caps.max_export_current_A = mod->config.max_export_current_A;
|
||||
caps.min_export_voltage_V = 150;
|
||||
caps.max_export_voltage_V = 1000;
|
||||
caps.max_export_power_W = mod->config.max_export_power_W;
|
||||
|
||||
caps.max_import_current_A = 0;
|
||||
caps.min_import_current_A = 0;
|
||||
caps.max_import_power_W = 0;
|
||||
caps.min_import_voltage_V = 0;
|
||||
caps.max_import_voltage_V = 0;
|
||||
|
||||
mod->acdc.signal_capabilities.connect([this](const types::power_supply_DC::Capabilities& c) {
|
||||
caps = c;
|
||||
// limit by config values
|
||||
if (caps.max_export_current_A > mod->config.max_export_current_A) {
|
||||
caps.max_export_current_A = mod->config.max_export_current_A;
|
||||
}
|
||||
if (caps.max_export_power_W > mod->config.max_export_power_W) {
|
||||
caps.max_export_power_W = mod->config.max_export_power_W;
|
||||
}
|
||||
publish_capabilities(caps);
|
||||
});
|
||||
|
||||
mod->acdc.signal_voltage_current.connect([this](float voltage, float current) {
|
||||
types::power_supply_DC::VoltageCurrent vc;
|
||||
vc.current_A = current;
|
||||
vc.voltage_V = voltage;
|
||||
publish_voltage_current(vc);
|
||||
});
|
||||
|
||||
mod->acdc.signal_serial_number.connect([this](int module_id, const std::string& serial_number) {
|
||||
EVLOG_info << "Module ID " << module_id << ": " << serial_number;
|
||||
});
|
||||
|
||||
mod->acdc.signal_on_off.connect([this](bool on) {
|
||||
if (on) {
|
||||
publish_mode(types::power_supply_DC::Mode::Import);
|
||||
} else {
|
||||
publish_mode(types::power_supply_DC::Mode::Off);
|
||||
}
|
||||
});
|
||||
|
||||
mod->acdc.signal_communication_error.connect([this](bool err, const std::string& desc) {
|
||||
if (err) {
|
||||
Everest::error::Error error_object = error_factory->create_error("power_supply_DC/CommunicationFault", "",
|
||||
desc, Everest::error::Severity::High);
|
||||
raise_error(error_object);
|
||||
comm_fault_error_raised = true;
|
||||
} else {
|
||||
if (comm_fault_error_raised) {
|
||||
clear_error("power_supply_DC/CommunicationFault");
|
||||
comm_fault_error_raised = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void power_supply_DCImpl::ready() {
|
||||
mod->p_main->publish_capabilities(caps);
|
||||
}
|
||||
|
||||
void power_supply_DCImpl::handle_setMode(types::power_supply_DC::Mode& mode,
|
||||
types::power_supply_DC::ChargingPhase& phase) {
|
||||
std::scoped_lock lock(settings_mutex);
|
||||
|
||||
if (mode == types::power_supply_DC::Mode::Off) {
|
||||
mod->acdc.switch_on(false);
|
||||
} else if (mode == types::power_supply_DC::Mode::Export) {
|
||||
mod->acdc.switch_on(true);
|
||||
} else if (mode == types::power_supply_DC::Mode::Import) {
|
||||
mod->acdc.switch_on(false);
|
||||
} else if (mode == types::power_supply_DC::Mode::Fault) {
|
||||
mod->acdc.switch_on(false);
|
||||
}
|
||||
};
|
||||
|
||||
void power_supply_DCImpl::handle_setExportVoltageCurrent(double& voltage, double& current) {
|
||||
|
||||
if (voltage > caps.max_export_voltage_V)
|
||||
voltage = caps.max_export_voltage_V;
|
||||
else if (voltage < caps.min_export_voltage_V)
|
||||
voltage = caps.min_export_voltage_V;
|
||||
|
||||
if (current > caps.max_export_current_A)
|
||||
current = caps.max_export_current_A;
|
||||
else if (current < caps.min_export_current_A)
|
||||
current = caps.min_export_current_A;
|
||||
|
||||
std::scoped_lock lock(settings_mutex);
|
||||
|
||||
export_voltage = voltage;
|
||||
export_current_limit = current;
|
||||
|
||||
EVLOG_info << "Updating voltage/current via CAN: " << export_voltage << "V / " << export_current_limit << "A";
|
||||
mod->acdc.set_voltage_current(export_voltage, export_current_limit);
|
||||
};
|
||||
|
||||
void power_supply_DCImpl::handle_setImportVoltageCurrent(double& voltage, double& current) {
|
||||
EVLOG_error << "Not implemented";
|
||||
}
|
||||
|
||||
} // namespace main
|
||||
} // namespace module
|
||||
@@ -0,0 +1,72 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#ifndef MAIN_POWER_SUPPLY_DC_IMPL_HPP
|
||||
#define MAIN_POWER_SUPPLY_DC_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/power_supply_DC/Implementation.hpp>
|
||||
|
||||
#include "../Huawei_R100040Gx.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
struct Conf {};
|
||||
|
||||
class power_supply_DCImpl : public power_supply_DCImplBase {
|
||||
public:
|
||||
power_supply_DCImpl() = delete;
|
||||
power_supply_DCImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<Huawei_R100040Gx>& mod, Conf& config) :
|
||||
power_supply_DCImplBase(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 void handle_setMode(types::power_supply_DC::Mode& mode,
|
||||
types::power_supply_DC::ChargingPhase& phase) override;
|
||||
virtual void handle_setExportVoltageCurrent(double& voltage, double& current) override;
|
||||
virtual void handle_setImportVoltageCurrent(double& voltage, double& current) override;
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<Huawei_R100040Gx>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
std::mutex settings_mutex;
|
||||
double export_voltage{0.};
|
||||
double export_current_limit{0.};
|
||||
double minImportVoltage{0.};
|
||||
double importCurrentLimit{0.};
|
||||
types::power_supply_DC::Capabilities caps;
|
||||
|
||||
types::power_supply_DC::Mode last_publish_mode{types::power_supply_DC::Mode::Off};
|
||||
bool comm_fault_error_raised{false};
|
||||
// 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_POWER_SUPPLY_DC_IMPL_HPP
|
||||
Reference in New Issue
Block a user