mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Move sims to a separate folder
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
#include "sim-test.h"
|
||||
#include "ui_sim-test.h"
|
||||
|
||||
Test_Sim::Test_Sim(Web_socket_wrapper* web_socket, QWidget* parent) :
|
||||
SimulatorBase(web_socket, parent),
|
||||
ui(new Ui::Test_Sim)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle("Test Sim");
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
|
||||
button_lookup = {
|
||||
{button_lookup_e::button, ui->button}
|
||||
};
|
||||
slider_lookup = {
|
||||
{slider_lookup_e::slider, ui->slider}
|
||||
};
|
||||
dial_lookup = {
|
||||
{dial_lookup_e::dial, ui->dial}
|
||||
};
|
||||
thermo_lookup = {
|
||||
{thermo_lookup_e::thermo, ui->thermo}
|
||||
};
|
||||
led_lookup = {
|
||||
{led_lookup_e::led, ui->led}
|
||||
};
|
||||
combobox_lookup = {
|
||||
{combobox_lookup_e::combobox, ui->combobox}
|
||||
};
|
||||
label_lookup = {
|
||||
{label_lookup_e::label, ui->label}
|
||||
};
|
||||
|
||||
setup_buttons();
|
||||
setup_comboboxes();
|
||||
setup_sliders();
|
||||
setup_dials();
|
||||
}
|
||||
|
||||
Test_Sim::~Test_Sim() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Test_Sim::setup_buttons(void)
|
||||
{
|
||||
for (Iterable<button_lookup_e> lookup; lookup < button_lookup_e::end; lookup++)
|
||||
{
|
||||
switch (lookup)
|
||||
{
|
||||
default:
|
||||
connect(button_lookup[lookup], &QPushButton::clicked, this, [=]{button_update(lookup);});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Test_Sim::setup_sliders(void)
|
||||
{
|
||||
for (Iterable<slider_lookup_e> lookup; lookup < slider_lookup_e::end; lookup++)
|
||||
{
|
||||
connect(slider_lookup[lookup], &QwtSlider::sliderMoved, this, [=]{
|
||||
//value_lookup_e lookup_v = thermo_to_value_lookup(lookup);
|
||||
//value_lookup[lookup_v]->setText(format_value(lookup_v, thermo_lookup[lookup]->value()));
|
||||
slider_update(lookup);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Test_Sim::setup_comboboxes(void)
|
||||
{
|
||||
for (Iterable<combobox_lookup_e> lookup; lookup < combobox_lookup_e::end; lookup++)
|
||||
{
|
||||
connect(combobox_lookup[lookup], &QComboBox::currentIndexChanged, this, [=]{combobox_update(lookup);});
|
||||
}
|
||||
}
|
||||
|
||||
void Test_Sim::setup_dials(void)
|
||||
{
|
||||
for (Iterable<dial_lookup_e> lookup; lookup < dial_lookup_e::end; lookup++)
|
||||
{
|
||||
create_dial_needle(dial_lookup[lookup]);
|
||||
}
|
||||
}
|
||||
|
||||
void Test_Sim::button_update(button_lookup_e lookup)
|
||||
{
|
||||
m_web_socket->send_event(Web_socket_wrapper::Event::clicked, QString(magic_enum::enum_name(lookup).data()));
|
||||
}
|
||||
|
||||
void Test_Sim::slider_update(slider_lookup_e lookup)
|
||||
{
|
||||
m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, QString(magic_enum::enum_name(lookup).data()),
|
||||
slider_lookup[lookup]->value());
|
||||
}
|
||||
|
||||
void Test_Sim::combobox_update(combobox_lookup_e lookup)
|
||||
{
|
||||
m_web_socket->send_event(Web_socket_wrapper::Event::selected, QString(magic_enum::enum_name(lookup).data()),
|
||||
combobox_lookup[lookup]->currentText());
|
||||
}
|
||||
|
||||
QLabel* Test_Sim::id_to_label(QString name)
|
||||
{
|
||||
label_lookup_e lookup = magic_enum::enum_cast<label_lookup_e>(name.toStdString()).value_or(label_lookup_e::end);
|
||||
if (lookup == label_lookup_e::end)
|
||||
{
|
||||
QD << "label lookup == end, instead of " << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return label_lookup[lookup];
|
||||
}
|
||||
|
||||
QPushButton* Test_Sim::id_to_led(QString name)
|
||||
{
|
||||
led_lookup_e lookup = magic_enum::enum_cast<led_lookup_e>(name.toStdString()).value_or(led_lookup_e::end);
|
||||
if (lookup == led_lookup_e::end)
|
||||
{
|
||||
QD << "led lookup == end, instead of " << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return led_lookup[lookup];
|
||||
}
|
||||
|
||||
QPushButton* Test_Sim::id_to_button(QString name)
|
||||
{
|
||||
button_lookup_e lookup = magic_enum::enum_cast<button_lookup_e>(name.toStdString()).value_or(button_lookup_e::end);
|
||||
if (lookup == button_lookup_e::end)
|
||||
{
|
||||
QD << "button lookup == end, instead of" << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return button_lookup[lookup];
|
||||
}
|
||||
|
||||
QwtSlider* Test_Sim::id_to_slider(QString name)
|
||||
{
|
||||
slider_lookup_e lookup = magic_enum::enum_cast<slider_lookup_e>(name.toStdString()).value_or(slider_lookup_e::end);
|
||||
if (lookup == slider_lookup_e::end)
|
||||
{
|
||||
QD << "slider lookup == end, instead of " << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return slider_lookup[lookup];
|
||||
}
|
||||
|
||||
QLabel* Test_Sim::id_to_slider_label(QString name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString Test_Sim::format_slider_value(QString name, double val)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
QwtDial* Test_Sim::id_to_dial(QString name)
|
||||
{
|
||||
dial_lookup_e lookup = magic_enum::enum_cast<dial_lookup_e>(name.toStdString()).value_or(dial_lookup_e::end);
|
||||
if (lookup == dial_lookup_e::end)
|
||||
{
|
||||
QD << "dial lookup == end, instead of " << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return dial_lookup[lookup];
|
||||
}
|
||||
|
||||
QwtThermo* Test_Sim::id_to_thermo(QString name)
|
||||
{
|
||||
thermo_lookup_e lookup = magic_enum::enum_cast<thermo_lookup_e>(name.toStdString()).value_or(thermo_lookup_e::end);
|
||||
if (lookup == thermo_lookup_e::end)
|
||||
{
|
||||
QD << "thermo lookup == end, instead of " << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return thermo_lookup[lookup];
|
||||
}
|
||||
|
||||
QComboBox* Test_Sim::id_to_combobox(QString name)
|
||||
{
|
||||
combobox_lookup_e lookup = magic_enum::enum_cast<combobox_lookup_e>(name.toStdString()).value_or(combobox_lookup_e::end);
|
||||
if (lookup == combobox_lookup_e::end)
|
||||
{
|
||||
QD << "combobox lookup == end, instead of " << name;
|
||||
emit quit();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return combobox_lookup[lookup];
|
||||
}
|
||||
Reference in New Issue
Block a user