mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
client
rename Simulator_base to UI_base this is so that doxygen can see the difference
This commit is contained in:
@@ -16,8 +16,8 @@ set(PROJECT_SOURCES
|
|||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
mainwindow.hpp
|
mainwindow.hpp
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
simulator_base.cpp
|
ui_base.cpp
|
||||||
simulator_base.hpp
|
ui_base.hpp
|
||||||
web_socket_wrapper.cpp
|
web_socket_wrapper.cpp
|
||||||
web_socket_wrapper.hpp
|
web_socket_wrapper.hpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
#include "simulator_base.hpp"
|
#include "ui_base.hpp"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "web_socket_wrapper.hpp"
|
#include "web_socket_wrapper.hpp"
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
|
|
||||||
typedef Simulator_base *(*Get_UI)(Web_socket_wrapper *, QWidget *);
|
typedef UI_base *(*Get_UI)(Web_socket_wrapper *, QWidget *);
|
||||||
|
|
||||||
MainWindow::MainWindow(QUrl ws_url, QString sim, QWidget *parent)
|
MainWindow::MainWindow(QUrl ws_url, QString sim, QWidget *parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow), m_error(new QMessageBox()),
|
: QMainWindow(parent), ui(new Ui::MainWindow), m_error(new QMessageBox()),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using json = nlohmann::json;
|
|||||||
|
|
||||||
Q_FORWARD_DECLARE_OBJC_CLASS(QMessageBox);
|
Q_FORWARD_DECLARE_OBJC_CLASS(QMessageBox);
|
||||||
Q_FORWARD_DECLARE_OBJC_CLASS(Web_socket_wrapper);
|
Q_FORWARD_DECLARE_OBJC_CLASS(Web_socket_wrapper);
|
||||||
Q_FORWARD_DECLARE_OBJC_CLASS(Simulator_base);
|
Q_FORWARD_DECLARE_OBJC_CLASS(UI_base);
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@@ -44,5 +44,5 @@ class MainWindow : public QMainWindow
|
|||||||
QMessageBox *m_error;
|
QMessageBox *m_error;
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
std::unique_ptr<Web_socket_wrapper> m_web_socket;
|
std::unique_ptr<Web_socket_wrapper> m_web_socket;
|
||||||
std::map<QString, std::unique_ptr<Simulator_base>> m_sims;
|
std::map<QString, std::unique_ptr<UI_base>> m_sims;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
EXPORT_UI(Can_Debugger);
|
EXPORT_UI(Can_Debugger);
|
||||||
|
|
||||||
Can_Debugger::Can_Debugger(Web_socket_wrapper *web_socket, QWidget *parent)
|
Can_Debugger::Can_Debugger(Web_socket_wrapper *web_socket, QWidget *parent)
|
||||||
: Simulator_base("Can Debugger", web_socket, parent), ui(new Ui::Can_Debugger)
|
: UI_base("Can Debugger", web_socket, parent), ui(new Ui::Can_Debugger)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "simulator_base.hpp"
|
#include "ui_base.hpp"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class Can_Debugger;
|
class Can_Debugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Can_Debugger : public Simulator_base
|
class Can_Debugger : public UI_base
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
EXPORT_UI(Test_Sim);
|
EXPORT_UI(Test_Sim);
|
||||||
|
|
||||||
Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
|
Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
|
||||||
: Simulator_base("Test Sim", web_socket, parent), ui(new Ui::Test_Sim)
|
: UI_base("Test Sim", web_socket, parent), ui(new Ui::Test_Sim)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "simulator_base.hpp"
|
#include "ui_base.hpp"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class Test_Sim;
|
class Test_Sim;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Test_Sim : public Simulator_base
|
class Test_Sim : public UI_base
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "simulator_base.hpp"
|
#include "ui_base.hpp"
|
||||||
#include "can_transceive.hpp"
|
#include "can_transceive.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "led.hpp"
|
#include "led.hpp"
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
|
|
||||||
Simulator_base::Simulator_base(QString name, Web_socket_wrapper *web_socket, QWidget *parent)
|
UI_base::UI_base(QString name, Web_socket_wrapper *web_socket, QWidget *parent)
|
||||||
: QMainWindow{parent}, m_timer_update(new QTimer()), m_error(new QMessageBox(this)), m_web_socket(web_socket),
|
: QMainWindow{parent}, m_timer_update(new QTimer()), m_error(new QMessageBox(this)), m_web_socket(web_socket),
|
||||||
m_name(name)
|
m_name(name)
|
||||||
{
|
{
|
||||||
@@ -22,17 +22,17 @@ Simulator_base::Simulator_base(QString name, Web_socket_wrapper *web_socket, QWi
|
|||||||
connect(exit_app, &QPushButton::clicked, this, &QCoreApplication::quit, Qt::QueuedConnection);
|
connect(exit_app, &QPushButton::clicked, this, &QCoreApplication::quit, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *Simulator_base::id_to_ui(size_t id)
|
QWidget *UI_base::id_to_ui(size_t id)
|
||||||
{
|
{
|
||||||
return m_ui_lookup.at(id);
|
return m_ui_lookup.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Simulator_base::name() const
|
QString UI_base::name() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::showEvent(QShowEvent *event)
|
void UI_base::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
setWindowTitle(m_name);
|
setWindowTitle(m_name);
|
||||||
@@ -49,7 +49,7 @@ void Simulator_base::showEvent(QShowEvent *event)
|
|||||||
m_open = true;
|
m_open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::closeEvent(QCloseEvent *event)
|
void UI_base::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::closeEvent(event);
|
QWidget::closeEvent(event);
|
||||||
if (m_open == true)
|
if (m_open == true)
|
||||||
@@ -62,7 +62,7 @@ void Simulator_base::closeEvent(QCloseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::on_cmd_cb(json &j)
|
void UI_base::on_cmd_cb(json &j)
|
||||||
{
|
{
|
||||||
auto response = magic_enum::enum_cast<Web_socket_wrapper::Command>(std::string(j.at("type")))
|
auto response = magic_enum::enum_cast<Web_socket_wrapper::Command>(std::string(j.at("type")))
|
||||||
.value_or(Web_socket_wrapper::Command::end);
|
.value_or(Web_socket_wrapper::Command::end);
|
||||||
@@ -82,7 +82,7 @@ void Simulator_base::on_cmd_cb(json &j)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::on_event_cb(json &j)
|
void UI_base::on_event_cb(json &j)
|
||||||
{
|
{
|
||||||
auto response = magic_enum::enum_cast<Web_socket_wrapper::Event>(std::string(j.at("type")))
|
auto response = magic_enum::enum_cast<Web_socket_wrapper::Event>(std::string(j.at("type")))
|
||||||
.value_or(Web_socket_wrapper::Event::end);
|
.value_or(Web_socket_wrapper::Event::end);
|
||||||
@@ -96,13 +96,13 @@ void Simulator_base::on_event_cb(json &j)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::push_ui_item(QWidget *item)
|
void UI_base::push_ui_item(QWidget *item)
|
||||||
{
|
{
|
||||||
m_ui_lookup.emplace_back(item);
|
m_ui_lookup.emplace_back(item);
|
||||||
setup_ui_item(item, m_ui_lookup.size() - 1);
|
setup_ui_item(item, m_ui_lookup.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::UI_item_parser(json &input)
|
void UI_base::UI_item_parser(json &input)
|
||||||
{
|
{
|
||||||
for (auto &ui_item : input.at("UI_items"))
|
for (auto &ui_item : input.at("UI_items"))
|
||||||
{
|
{
|
||||||
@@ -211,7 +211,7 @@ void Simulator_base::UI_item_parser(json &input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_label(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_label(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto label = qobject_cast<QLabel *>(widget);
|
auto label = qobject_cast<QLabel *>(widget);
|
||||||
if (label == nullptr)
|
if (label == nullptr)
|
||||||
@@ -240,7 +240,7 @@ void Simulator_base::process_ui_label(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_slider(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_slider(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ void Simulator_base::process_ui_slider(json &ui_item, QWidget *widget)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_dial(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_dial(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ void Simulator_base::process_ui_dial(json &ui_item, QWidget *widget)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_thermo(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_thermo(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||||
|
|
||||||
@@ -343,12 +343,12 @@ void Simulator_base::process_ui_thermo(json &ui_item, QWidget *widget)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_textbox(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_textbox(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
SPDLOG_CRITICAL("Not implemented");
|
SPDLOG_CRITICAL("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_combobox(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_combobox(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto combobox = qobject_cast<QComboBox *>(widget);
|
auto combobox = qobject_cast<QComboBox *>(widget);
|
||||||
if (combobox == nullptr)
|
if (combobox == nullptr)
|
||||||
@@ -383,12 +383,12 @@ void Simulator_base::process_ui_combobox(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_radiobutton(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_radiobutton(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
SPDLOG_CRITICAL("Not implemented");
|
SPDLOG_CRITICAL("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_checkbox(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_checkbox(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto checkbox = qobject_cast<QCheckBox *>(widget);
|
auto checkbox = qobject_cast<QCheckBox *>(widget);
|
||||||
if (checkbox == nullptr)
|
if (checkbox == nullptr)
|
||||||
@@ -454,7 +454,7 @@ void Simulator_base::process_ui_checkbox(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_button(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_button(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto button = qobject_cast<QPushButton *>(widget);
|
auto button = qobject_cast<QPushButton *>(widget);
|
||||||
if (button == nullptr)
|
if (button == nullptr)
|
||||||
@@ -514,7 +514,7 @@ void Simulator_base::process_ui_button(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_led(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_led(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto led = qobject_cast<Led *>(widget);
|
auto led = qobject_cast<Led *>(widget);
|
||||||
if (led == nullptr)
|
if (led == nullptr)
|
||||||
@@ -568,7 +568,7 @@ void Simulator_base::process_ui_led(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_spinbox(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_spinbox(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto spinbox = qobject_cast<QSpinBox *>(widget);
|
auto spinbox = qobject_cast<QSpinBox *>(widget);
|
||||||
if (spinbox == nullptr)
|
if (spinbox == nullptr)
|
||||||
@@ -607,7 +607,7 @@ void Simulator_base::process_ui_spinbox(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_double_spinbox(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_double_spinbox(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto spinbox = qobject_cast<QDoubleSpinBox *>(widget);
|
auto spinbox = qobject_cast<QDoubleSpinBox *>(widget);
|
||||||
if (spinbox == nullptr)
|
if (spinbox == nullptr)
|
||||||
@@ -646,7 +646,7 @@ void Simulator_base::process_ui_double_spinbox(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_hex_spinbox(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_hex_spinbox(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto spinbox = qobject_cast<HexSpinBox *>(widget);
|
auto spinbox = qobject_cast<HexSpinBox *>(widget);
|
||||||
if (spinbox == nullptr)
|
if (spinbox == nullptr)
|
||||||
@@ -685,7 +685,7 @@ void Simulator_base::process_ui_hex_spinbox(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_tab_widget(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_tab_widget(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto tab_widget = qobject_cast<QTabWidget *>(widget);
|
auto tab_widget = qobject_cast<QTabWidget *>(widget);
|
||||||
if (tab_widget == nullptr)
|
if (tab_widget == nullptr)
|
||||||
@@ -732,7 +732,7 @@ void Simulator_base::process_ui_tab_widget(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_stacked_widget(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_stacked_widget(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto stacked_widget = qobject_cast<QStackedWidget *>(widget);
|
auto stacked_widget = qobject_cast<QStackedWidget *>(widget);
|
||||||
if (stacked_widget == nullptr)
|
if (stacked_widget == nullptr)
|
||||||
@@ -766,7 +766,7 @@ void Simulator_base::process_ui_stacked_widget(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_status_bar(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_status_bar(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto status_bar = qobject_cast<QStatusBar *>(widget);
|
auto status_bar = qobject_cast<QStatusBar *>(widget);
|
||||||
if (status_bar == nullptr)
|
if (status_bar == nullptr)
|
||||||
@@ -781,7 +781,7 @@ void Simulator_base::process_ui_status_bar(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_plot(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_plot(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto plot = qobject_cast<Plot_wrapper *>(widget);
|
auto plot = qobject_cast<Plot_wrapper *>(widget);
|
||||||
if (plot == nullptr)
|
if (plot == nullptr)
|
||||||
@@ -843,7 +843,7 @@ void Simulator_base::process_ui_plot(json &ui_item, QWidget *widget)
|
|||||||
plot->replot();
|
plot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_table(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_table(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto table = qobject_cast<QTableWidget *>(widget);
|
auto table = qobject_cast<QTableWidget *>(widget);
|
||||||
if (table == nullptr)
|
if (table == nullptr)
|
||||||
@@ -908,7 +908,7 @@ void Simulator_base::process_ui_table(json &ui_item, QWidget *widget)
|
|||||||
table->resizeColumnsToContents();
|
table->resizeColumnsToContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::process_ui_can(json &ui_item, QWidget *widget)
|
void UI_base::process_ui_can(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
auto can_ui = qobject_cast<Can_Transceive *>(widget);
|
auto can_ui = qobject_cast<Can_Transceive *>(widget);
|
||||||
if (can_ui == nullptr)
|
if (can_ui == nullptr)
|
||||||
@@ -929,7 +929,7 @@ void Simulator_base::process_ui_can(json &ui_item, QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_ui_item(QWidget *item, size_t index)
|
void UI_base::setup_ui_item(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
setup_button(item, index);
|
setup_button(item, index);
|
||||||
setup_combobox(item, index);
|
setup_combobox(item, index);
|
||||||
@@ -943,7 +943,7 @@ void Simulator_base::setup_ui_item(QWidget *item, size_t index)
|
|||||||
setup_can_ui(item, index);
|
setup_can_ui(item, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_button(QWidget *item, size_t index)
|
void UI_base::setup_button(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QPushButton *button = qobject_cast<QPushButton *>(item);
|
QPushButton *button = qobject_cast<QPushButton *>(item);
|
||||||
if (button == nullptr)
|
if (button == nullptr)
|
||||||
@@ -952,7 +952,7 @@ void Simulator_base::setup_button(QWidget *item, size_t index)
|
|||||||
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, index); });
|
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, index); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_combobox(QWidget *item, size_t index)
|
void UI_base::setup_combobox(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QComboBox *combobox = qobject_cast<QComboBox *>(item);
|
QComboBox *combobox = qobject_cast<QComboBox *>(item);
|
||||||
if (combobox == nullptr)
|
if (combobox == nullptr)
|
||||||
@@ -963,7 +963,7 @@ void Simulator_base::setup_combobox(QWidget *item, size_t index)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_checkbox(QWidget *item, size_t index)
|
void UI_base::setup_checkbox(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QCheckBox *checkbox = qobject_cast<QCheckBox *>(item);
|
QCheckBox *checkbox = qobject_cast<QCheckBox *>(item);
|
||||||
if (checkbox == nullptr)
|
if (checkbox == nullptr)
|
||||||
@@ -973,7 +973,7 @@ void Simulator_base::setup_checkbox(QWidget *item, size_t index)
|
|||||||
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, index); });
|
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, index); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_dial(QWidget *item, size_t index)
|
void UI_base::setup_dial(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QwtDial *dial = qobject_cast<QwtDial *>(item);
|
QwtDial *dial = qobject_cast<QwtDial *>(item);
|
||||||
if (dial == nullptr)
|
if (dial == nullptr)
|
||||||
@@ -982,7 +982,7 @@ void Simulator_base::setup_dial(QWidget *item, size_t index)
|
|||||||
create_dial_needle(dial);
|
create_dial_needle(dial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_slider(QWidget *item, size_t index)
|
void UI_base::setup_slider(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QwtSlider *slider = qobject_cast<QwtSlider *>(item);
|
QwtSlider *slider = qobject_cast<QwtSlider *>(item);
|
||||||
if (slider == nullptr)
|
if (slider == nullptr)
|
||||||
@@ -992,7 +992,7 @@ void Simulator_base::setup_slider(QWidget *item, size_t index)
|
|||||||
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, index, slider->value()); });
|
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, index, slider->value()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_spinbox(QWidget *item, size_t index)
|
void UI_base::setup_spinbox(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QSpinBox *spinbox = qobject_cast<QSpinBox *>(item);
|
QSpinBox *spinbox = qobject_cast<QSpinBox *>(item);
|
||||||
if (spinbox == nullptr)
|
if (spinbox == nullptr)
|
||||||
@@ -1003,7 +1003,7 @@ void Simulator_base::setup_spinbox(QWidget *item, size_t index)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_double_spinbox(QWidget *item, size_t index)
|
void UI_base::setup_double_spinbox(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QDoubleSpinBox *spinbox = qobject_cast<QDoubleSpinBox *>(item);
|
QDoubleSpinBox *spinbox = qobject_cast<QDoubleSpinBox *>(item);
|
||||||
if (spinbox == nullptr)
|
if (spinbox == nullptr)
|
||||||
@@ -1014,7 +1014,7 @@ void Simulator_base::setup_double_spinbox(QWidget *item, size_t index)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_hex_spinbox(QWidget *item, size_t index)
|
void UI_base::setup_hex_spinbox(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
HexSpinBox *spinbox = qobject_cast<HexSpinBox *>(item);
|
HexSpinBox *spinbox = qobject_cast<HexSpinBox *>(item);
|
||||||
if (spinbox == nullptr)
|
if (spinbox == nullptr)
|
||||||
@@ -1025,7 +1025,7 @@ void Simulator_base::setup_hex_spinbox(QWidget *item, size_t index)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_tab_widget(QWidget *item, size_t index)
|
void UI_base::setup_tab_widget(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
QTabWidget *tab_widget = qobject_cast<QTabWidget *>(item);
|
QTabWidget *tab_widget = qobject_cast<QTabWidget *>(item);
|
||||||
if (tab_widget == nullptr)
|
if (tab_widget == nullptr)
|
||||||
@@ -1036,7 +1036,7 @@ void Simulator_base::setup_tab_widget(QWidget *item, size_t index)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulator_base::setup_can_ui(QWidget *item, size_t index)
|
void UI_base::setup_can_ui(QWidget *item, size_t index)
|
||||||
{
|
{
|
||||||
Can_Transceive *can = qobject_cast<Can_Transceive *>(item);
|
Can_Transceive *can = qobject_cast<Can_Transceive *>(item);
|
||||||
if (can == nullptr)
|
if (can == nullptr)
|
||||||
@@ -13,16 +13,16 @@ using json = nlohmann::json;
|
|||||||
|
|
||||||
#define PUSH_UI_ITEM(item) push_ui_item(ui->item)
|
#define PUSH_UI_ITEM(item) push_ui_item(ui->item)
|
||||||
#define EXPORT_UI(client) \
|
#define EXPORT_UI(client) \
|
||||||
extern "C" Q_DECL_EXPORT Simulator_base *get_ui(Web_socket_wrapper *api, QWidget *parent) \
|
extern "C" Q_DECL_EXPORT UI_base *get_ui(Web_socket_wrapper *api, QWidget *parent) \
|
||||||
{ \
|
{ \
|
||||||
return new client(api, parent); \
|
return new client(api, parent); \
|
||||||
}
|
}
|
||||||
|
|
||||||
class Simulator_base : public QMainWindow
|
class UI_base : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Simulator_base(QString name, Web_socket_wrapper *api, QWidget *parent = nullptr);
|
explicit UI_base(QString name, Web_socket_wrapper *api, QWidget *parent = nullptr);
|
||||||
void sim_update(void);
|
void sim_update(void);
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QWidget *id_to_ui(size_t id);
|
QWidget *id_to_ui(size_t id);
|
||||||
+3
-3
@@ -14,14 +14,14 @@ To create a new simulator ui follow these steps
|
|||||||
OPTIONAL Add id_to_label is optional if you want to use value labels
|
OPTIONAL Add id_to_label is optional if you want to use value labels
|
||||||
```cpp
|
```cpp
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "simulator_base.hpp"
|
#include "ui_base.hpp"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class Test_Sim;
|
class Test_Sim;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Test_Sim : public Simulator_base
|
class Test_Sim : public UI_base
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ OPTIONAL Add id_to_label is optional if you want to use value labels switch case
|
|||||||
EXPORT_UI(Test_Sim);
|
EXPORT_UI(Test_Sim);
|
||||||
|
|
||||||
Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
|
Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
|
||||||
: Simulator_base("Test Sim", web_socket, parent), ui(new Ui::Test_Sim)
|
: UI_base("Test Sim", web_socket, parent), ui(new Ui::Test_Sim)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ To create a simulator server follow these steps
|
|||||||
2. Right click on unisim_server and select Add new
|
2. Right click on unisim_server and select Add new
|
||||||
3. Choose C/C++ in files and classes and then select C++ class + Choose
|
3. Choose C/C++ in files and classes and then select C++ class + Choose
|
||||||
4. Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter
|
4. Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter
|
||||||
5. Set as base Simulator_base and check "Add Q_Object"
|
5. Set as base UI_base and check "Add Q_Object"
|
||||||
6. Select the path by clicking browse and make sure it is in the server/simulators folder + Next
|
6. Select the path by clicking browse and make sure it is in the server/simulators folder + Next
|
||||||
7. Set add to project to None + Finish
|
7. Set add to project to None + Finish
|
||||||
8. Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as sim_ + filename
|
8. Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as sim_ + filename
|
||||||
@@ -41,7 +41,7 @@ class Test_Sim : public Simulator_base
|
|||||||
EXPORT_SIM(Test_Sim);
|
EXPORT_SIM(Test_Sim);
|
||||||
|
|
||||||
Test_Sim::Test_Sim(Communication *com, QObject *parent)
|
Test_Sim::Test_Sim(Communication *com, QObject *parent)
|
||||||
: Simulator_base("Test Sim", com, std::chrono::milliseconds(1000), parent),
|
: UI_base("Test Sim", com, std::chrono::milliseconds(1000), parent),
|
||||||
// Put you're variable constructors here
|
// Put you're variable constructors here
|
||||||
m_button("Off", Color::White, Color::Red)
|
m_button("Off", Color::White, Color::Red)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user