simulators

Move websocket to thread
This commit is contained in:
2026-02-14 14:30:52 +01:00
parent 2e6bcce589
commit 63d6ff460b
2 changed files with 8 additions and 2 deletions
+6 -2
View File
@@ -1,11 +1,15 @@
#include "simulators.hpp" #include "simulators.hpp"
#include "can_debugger.hpp" #include "can_debugger.hpp"
#include "test_sim.hpp" #include "test_sim.hpp"
#include <QDebug>
#include <unordered_set> #include <unordered_set>
Simulators::Simulators(uint16_t port, QObject *parent) : QObject(parent), m_server(new Websocket(port, this)) Simulators::Simulators(uint16_t port, QString can_dev, QObject *parent)
: QObject(parent), m_server_thread(new QThread), m_server(new Websocket(port, parent)),
m_can_wrapper(new CAN_Wrapper(new CAN_Interface(can_dev, parent), parent))
{ {
m_server->moveToThread(m_server_thread);
m_server_thread->start();
INSERT_SIMULATOR(Test_Sim); INSERT_SIMULATOR(Test_Sim);
INSERT_SIMULATOR(Can_Debugger); INSERT_SIMULATOR(Can_Debugger);
+2
View File
@@ -1,4 +1,5 @@
#pragma once #pragma once
#include <QThread>
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
@@ -52,6 +53,7 @@ class Simulators : public QObject
void event_handler(json event); void event_handler(json event);
private: private:
QThread *m_server_thread;
Websocket *m_server; Websocket *m_server;
std::map<std::string, std::unique_ptr<Simulator_base>> m_simulators; std::map<std::string, std::unique_ptr<Simulator_base>> m_simulators;
std::string m_current_simulator = ""; std::string m_current_simulator = "";