From 135a2a03d7aaefe88457f1cf3019d5be727eca98 Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Thu, 29 Jan 2026 20:46:20 +0100 Subject: [PATCH] move can debugger to can if --- server/simulators/can_debugger.cpp | 16 ++++++++++------ server/simulators/can_debugger.hpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/simulators/can_debugger.cpp b/server/simulators/can_debugger.cpp index d48349c..a6a154e 100644 --- a/server/simulators/can_debugger.cpp +++ b/server/simulators/can_debugger.cpp @@ -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); } diff --git a/server/simulators/can_debugger.hpp b/server/simulators/can_debugger.hpp index 338b995..dc8f7fd 100644 --- a/server/simulators/can_debugger.hpp +++ b/server/simulators/can_debugger.hpp @@ -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; };