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,93 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "over_voltage_monitorImpl.hpp"
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
void over_voltage_monitorImpl::init() {
|
||||
over_voltage_monitoring_active = false;
|
||||
over_voltage_monitorImpl_thread_handle =
|
||||
std::thread(&over_voltage_monitorImpl::over_voltage_monitorImpl_worker, this);
|
||||
const std::string OVER_VOLTAGE_TOPIC = "everest_api/" + this->mod->info.id + "/cmd/set_over_voltage_measurement_V";
|
||||
EVLOG_info << "Can control the over voltage measurement values over the topic: " << OVER_VOLTAGE_TOPIC
|
||||
<< " via MQTT";
|
||||
this->mod->mqtt.subscribe(OVER_VOLTAGE_TOPIC, [this](const std::string& over_voltage_measurement_V) {
|
||||
try {
|
||||
EVLOG_info << "Setting simulated over voltage measurement to " << over_voltage_measurement_V
|
||||
<< " V via MQTT";
|
||||
voltage_measurement_V = std::stof(over_voltage_measurement_V);
|
||||
} catch (const std::invalid_argument& e) {
|
||||
EVLOG_error << "Failed to set over voltage measurement via MQTT, invalid value: "
|
||||
<< over_voltage_measurement_V;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void over_voltage_monitorImpl::ready() {
|
||||
if (!this->mod->r_power_supply.empty() && this->mod->r_power_supply[0]) {
|
||||
this->mod->r_power_supply[0]->subscribe_voltage_current(
|
||||
[this](types::power_supply_DC::VoltageCurrent measurement) {
|
||||
this->voltage_measurement_V = static_cast<float>(measurement.voltage_V);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void over_voltage_monitorImpl::handle_set_limits(double& emergency_over_voltage_limit_V,
|
||||
double& error_over_voltage_limit_V) {
|
||||
error_threshold = error_over_voltage_limit_V;
|
||||
emergency_threshold = emergency_over_voltage_limit_V;
|
||||
}
|
||||
|
||||
void over_voltage_monitorImpl::handle_start() {
|
||||
EVLOG_info << "Over voltage monitoring: starting with " << emergency_threshold << " (emergency) and "
|
||||
<< error_threshold << "(error)";
|
||||
over_voltage_monitoring_active = true;
|
||||
if (config.simulate_error_shutdown) {
|
||||
std::thread([this]() {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(config.simulate_error_delay));
|
||||
auto err = error_factory->create_error("over_voltage_monitor/MREC5OverVoltage", "",
|
||||
"Simulated Over voltage error shutdown occurred.",
|
||||
Everest::error::Severity::Medium);
|
||||
raise_error(err);
|
||||
}).detach();
|
||||
}
|
||||
|
||||
if (config.simulate_emergency_shutdown) {
|
||||
std::thread([this]() {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(config.simulate_error_delay));
|
||||
auto err = error_factory->create_error("over_voltage_monitor/MREC5OverVoltage", "",
|
||||
"Simulated Over voltage emergency shutdown occurred.",
|
||||
Everest::error::Severity::High);
|
||||
raise_error(err);
|
||||
}).detach();
|
||||
}
|
||||
}
|
||||
|
||||
void over_voltage_monitorImpl::over_voltage_monitorImpl_worker() {
|
||||
while (true) {
|
||||
if (this->over_voltage_monitorImpl_thread_handle.shouldExit()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->over_voltage_monitoring_active == true) {
|
||||
this->mod->p_main->publish_voltage_measurement_V(this->voltage_measurement_V);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(this->LOOP_SLEEP_MS));
|
||||
}
|
||||
}
|
||||
|
||||
void over_voltage_monitorImpl::handle_stop() {
|
||||
EVLOG_info << "Over voltage monitoring: stopped.";
|
||||
over_voltage_monitoring_active = false;
|
||||
}
|
||||
|
||||
void over_voltage_monitorImpl::handle_reset_over_voltage_error() {
|
||||
EVLOG_info << "Over voltage monitoring: reset";
|
||||
clear_all_errors_of_impl("over_voltage_monitor/MREC5OverVoltage");
|
||||
}
|
||||
|
||||
} // namespace main
|
||||
} // namespace module
|
||||
@@ -0,0 +1,78 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#ifndef MAIN_OVER_VOLTAGE_MONITOR_IMPL_HPP
|
||||
#define MAIN_OVER_VOLTAGE_MONITOR_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/over_voltage_monitor/Implementation.hpp>
|
||||
|
||||
#include "../OVMSimulator.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
#include <atomic>
|
||||
#include <utils/thread.hpp>
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
struct Conf {
|
||||
bool simulate_error_shutdown;
|
||||
bool simulate_emergency_shutdown;
|
||||
int simulate_error_delay;
|
||||
};
|
||||
|
||||
class over_voltage_monitorImpl : public over_voltage_monitorImplBase {
|
||||
public:
|
||||
over_voltage_monitorImpl() = delete;
|
||||
over_voltage_monitorImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<OVMSimulator>& mod, Conf& config) :
|
||||
over_voltage_monitorImplBase(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_set_limits(double& emergency_over_voltage_limit_V, double& error_over_voltage_limit_V) override;
|
||||
virtual void handle_start() override;
|
||||
virtual void handle_stop() override;
|
||||
virtual void handle_reset_over_voltage_error() override;
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<OVMSimulator>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
// insert your private definitions here
|
||||
double error_threshold{0.};
|
||||
double emergency_threshold{0.};
|
||||
|
||||
static constexpr int LOOP_SLEEP_MS{20};
|
||||
std::atomic<bool> over_voltage_monitoring_active;
|
||||
float voltage_measurement_V{0.0f};
|
||||
Everest::Thread over_voltage_monitorImpl_thread_handle;
|
||||
void over_voltage_monitorImpl_worker();
|
||||
// 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_OVER_VOLTAGE_MONITOR_IMPL_HPP
|
||||
Reference in New Issue
Block a user