* @brief Set the visible plot time window in seconds */
| 347 | * @brief Set the visible plot time window in seconds |
| 348 | */ |
| 349 | API::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 |
nothing calls this directly
no test coverage detected