* @brief Replaces the control-script source through the project model. */
| 119 | * @brief Replaces the control-script source through the project model. |
| 120 | */ |
| 121 | API::CommandResponse API::Handlers::ControlScriptHandler::setScript(const QString& id, |
| 122 | const QJsonObject& params) |
| 123 | { |
| 124 | if (!params.contains(QStringLiteral("code"))) { |
| 125 | return CommandResponse::makeError( |
| 126 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: code")); |
| 127 | } |
| 128 | |
| 129 | const QString code = params.value(QStringLiteral("code")).toString(); |
| 130 | DataModel::ProjectModel::instance().setControlScriptCode(code); |
| 131 | |
| 132 | QJsonObject result; |
| 133 | result[QStringLiteral("running")] = DataModel::ControlScript::instance().running(); |
| 134 | return CommandResponse::makeSuccess(id, result); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @brief Returns the running state of the control script. |
nothing calls this directly
no test coverage detected