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

Method reprocessDatasetValues

app/src/DataModel/FrameBuilder.cpp:1461–1508  ·  view source on GitHub ↗

* @brief Transform-only dataset pass for reprocessFrames(): re-applies every transform from * the dataset's retained raw value instead of fresh channels, so table-driven (virtual) * datasets pick up the current store contents without a device frame. */

Source from the content-addressed store, hash-verified

1459 * datasets pick up the current store contents without a device frame.
1460 */
1461void DataModel::FrameBuilder::reprocessDatasetValues(DataModel::Frame& frame)
1462{
1463 Q_ASSERT(m_operationMode == SerialStudio::ProjectFile);
1464 Q_ASSERT(!frame.groups.empty());
1465
1466 TransformFrameInfo info;
1467 info.sourceId = frame.sourceId;
1468 info.timestampMs = std::chrono::duration_cast<std::chrono::milliseconds>(
1469 std::chrono::steady_clock::now().time_since_epoch())
1470 .count();
1471 if (!m_transformEngines.empty())
1472 info.frameNumber = ++m_sourceFrameCounters[frame.sourceId];
1473
1474 const bool armedWatchdog = beginDatasetPass(info);
1475
1476 for (auto& group : frame.groups) {
1477 for (auto& dataset : group.datasets) {
1478 if (dataset.transformCode.isEmpty())
1479 continue;
1480
1481 QVariant input(0.0);
1482 if (!dataset.virtual_) {
1483 bool numeric = false;
1484 const double raw = SerialStudio::toDouble(dataset.rawValue, &numeric);
1485 input = numeric ? QVariant(raw) : QVariant(dataset.rawValue);
1486 }
1487
1488 const auto result = applyTransform(dataset.transformLanguage, dataset.uniqueId, input, info);
1489 if (result.typeId() == QMetaType::Double) {
1490 dataset.numericValue = SerialStudio::toDouble(result);
1491 dataset.value = QString::number(dataset.numericValue, 'g', 15);
1492 dataset.isNumeric = true;
1493 } else {
1494 dataset.value = result.toString();
1495 dataset.isNumeric = false;
1496 }
1497
1498 if (!dataset.isNumeric)
1499 dataset.numericValue = (dataset.wgtMax > dataset.wgtMin) ? dataset.wgtMin : 0.0;
1500
1501 if (m_captureDatasetValues)
1502 m_tableStore.setDatasetFinal(
1503 dataset.uniqueId, dataset.numericValue, dataset.value, dataset.isNumeric);
1504 }
1505 }
1506
1507 endDatasetPass(armedWatchdog);
1508}
1509
1510/**
1511 * @brief Writes channel values + transforms into every dataset of @p frame.

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.80
isEmptyMethod · 0.80
setDatasetFinalMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected