connected to gui

This commit is contained in:
zanostro 2025-11-12 19:05:16 +01:00
parent 42e884aced
commit 8a6e916876
7 changed files with 165 additions and 3 deletions

View 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));
}
}