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,75 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright (C) 2023 chargebyte GmbH
|
||||
// Copyright (C) 2023 Contributors to EVerest
|
||||
#include "isolation_monitorImpl.hpp"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
namespace module {
|
||||
|
||||
namespace main {
|
||||
|
||||
void isolation_monitorImpl::init() {
|
||||
this->isolation_monitoring_active = false;
|
||||
this->isolation_measurement.resistance_F_Ohm = this->config.resistance_F_Ohm;
|
||||
this->config_interval = this->config.interval;
|
||||
|
||||
this->isolation_measurement_thread_handle = std::thread(&isolation_monitorImpl::isolation_measurement_worker, this);
|
||||
|
||||
const std::string RESISTANCE_TOPIC = "everest_api/" + this->mod->info.id + "/cmd/set_resistance";
|
||||
this->mod->mqtt.subscribe(RESISTANCE_TOPIC, [this](const std::string& resistance_ohm) {
|
||||
try {
|
||||
int32_t _resistance_ohm = std::stoi(resistance_ohm);
|
||||
EVLOG_info << "Setting simulated isolation resistance to " << _resistance_ohm << " Ohm via MQTT";
|
||||
this->isolation_measurement.resistance_F_Ohm = _resistance_ohm;
|
||||
} catch (const std::invalid_argument& e) {
|
||||
EVLOG_error << "Failed to set isolation resistance via MQTT, invalid value: " << resistance_ohm;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void isolation_monitorImpl::ready() {
|
||||
}
|
||||
|
||||
void isolation_monitorImpl::handle_start() {
|
||||
if (this->isolation_monitoring_active == false) {
|
||||
this->isolation_monitoring_active = true;
|
||||
EVLOG_info << "Started simulated isolation monitoring with " << this->config_interval << " ms interval";
|
||||
}
|
||||
};
|
||||
|
||||
void isolation_monitorImpl::handle_start_self_test(double& test_voltage_V) {
|
||||
selftest_running_countdown = 3 * 1000 / LOOP_SLEEP_MS;
|
||||
}
|
||||
|
||||
void isolation_monitorImpl::isolation_measurement_worker() {
|
||||
while (true) {
|
||||
if (this->isolation_measurement_thread_handle.shouldExit()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->isolation_monitoring_active == true) {
|
||||
this->mod->p_main->publish_isolation_measurement(this->isolation_measurement);
|
||||
EVLOG_debug << "Simulated isolation measurement finished";
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(this->config_interval - this->LOOP_SLEEP_MS));
|
||||
}
|
||||
|
||||
if (this->selftest_running_countdown > 0) {
|
||||
this->selftest_running_countdown--;
|
||||
if (this->selftest_running_countdown == 0) {
|
||||
this->mod->p_main->publish_self_test_result(config.selftest_success);
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(this->LOOP_SLEEP_MS));
|
||||
}
|
||||
}
|
||||
|
||||
void isolation_monitorImpl::handle_stop() {
|
||||
if (this->isolation_monitoring_active == true) {
|
||||
EVLOG_info << "Stopped simulated isolation monitoring";
|
||||
this->isolation_monitoring_active = false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace main
|
||||
} // namespace module
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright (C) 2023 chargebyte GmbH
|
||||
// Copyright (C) 2023 Contributors to EVerest
|
||||
// Copyright (C) 2024 Pionix GmbH
|
||||
#ifndef MAIN_ISOLATION_MONITOR_IMPL_HPP
|
||||
#define MAIN_ISOLATION_MONITOR_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/isolation_monitor/Implementation.hpp>
|
||||
|
||||
#include "../IMDSimulator.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <utils/thread.hpp>
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
struct Conf {
|
||||
double resistance_F_Ohm;
|
||||
int interval;
|
||||
bool selftest_success;
|
||||
};
|
||||
|
||||
class isolation_monitorImpl : public isolation_monitorImplBase {
|
||||
public:
|
||||
isolation_monitorImpl() = delete;
|
||||
isolation_monitorImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<IMDSimulator>& mod, Conf& config) :
|
||||
isolation_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_start() override;
|
||||
virtual void handle_stop() override;
|
||||
virtual void handle_start_self_test(double& test_voltage_V) override;
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<IMDSimulator>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
// insert your private definitions here
|
||||
types::isolation_monitor::IsolationMeasurement isolation_measurement;
|
||||
std::atomic<bool> isolation_monitoring_active;
|
||||
int config_interval;
|
||||
static constexpr int LOOP_SLEEP_MS{20};
|
||||
|
||||
Everest::Thread isolation_measurement_thread_handle;
|
||||
void isolation_measurement_worker(void);
|
||||
|
||||
std::atomic_int selftest_running_countdown{0};
|
||||
// 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_ISOLATION_MONITOR_IMPL_HPP
|
||||
Reference in New Issue
Block a user