* @brief Get all dashboard configuration settings */
| 391 | * @brief Get all dashboard configuration settings |
| 392 | */ |
| 393 | API::CommandResponse API::Handlers::DashboardHandler::getStatus(const QString& id, |
| 394 | const QJsonObject& params) |
| 395 | { |
| 396 | Q_UNUSED(params) |
| 397 | |
| 398 | const auto mode = AppState::instance().operationMode(); |
| 399 | const int modeIndex = static_cast<int>(mode); |
| 400 | const int fps = Misc::TimerEvents::instance().fps(); |
| 401 | const double timeRange = UI::Dashboard::instance().plotTimeRange(); |
| 402 | const int widgetCnt = UI::Dashboard::instance().totalWidgetCount(); |
| 403 | const int datasetCnt = static_cast<int>(UI::Dashboard::instance().datasets().size()); |
| 404 | const bool running = UI::Dashboard::instance().streamAvailable(); |
| 405 | |
| 406 | QJsonObject result; |
| 407 | result[QStringLiteral("operationMode")] = modeIndex; |
| 408 | result[QStringLiteral("operationModeLabel")] = API::EnumLabels::operationModeLabel(modeIndex); |
| 409 | result[QStringLiteral("operationModeSlug")] = API::EnumLabels::operationModeSlug(modeIndex); |
| 410 | |
| 411 | static const QStringList kModeNames = { |
| 412 | QStringLiteral("ProjectFile"), QStringLiteral("ConsoleOnly"), QStringLiteral("QuickPlot")}; |
| 413 | result[QStringLiteral("operationModeName")] = (modeIndex >= 0 && modeIndex < kModeNames.size()) |
| 414 | ? kModeNames[modeIndex] |
| 415 | : QStringLiteral("Unknown"); |
| 416 | result[QStringLiteral("fps")] = fps; |
| 417 | result[QStringLiteral("timeRange")] = timeRange; |
| 418 | result[QStringLiteral("widgetCount")] = widgetCnt; |
| 419 | result[QStringLiteral("datasetCount")] = datasetCnt; |
| 420 | result[QStringLiteral("running")] = running; |
| 421 | |
| 422 | result[QStringLiteral("_summary")] = |
| 423 | QStringLiteral("Dashboard mode: %1. %2 widget%3 visible across %4 dataset%5, " |
| 424 | "rendering at %6 fps over a %7 s plot window.") |
| 425 | .arg(API::EnumLabels::operationModeLabel(modeIndex)) |
| 426 | .arg(widgetCnt) |
| 427 | .arg(widgetCnt == 1 ? QString() : QStringLiteral("s")) |
| 428 | .arg(datasetCnt) |
| 429 | .arg(datasetCnt == 1 ? QString() : QStringLiteral("s")) |
| 430 | .arg(fps) |
| 431 | .arg(timeRange); |
| 432 | |
| 433 | return CommandResponse::makeSuccess(id, result); |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * @brief Get dashboard widget counts and latest processed frame data |
nothing calls this directly
no test coverage detected