* @brief Updates a single dataset from its channel and any registered transform. */
| 1229 | * @brief Updates a single dataset from its channel and any registered transform. |
| 1230 | */ |
| 1231 | void DataModel::FrameBuilder::applyDatasetValue(Dataset& dataset, |
| 1232 | const QString* channelData, |
| 1233 | int channelCount, |
| 1234 | const TransformFrameInfo& info, |
| 1235 | const std::unordered_map<int, int>* replayColumns) |
| 1236 | { |
| 1237 | DatasetDeps* dep = nullptr; |
| 1238 | if (m_changeDriven && dataset.virtual_ && !dataset.transformCode.isEmpty() |
| 1239 | && !SerialStudio::isFinalValuePlayerOpen()) { |
| 1240 | dep = &m_datasetDeps[dataset.uniqueId]; |
| 1241 | if (!dep->readSlots.empty() && !m_tableStore.changedSince(dep->readSlots, dep->lastRunClock)) |
| 1242 | return; |
| 1243 | } |
| 1244 | |
| 1245 | if (replayColumns) [[unlikely]] { |
| 1246 | const auto it = replayColumns->find(dataset.uniqueId); |
| 1247 | const int col = (it != replayColumns->end()) ? it->second : -1; |
| 1248 | if (col >= 0 && col < channelCount) { |
| 1249 | dataset.value = channelData[col]; |
| 1250 | dataset.numericValue = SerialStudio::toDouble(dataset.value, &dataset.isNumeric); |
| 1251 | } else { |
| 1252 | dataset.numericValue = 0.0; |
| 1253 | dataset.value.clear(); |
| 1254 | dataset.isNumeric = true; |
| 1255 | } |
| 1256 | } else if (dataset.virtual_) { |
| 1257 | dataset.numericValue = 0.0; |
| 1258 | dataset.value.clear(); |
| 1259 | dataset.isNumeric = true; |
| 1260 | } else { |
| 1261 | const int idx = dataset.index; |
| 1262 | if (idx <= 0 || idx > channelCount) [[unlikely]] |
| 1263 | return; |
| 1264 | |
| 1265 | dataset.value = channelData[idx - 1]; |
| 1266 | dataset.numericValue = SerialStudio::toDouble(dataset.value, &dataset.isNumeric); |
| 1267 | } |
| 1268 | |
| 1269 | dataset.rawNumericValue = dataset.numericValue; |
| 1270 | dataset.rawValue = dataset.value; |
| 1271 | |
| 1272 | if (m_captureDatasetValues) |
| 1273 | m_tableStore.setDatasetRaw( |
| 1274 | dataset.uniqueId, dataset.numericValue, dataset.value, dataset.isNumeric); |
| 1275 | |
| 1276 | if (!dataset.transformCode.isEmpty() && !SerialStudio::isFinalValuePlayerOpen()) [[unlikely]] { |
| 1277 | const auto input = dataset.isNumeric ? QVariant(dataset.numericValue) : QVariant(dataset.value); |
| 1278 | if (dep) |
| 1279 | m_tableStore.setReadCaptureTarget(&dep->readSlots); |
| 1280 | |
| 1281 | const auto result = applyTransform(dataset.transformLanguage, dataset.uniqueId, input, info); |
| 1282 | |
| 1283 | if (dep) { |
| 1284 | m_tableStore.setReadCaptureTarget(nullptr); |
| 1285 | dep->lastRunClock = m_tableStore.writeClock(); |
| 1286 | } |
| 1287 | |
| 1288 | if (result.typeId() == QMetaType::Double) { |
nothing calls this directly
no test coverage detected