mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
server
implemented but not tested
This commit is contained in:
@@ -8,6 +8,12 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#define PUSH_UI_ITEM(item) push_ui_item(&item)
|
#define PUSH_UI_ITEM(item) push_ui_item(&item)
|
||||||
|
#define EXPORT_SIM(sim) \
|
||||||
|
extern "C" Q_DECL_EXPORT Simulator_base *get_ui(Communication *com, QObject *parent) \
|
||||||
|
{ \
|
||||||
|
return new sim(com, parent); \
|
||||||
|
}
|
||||||
|
|
||||||
struct Communication
|
struct Communication
|
||||||
{
|
{
|
||||||
CAN_Wrapper *c_if1 = nullptr;
|
CAN_Wrapper *c_if1 = nullptr;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#include "simulators.hpp"
|
#include "simulators.hpp"
|
||||||
|
#include <QDirIterator>
|
||||||
|
#include <QLibrary>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
typedef Simulator_base *(*Get_Sim)(Communication *, QObject *);
|
||||||
|
|
||||||
Simulators::Simulators(uint16_t port, QString can_dev, QString uart_dev, QObject *parent)
|
Simulators::Simulators(uint16_t port, QString can_dev, QString uart_dev, QObject *parent)
|
||||||
: QObject(parent), m_server_thread(new QThread), m_server(new Websocket(port, nullptr)),
|
: QObject(parent), m_server_thread(new QThread), m_server(new Websocket(port, nullptr)),
|
||||||
m_can_wrapper(new CAN_Wrapper(new CAN_Interface(this), this)), m_serial(new QSerialPort(this))
|
m_can_wrapper(new CAN_Wrapper(new CAN_Interface(this), this)), m_serial(new QSerialPort(this))
|
||||||
@@ -28,6 +32,24 @@ Simulators::Simulators(uint16_t port, QString can_dev, QString uart_dev, QObject
|
|||||||
m_com.c_if1 = m_can_wrapper;
|
m_com.c_if1 = m_can_wrapper;
|
||||||
m_com.s_if1 = m_serial;
|
m_com.s_if1 = m_serial;
|
||||||
|
|
||||||
|
QLibrary lib;
|
||||||
|
QDirIterator it(QCoreApplication::applicationDirPath(), QStringList() << "*.so" << "*.dll", QDir::Files,
|
||||||
|
QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
lib.setFileName(it.next());
|
||||||
|
lib.load();
|
||||||
|
auto loaded_ui = Get_Sim(lib.resolve("get_sim"));
|
||||||
|
if (loaded_ui == nullptr)
|
||||||
|
{
|
||||||
|
SPDLOG_INFO("{} NOT FOUND", lib.fileName().toStdString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto widget = loaded_ui(&m_com, this);
|
||||||
|
m_simulators.insert(std::make_pair(widget->name(), widget));
|
||||||
|
lib.unload();
|
||||||
|
}
|
||||||
|
|
||||||
// Insert Debug sims here
|
// Insert Debug sims here
|
||||||
// INSERT_SIMULATOR(TEST_SIM);
|
// INSERT_SIMULATOR(TEST_SIM);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "can_debugger.hpp"
|
#include "can_debugger.hpp"
|
||||||
|
|
||||||
|
EXPORT_SIM(Can_Debugger);
|
||||||
|
|
||||||
Can_Debugger::Can_Debugger(Communication *com, QObject *parent)
|
Can_Debugger::Can_Debugger(Communication *com, QObject *parent)
|
||||||
: Simulator_base("Can Debugger", com, std::chrono::milliseconds(100), parent), m_wrapper(com->c_if1),
|
: Simulator_base("Can Debugger", com, std::chrono::milliseconds(100), parent), m_wrapper(com->c_if1),
|
||||||
m_can_ui(Color::Black, Color::White)
|
m_can_ui(Color::Black, Color::White)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "test_sim.hpp"
|
#include "test_sim.hpp"
|
||||||
|
|
||||||
|
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),
|
: Simulator_base("Test Sim", com, std::chrono::milliseconds(1000), parent),
|
||||||
m_button("Off", Color::White, Color::Red),
|
m_button("Off", Color::White, Color::Red),
|
||||||
|
|||||||
Reference in New Issue
Block a user