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

Method setTimeRange

app/src/API/Handlers/DashboardHandler.cpp:349–372  ·  view source on GitHub ↗

* @brief Set the visible plot time window in seconds */

Source from the content-addressed store, hash-verified

347 * @brief Set the visible plot time window in seconds
348 */
349API::CommandResponse API::Handlers::DashboardHandler::setTimeRange(const QString& id,
350 const QJsonObject& params)
351{
352 if (!params.contains(QStringLiteral("seconds"))) {
353 return CommandResponse::makeError(
354 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: seconds"));
355 }
356
357 const double seconds = SerialStudio::toDouble(params.value(QStringLiteral("seconds")));
358
359 if (seconds < 0.001 || seconds > 300.0) {
360 return CommandResponse::makeError(
361 id,
362 ErrorCode::InvalidParam,
363 QStringLiteral("Invalid seconds: %1. Valid range: 0.001-300").arg(seconds));
364 }
365
366 UI::Dashboard::instance().setPlotTimeRange(seconds);
367
368 QJsonObject result;
369 result[QStringLiteral("seconds")] = UI::Dashboard::instance().plotTimeRange();
370
371 return CommandResponse::makeSuccess(id, result);
372}
373
374/**
375 * @brief Get the current visible plot time window in seconds

Callers

nothing calls this directly

Calls 4

containsMethod · 0.45
valueMethod · 0.45
setPlotTimeRangeMethod · 0.45
plotTimeRangeMethod · 0.45

Tested by

no test coverage detected