connected to gui
This commit is contained in:
parent
42e884aced
commit
8a6e916876
7 changed files with 165 additions and 3 deletions
32
simulator_SIC_XE/gui/qt/MachineController.cpp
Normal file
32
simulator_SIC_XE/gui/qt/MachineController.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "MachineController.h"
|
||||
#include <chrono>
|
||||
|
||||
MachineController::MachineController(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
MachineController::~MachineController() {
|
||||
stop();
|
||||
}
|
||||
|
||||
void MachineController::start() {
|
||||
if (m_running.exchange(true)) return;
|
||||
m_thread = std::thread([this]{ runLoop(); });
|
||||
}
|
||||
|
||||
void MachineController::stop() {
|
||||
if (!m_running.exchange(false)) return;
|
||||
if (m_thread.joinable()) m_thread.join();
|
||||
}
|
||||
|
||||
void MachineController::step() {
|
||||
emit tick();
|
||||
}
|
||||
|
||||
void MachineController::runLoop() {
|
||||
while (m_running.load()) {
|
||||
emit tick();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue