#include "MachineController.h" #include 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)); } }