X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevicemanager.cpp;h=ac6ce6fb433da3fa29eefa9ba551c043c70f63b5;hp=883175c7752eb8cf27767a254d285da3760eb539;hb=941e22a645e89e7253f0faeb63b74ee97201dd91;hpb=83b1c8d251386ac1980284c4668cbdd8e425550f diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index 883175c7..ac6ce6fb 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -22,12 +22,17 @@ #include #include -#include +#include #include +#include #include #include +#include +#include +#include + #include #include @@ -39,6 +44,7 @@ using std::placeholders::_1; using std::placeholders::_2; using std::shared_ptr; using std::string; +using std::unique_ptr; using Glib::VariantBase; @@ -51,8 +57,24 @@ namespace pv { DeviceManager::DeviceManager(shared_ptr context) : context_(context) { - for (auto entry : context->drivers()) + unique_ptr progress(new QProgressDialog("", + QObject::tr("Cancel"), 0, context->drivers().size())); + progress->setWindowModality(Qt::WindowModal); + progress->setMinimumDuration(1); // To show the dialog immediately + + int entry_num = 1; + + for (auto entry : context->drivers()) { + progress->setLabelText(QObject::tr("Scanning for %1...") + .arg(QString::fromStdString(entry.first))); + driver_scan(entry.second, map()); + + progress->setValue(entry_num++); + QApplication::processEvents(); + if (progress->wasCanceled()) + break; + } } const shared_ptr& DeviceManager::context() const @@ -79,6 +101,18 @@ DeviceManager::driver_scan( assert(driver); + /* + * We currently only support devices that can deliver samples at + * a fixed samplerate (i.e. oscilloscopes and logic analysers). + * + * @todo Add support for non-monotonic devices (DMMs, sensors, etc). + */ + const auto keys = driver->config_keys(); + bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) | + keys.count(ConfigKey::OSCILLOSCOPE); + if (!supported_device) + return driver_devices; + // Remove any device instances from this driver from the device // list. They will not be valid after the scan. devices_.remove_if([&](shared_ptr device) {