mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Fix rebase errors
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#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),
|
||||
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);});
|
||||
}
|
||||
|
||||
void Can_Debugger::timer()
|
||||
{
|
||||
// Timer function
|
||||
}
|
||||
|
||||
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);});
|
||||
}
|
||||
|
||||
void Can_Debugger::run_at_stop()
|
||||
{
|
||||
disconnect(m_wrapper, nullptr, nullptr, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "simulator_base.hpp"
|
||||
|
||||
class Can_Debugger : public Simulator_base {
|
||||
Q_OBJECT
|
||||
public:
|
||||
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;
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "test_sim.hpp"
|
||||
|
||||
Test_Sim::Test_Sim(QObject* parent) :
|
||||
Simulator_base("Test_Sim", std::chrono::milliseconds(1000), parent),
|
||||
m_button("Off", Color(Color::White), Color(Color::Red)),
|
||||
m_combobox(Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0),
|
||||
m_label("Label", Color(Color::White), Color(Color::Black)),
|
||||
m_checkbox("Option 1", Color(Color::White), Color(Color::Black)),
|
||||
m_slider("Slider", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_dial("Dial", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_thermo("Thermo", "%", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_led("Led", Color(Color::White), Color(Color::Black), Color(Color::Red))
|
||||
{
|
||||
this->m_thermo.set_start_color(Color(Color::Red));
|
||||
this->m_thermo.set_end_color(Color(Color::Red));
|
||||
this->m_thermo.add_color_stop(0.10, Color(Color::Yellow));
|
||||
this->m_thermo.add_color_stop(0.50, Color(Color::Green));
|
||||
this->m_thermo.add_color_stop(0.60, Color(Color::Yellow));
|
||||
this->m_thermo.add_color_stop(0.90, Color(Color::Red));
|
||||
|
||||
this->add_UI_item(&this->m_button);
|
||||
this->add_UI_item(&this->m_combobox);
|
||||
this->add_UI_item(&this->m_label);
|
||||
this->add_UI_item(&this->m_slider);
|
||||
this->add_UI_item(&this->m_dial);
|
||||
this->add_UI_item(&this->m_thermo);
|
||||
this->add_UI_item(&this->m_led);
|
||||
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); });
|
||||
}
|
||||
|
||||
void Test_Sim::timer()
|
||||
{
|
||||
this->m_button.click();
|
||||
if (this->m_slider.value() == this->m_slider.max())
|
||||
{
|
||||
this->m_slider.set_value(0);
|
||||
}
|
||||
this->m_slider.set_value(this->m_slider.value() + 1);
|
||||
}
|
||||
|
||||
void Test_Sim::run_at_startup()
|
||||
{
|
||||
// Run at startup
|
||||
spdlog::info("Test_Sim started");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (id == &this->m_slider)
|
||||
{
|
||||
spdlog::info("Test slider changed to {}", value);
|
||||
this->m_label.set_text(std::to_string(value));
|
||||
this->m_dial.set_value(value);
|
||||
this->m_thermo.set_value(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "simulator_base.hpp"
|
||||
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user