move can debugger to can if

This commit is contained in:
2026-02-14 14:32:44 +01:00
parent 36ed0f3b7b
commit 135a2a03d7
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -3,12 +3,12 @@
EXPORT_SIM(Can_Debugger);
Can_Debugger::Can_Debugger(Communication *com, QObject *parent)
: Simulator_base("Can Debugger", com, std::chrono::milliseconds(100), parent),
m_wrapper(new CAN_Wrapper(com->can_if[0].get(), this)), m_can_ui(Color::Black, Color::White)
: Simulator_base("Can Debugger", com, std::chrono::milliseconds(100), parent), m_if(com->can_if[0].get()),
m_can_ui(Color::Black, Color::White)
{
PUSH_UI_ITEM(m_can_ui);
connect(&m_can_ui, &UI_can::send, this, [=, this](QCanBusFrame frame) { m_wrapper->send_can_message(frame); });
connect(&m_can_ui, &UI_can::send, this, [=, this](QCanBusFrame frame) { m_if->send_frame(frame); });
}
void Can_Debugger::timer()
@@ -18,13 +18,17 @@ void Can_Debugger::timer()
void Can_Debugger::run_at_startup()
{
connect(m_wrapper, &CAN_Wrapper::on_can_message, this,
if (!m_if)
return;
connect(m_if, &CAN_Interface::frame_received, this,
[=, this](QCanBusFrame frame) { this->m_can_ui.add_received_message(frame); });
connect(m_wrapper, &CAN_Wrapper::on_can_send, this,
connect(m_if, &CAN_Interface::frame_send, this,
[=, this](QCanBusFrame frame) { this->m_can_ui.add_send_message(frame); });
}
void Can_Debugger::run_at_stop()
{
disconnect(m_wrapper, nullptr, nullptr, nullptr);
if (!m_if)
return;
disconnect(m_if, nullptr, nullptr, nullptr);
}
+1 -1
View File
@@ -11,6 +11,6 @@ class Can_Debugger : public Simulator_base
void run_at_stop() override;
private:
CAN_Wrapper *m_wrapper;
CAN_Interface *m_if;
UI_can m_can_ui;
};