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

Method reconfigureReader

app/src/UI/Widgets/ImageView.cpp:513–549  ·  view source on GitHub ↗

* @brief Destroys the current @c ImageFrameReader and creates a new one with the latest delimiter * configuration from the project model. */

Source from the content-addressed store, hash-verified

511 * configuration from the project model.
512 */
513void Widgets::ImageView::reconfigureReader()
514{
515 Q_ASSERT(m_index >= 0);
516 Q_ASSERT(!m_providerKey.isEmpty());
517
518 if (m_reader) {
519 m_reader->deleteLater();
520 m_reader = nullptr;
521 }
522
523 auto* driver = IO::ConnectionManager::instance().driver(m_sourceId);
524 if (!driver)
525 return;
526
527 QString mode;
528 QString startHex;
529 QString endHex;
530
531 if (VALIDATE_WIDGET(SerialStudio::DashboardImageView, m_index)) {
532 const auto& group = GET_GROUP(SerialStudio::DashboardImageView, m_index);
533 mode = group.imgDetectionMode;
534 startHex = group.imgStartSequence;
535 endHex = group.imgEndSequence;
536 }
537
538 if (mode == QLatin1String("manual") && !startHex.isEmpty() && !endHex.isEmpty()) {
539 m_reader = new ImageFrameReader(
540 SerialStudio::hexToBytes(startHex), SerialStudio::hexToBytes(endHex), this);
541 } else {
542 m_reader = new ImageFrameReader(this);
543 }
544
545 connect(driver, &IO::HAL_Driver::dataReceived, m_reader, &ImageFrameReader::processData);
546
547 connect(
548 m_reader, &ImageFrameReader::frameReady, this, &ImageView::onFrameReady, Qt::QueuedConnection);
549}
550
551/**
552 * @brief Identifies the image format from the first few bytes of @p data.

Callers

nothing calls this directly

Calls 3

VALIDATE_WIDGETFunction · 0.85
isEmptyMethod · 0.80
driverMethod · 0.45

Tested by

no test coverage detected