| 986 | } |
| 987 | |
| 988 | void HyperAPI::handleLutCalibrationCommand(const QJsonObject& message, const QString& command, int tan) |
| 989 | { |
| 990 | QString subcommand = message["subcommand"].toString(""); |
| 991 | |
| 992 | if (subcommand == "capture") |
| 993 | { |
| 994 | bool debug = message["debug"].toBool(false); |
| 995 | bool lchCorrection = message["lch_correction"].toBool(false); |
| 996 | |
| 997 | QThread* lutThread = new QThread(); |
| 998 | LutCalibrator* lutCalibrator = new LutCalibrator(_instanceManager->getRootPath(), getActiveComponent(), debug, lchCorrection); |
| 999 | lutCalibrator->moveToThread(lutThread); |
| 1000 | connect(lutThread, &QThread::finished, lutCalibrator, &LutCalibrator::deleteLater); |
| 1001 | connect(lutThread, &QThread::started, lutCalibrator, &LutCalibrator::startHandler); |
| 1002 | connect(lutCalibrator, &LutCalibrator::SignalLutCalibrationUpdated, this, &CallbackAPI::lutCalibrationUpdateHandler); |
| 1003 | |
| 1004 | _lutCalibratorThread = std::unique_ptr<QThread, std::function<void(QThread*)>>(lutThread, |
| 1005 | [lutCalibrator](QThread* mqttThread) { |
| 1006 | lutCalibrator->cancelCalibrationSafe(); |
| 1007 | THREAD_REMOVER(QString("LutCalibrator"), mqttThread, lutCalibrator); |
| 1008 | }); |
| 1009 | _lutCalibratorThread->start(); |
| 1010 | } |
| 1011 | else if (_lutCalibratorThread != nullptr && subcommand == "stop") |
| 1012 | { |
| 1013 | _lutCalibratorThread = nullptr; |
| 1014 | } |
| 1015 | else |
| 1016 | { |
| 1017 | sendErrorReply("The command does not have any effect", command + "-" + subcommand, tan); |
| 1018 | return; |
| 1019 | } |
| 1020 | |
| 1021 | sendSuccessReply(command, tan); |
| 1022 | } |
| 1023 | |
| 1024 | void HyperAPI::handleInstanceCommand(const QJsonObject& message, const QString& command, int tan) |
| 1025 | { |
nothing calls this directly
no test coverage detected