diff --git a/server/message_parser.cpp b/server/message_parser.cpp index 3dfc110..ef87dd3 100644 --- a/server/message_parser.cpp +++ b/server/message_parser.cpp @@ -1,5 +1,7 @@ +#include "simulator_base.hpp" #include "simulators.hpp" #include +#include QString Simulators::message_parser(QString message) { diff --git a/server/simulators.cpp b/server/simulators.cpp index 5dc5455..2c9f6f9 100644 --- a/server/simulators.cpp +++ b/server/simulators.cpp @@ -1,13 +1,18 @@ #include "simulators.hpp" +#include "CAN_wrapper.hpp" +#include "simulator_base.hpp" +#include "websocket.hpp" #include #include +#include #include typedef Simulator_base *(*Get_Sim)(Communication *, QObject *); 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)), - 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)), + m_com(new Communication) { m_server->moveToThread(m_server_thread); m_server_thread->start(); @@ -29,8 +34,8 @@ Simulators::Simulators(uint16_t port, QString can_dev, QString uart_dev, QObject SPDLOG_CRITICAL("Error {}", m_serial->errorString().toStdString()); } } - m_com.c_if1 = m_can_wrapper; - m_com.s_if1 = m_serial; + m_com->c_if1 = m_can_wrapper; + m_com->s_if1 = m_serial; QLibrary lib; QDirIterator it(QCoreApplication::applicationDirPath(), QStringList() << "*.so" << "*.dll", QDir::Files, @@ -46,7 +51,7 @@ Simulators::Simulators(uint16_t port, QString can_dev, QString uart_dev, QObject lib.unload(); continue; } - auto widget = loaded_sim(&m_com, this); + auto widget = loaded_sim(m_com, this); m_simulators.insert(std::make_pair(widget->name(), widget)); lib.unload(); } diff --git a/server/simulators.hpp b/server/simulators.hpp index 3c481c8..00b5a9e 100644 --- a/server/simulators.hpp +++ b/server/simulators.hpp @@ -1,16 +1,22 @@ #pragma once -#include +#include #include #include #include - -#include "CAN_wrapper.hpp" -#include "simulator_base.hpp" -#include "websocket.hpp" +#include #define INSERT_SIMULATOR(type) \ m_simulators.insert(std::make_pair(type(&m_com).name(), std::make_unique(&m_com, this))); +Q_FORWARD_DECLARE_OBJC_CLASS(QThread); +Q_FORWARD_DECLARE_OBJC_CLASS(Websocket); +Q_FORWARD_DECLARE_OBJC_CLASS(CAN_Wrapper); +Q_FORWARD_DECLARE_OBJC_CLASS(QSerialPort); +Q_FORWARD_DECLARE_OBJC_CLASS(Simulator_base); +Q_FORWARD_DECLARE_OBJC_CLASS(Communication); + +using json = nlohmann::json; + class Simulators : public QObject { Q_OBJECT @@ -59,7 +65,7 @@ class Simulators : public QObject Websocket *m_server; CAN_Wrapper *m_can_wrapper; QSerialPort *m_serial; - Communication m_com; + Communication *m_com; std::map> m_simulators; std::string m_current_simulator = ""; std::mutex m_mutex;