mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
Move to Qt
Everything seems to be working Only timer is not moved over
This commit is contained in:
+23
-2
@@ -2,11 +2,26 @@
|
||||
#include "can_debugger.hpp"
|
||||
#include "test_sim.hpp"
|
||||
#include <unordered_set>
|
||||
#include <QDebug>
|
||||
|
||||
Simulators::Simulators()
|
||||
Simulators::Simulators(uint16_t port, QObject* parrent) :
|
||||
QObject(parrent),
|
||||
m_server(new Websocket(port, this))
|
||||
{
|
||||
qDebug() << port;
|
||||
INSERT_SIMULATOR(Test_Sim);
|
||||
INSERT_SIMULATOR(Can_Debugger);
|
||||
setup_connections();
|
||||
}
|
||||
|
||||
void Simulators::setup_connections()
|
||||
{
|
||||
connect(m_server, &Websocket::on_message, this, [this](QWebSocket* conn, QString message){
|
||||
QString response = message_parser(message);
|
||||
if (response.isEmpty() || response == "{}")
|
||||
return;
|
||||
m_server->send(conn, response);
|
||||
});
|
||||
}
|
||||
|
||||
std::string Simulators::active_simulator_name() const
|
||||
@@ -59,7 +74,13 @@ void Simulators::switch_simulator(std::string name)
|
||||
return;
|
||||
}
|
||||
|
||||
this->stop();
|
||||
if (!this->m_current_simulator.empty())
|
||||
{
|
||||
disconnect(m_simulators.at(m_current_simulator).get());
|
||||
}
|
||||
this->m_current_simulator = name;
|
||||
connect(m_simulators.at(m_current_simulator).get(), &Simulator_base::sim_changed, this, [this]{m_server->broadcast(QString::fromStdString(changed_UI_items().dump()));});
|
||||
this->run();
|
||||
}
|
||||
|
||||
@@ -139,4 +160,4 @@ json Simulators::changed_UI_items()
|
||||
|
||||
m_before = after;
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user