MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setScript

Method setScript

app/src/API/Handlers/ControlScriptHandler.cpp:121–135  ·  view source on GitHub ↗

* @brief Replaces the control-script source through the project model. */

Source from the content-addressed store, hash-verified

119 * @brief Replaces the control-script source through the project model.
120 */
121API::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.

Callers

nothing calls this directly

Calls 4

setControlScriptCodeMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45
runningMethod · 0.45

Tested by

no test coverage detected