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

Method setProgress

app/src/API/Handlers/CSVPlayerHandler.cpp:262–282  ·  view source on GitHub ↗

* @brief Seek to position */

Source from the content-addressed store, hash-verified

260 * @brief Seek to position
261 */
262API::CommandResponse API::Handlers::CSVPlayerHandler::setProgress(const QString& id,
263 const QJsonObject& params)
264{
265 if (!params.contains(QStringLiteral("progress"))) {
266 return CommandResponse::makeError(
267 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: progress"));
268 }
269
270 const double progress = SerialStudio::toDouble(params.value(QStringLiteral("progress")));
271 if (progress < 0.0 || progress > 1.0) {
272 return CommandResponse::makeError(
273 id, ErrorCode::InvalidParam, QStringLiteral("progress must be between 0.0 and 1.0"));
274 }
275
276 CSV::Player::instance().setProgress(progress);
277
278 QJsonObject result;
279 result[QStringLiteral("progress")] = CSV::Player::instance().progress();
280 result[QStringLiteral("framePosition")] = CSV::Player::instance().framePosition();
281 return CommandResponse::makeSuccess(id, result);
282}
283
284//--------------------------------------------------------------------------------------------------
285// Getters

Callers

nothing calls this directly

Calls 4

containsMethod · 0.45
valueMethod · 0.45
progressMethod · 0.45
framePositionMethod · 0.45

Tested by

no test coverage detected