mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
CAN debuger
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
#include "can_debugger.hpp"
|
||||
#include <iostream>
|
||||
|
||||
Can_Debugger::Can_Debugger() :
|
||||
Simulator_base("Can_Debugger")
|
||||
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),
|
||||
m_clear_can_list("Clear list", Color::Black, Color::White)
|
||||
{
|
||||
//this->add_UI_item(&this->);
|
||||
this->add_UI_item(&this->m_can_ui);
|
||||
this->add_UI_item(&this->m_clear_can_list);
|
||||
|
||||
connect(&m_clear_can_list, &UI_button::on_click, this, [=, this]{this->m_can_ui.clear_send_buffer(); this->m_can_ui.clear_receive_buffer();});
|
||||
connect(&m_can_ui, &UI_can::on_send, this, [=, this](QCanBusFrame frame){m_wrapper->send_can_message(frame);});
|
||||
}
|
||||
|
||||
void Can_Debugger::timer()
|
||||
@@ -14,5 +20,11 @@ void Can_Debugger::timer()
|
||||
|
||||
void Can_Debugger::run_at_startup()
|
||||
{
|
||||
// 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);});
|
||||
}
|
||||
|
||||
void Can_Debugger::run_at_stop()
|
||||
{
|
||||
disconnect(m_wrapper, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ class Can_Debugger : public Simulator_base {
|
||||
Can_Debugger();
|
||||
void timer() override;
|
||||
void run_at_startup() override;
|
||||
void run_at_stop() override;
|
||||
private:
|
||||
|
||||
CAN_Wrapper* m_wrapper;
|
||||
UI_can m_can_ui;
|
||||
UI_button m_clear_can_list;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user