This commit is contained in:
2026-02-14 14:30:25 +01:00
parent d3c0cb1066
commit ee5c156e56
48 changed files with 549 additions and 510 deletions
+7 -6
View File
@@ -1,13 +1,12 @@
#include "can_debugger.hpp"
Can_Debugger::Can_Debugger(CAN_Wrapper* can_wrapper, QObject* parent) :
Simulator_base("Can_Debugger", can_wrapper, std::chrono::milliseconds(100), parent),
m_wrapper(can_wrapper),
Can_Debugger::Can_Debugger(CAN_Wrapper *can_wrapper, QObject *parent)
: Simulator_base("Can_Debugger", can_wrapper, std::chrono::milliseconds(100), parent), m_wrapper(can_wrapper),
m_can_ui(Color::Black, Color::White)
{
this->add_UI_item(&this->m_can_ui);
connect(&m_can_ui, &UI_can::on_send, this, [=, this](QCanBusFrame frame){m_wrapper->send_can_message(frame);});
connect(&m_can_ui, &UI_can::on_send, this, [=, this](QCanBusFrame frame) { m_wrapper->send_can_message(frame); });
}
void Can_Debugger::timer()
@@ -17,8 +16,10 @@ void Can_Debugger::timer()
void Can_Debugger::run_at_startup()
{
connect(m_wrapper, &CAN_Wrapper::on_can_message, this, [=, this](QCanBusFrame frame){this->m_can_ui.add_received_message(frame);});
connect(m_wrapper, &CAN_Wrapper::on_can_send, this, [=, this](QCanBusFrame frame){this->m_can_ui.add_send_message(frame);});
connect(m_wrapper, &CAN_Wrapper::on_can_message, this,
[=, this](QCanBusFrame frame) { this->m_can_ui.add_received_message(frame); });
connect(m_wrapper, &CAN_Wrapper::on_can_send, this,
[=, this](QCanBusFrame frame) { this->m_can_ui.add_send_message(frame); });
}
void Can_Debugger::run_at_stop()
+3 -2
View File
@@ -1,10 +1,11 @@
#pragma once
#include "simulator_base.hpp"
class Can_Debugger : public Simulator_base {
class Can_Debugger : public Simulator_base
{
Q_OBJECT
public:
Can_Debugger();
explicit Can_Debugger(QObject* parent = nullptr);
void timer() override;
void run_at_startup() override;
void run_at_stop() override;
+5 -4
View File
@@ -28,7 +28,8 @@ m_led("Led", Color(Color::White), Color(Color::Black), Color(Color::Red))
this->add_UI_item(&this->m_checkbox);
QObject::connect(&m_button, &UI_button::on_click, this, [=, this] { button_clicked(&m_button); });
QObject::connect(&m_slider, &UI_slider::on_change, this, [=, this](double value) { slider_changed(&m_slider, value); });
QObject::connect(&m_slider, &UI_slider::on_change, this,
[=, this](double value) { slider_changed(&m_slider, value); });
}
void Test_Sim::timer()
@@ -47,20 +48,20 @@ void Test_Sim::run_at_startup()
SPDLOG_INFO("Test_Sim started");
}
void Test_Sim::button_clicked(UI_button* id)
void Test_Sim::button_clicked(UI_button *id)
{
if (id == &this->m_button)
{
bool state = this->m_button.bg_color() == Color(Color::Red) ? true : false;
this->m_button.set_bg_color(state ? Color(Color::Green) : Color(Color::Red));
this->m_button.set_text(state ? "On" : "Off");
this->m_led.set_led_color(state ? Color(Color::Green) : Color(Color::Red));
return;
}
}
void Test_Sim::slider_changed(UI_slider* id, double value)
void Test_Sim::slider_changed(UI_slider *id, double value)
{
if (id == &this->m_slider)
{
+15 -13
View File
@@ -1,23 +1,25 @@
#pragma once
#include "simulator_base.hpp"
class Test_Sim : public Simulator_base {
class Test_Sim : public Simulator_base
{
Q_OBJECT
public:
Test_Sim(QObject* parent = nullptr);
void timer() override;
void run_at_startup() override;
private:
void button_clicked(UI_button* id);
void slider_changed(UI_slider* id, double value);
private:
UI_button m_button;
UI_combobox m_combobox;
UI_label m_label;
UI_checkbox m_checkbox;
UI_slider m_slider;
UI_dial m_dial;
UI_thermo m_thermo;
UI_led m_led;
private:
void button_clicked(UI_button *id);
void slider_changed(UI_slider *id, double value);
private:
UI_button m_button;
UI_combobox m_combobox;
UI_label m_label;
UI_checkbox m_checkbox;
UI_slider m_slider;
UI_dial m_dial;
UI_thermo m_thermo;
UI_led m_led;
};