* @brief Returns a register's live value by handle; found=false for a stale or invalid handle. */
| 762 | * @brief Returns a register's live value by handle; found=false for a stale or invalid handle. |
| 763 | */ |
| 764 | API::CommandResponse API::Handlers::DataTablesHandler::valueGetH(const QString& id, |
| 765 | const QJsonObject& params) |
| 766 | { |
| 767 | if (!params.contains(QStringLiteral("handle"))) |
| 768 | return CommandResponse::makeError( |
| 769 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: handle")); |
| 770 | |
| 771 | const qint64 handle = |
| 772 | static_cast<qint64>(SerialStudio::toDouble(params.value(QStringLiteral("handle")))); |
| 773 | |
| 774 | const auto& store = DataModel::FrameBuilder::instance().tableStore(); |
| 775 | if (!store.isInitialized()) |
| 776 | return CommandResponse::makeError( |
| 777 | id, ErrorCode::InvalidParam, QStringLiteral("Data-table store not initialized (no project)")); |
| 778 | |
| 779 | const auto* value = store.getByHandle(handle); |
| 780 | |
| 781 | QJsonObject result; |
| 782 | result[QStringLiteral("handle")] = static_cast<double>(handle); |
| 783 | result[QStringLiteral("found")] = (value != nullptr); |
| 784 | result[QStringLiteral("value")] = QJsonValue(); |
| 785 | if (value) { |
| 786 | result[QStringLiteral("isNumeric")] = value->isNumeric; |
| 787 | result[QStringLiteral("value")] = |
| 788 | value->isNumeric ? QJsonValue(value->numericValue) : QJsonValue(value->stringValue); |
| 789 | } |
| 790 | |
| 791 | return CommandResponse::makeSuccess(id, result); |
| 792 | } |
| 793 | |
| 794 | /** |
| 795 | * @brief Writes a register's live value by handle; written=false for stale/invalid/constant. |
nothing calls this directly
no test coverage detected