X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdevicemanager.cpp;h=540f88150e4cf117be1ca1fa12762e8b734f3943;hb=e2649143f11fad802b85f124dba7ef3e81874e50;hp=f1f4c542ca227bca236f050f9e226f30c7271422;hpb=e71eb81c946c3524e01eaef9781ccbf170143d0c;p=pulseview.git
diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp
index f1f4c54..540f881 100644
--- a/pv/devicemanager.cpp
+++ b/pv/devicemanager.cpp
@@ -14,8 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see .
*/
#include "devicemanager.hpp"
@@ -23,53 +22,75 @@
#include
#include
-#include
+#include
#include
+#include
#include
-#include
#include
-#include
+#include
+#include
+#include
+
#include
#include
-using boost::algorithm::join;
-
using std::bind;
-using std::dynamic_pointer_cast;
using std::list;
using std::map;
using std::placeholders::_1;
using std::placeholders::_2;
-using std::remove_if;
-using std::runtime_error;
using std::shared_ptr;
using std::string;
-using std::vector;
+using std::unique_ptr;
using Glib::VariantBase;
using sigrok::ConfigKey;
using sigrok::Context;
using sigrok::Driver;
-using sigrok::SessionDevice;
namespace pv {
DeviceManager::DeviceManager(shared_ptr context) :
context_(context)
{
- for (auto entry : context->drivers())
- driver_scan(entry.second, map());
-}
-
-DeviceManager::~DeviceManager()
-{
+ 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)));
+
+ /**
+ * 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 i.e. DMMs
+ * and sensors.
+ */
+ const auto keys = (entry.second)->config_keys();
+
+ bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) |
+ keys.count(ConfigKey::OSCILLOSCOPE);
+
+ if (supported_device)
+ driver_scan(entry.second, map());
+
+ progress->setValue(entry_num++);
+ QApplication::processEvents();
+ if (progress->wasCanceled())
+ break;
+ }
}
-const std::shared_ptr& DeviceManager::context() const
+const shared_ptr& DeviceManager::context() const
{
return context_;
}
@@ -151,10 +172,12 @@ const shared_ptr DeviceManager::find_device_from_info(
// If present, vendor and model always have to match.
if (dev_info.count("vendor") > 0 && search_info.count("vendor") > 0)
- if (dev_info.at("vendor") != search_info.at("vendor")) continue;
+ if (dev_info.at("vendor") != search_info.at("vendor"))
+ continue;
if (dev_info.count("model") > 0 && search_info.count("model") > 0)
- if (dev_info.at("model") != search_info.at("model")) continue;
+ if (dev_info.at("model") != search_info.at("model"))
+ continue;
// Most unique match: vendor/model/serial_num (but don't match a S/N of 0)
if ((dev_info.count("serial_num") > 0) && (dev_info.at("serial_num") != "0")
@@ -189,7 +212,8 @@ const shared_ptr DeviceManager::find_device_from_info(
}
bool DeviceManager::compare_devices(shared_ptr a,
- shared_ptr b) {
+ shared_ptr b)
+{
assert(a);
assert(b);
return a->display_name(*this).compare(b->display_name(*this)) < 0;