MCPcopy Create free account
hub / github.com/analogdevicesinc/scopy / createDevice

Method createDevice

core/src/devicemanager.cpp:66–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66QString DeviceManager::createDevice(QString category, QString param, bool async, QList<QString> plugins)
67{
68 for(Device *val : qAsConst(map)) {
69 if(val->param() == param) {
70 return "";
71 }
72 }
73 qInfo(CAT_DEVICEMANAGER) << category << "device with params" << param << "added";
74 Q_EMIT deviceAddStarted(param);
75
76 DeviceImpl *d = DeviceFactory::build(param, category);
77 DeviceLoader *dl = new DeviceLoader(d, this);
78
79 connect(dl, &DeviceLoader::initialized, this, [=]() {
80 QList<Plugin *> availablePlugins = d->plugins();
81 if(!plugins.isEmpty()) {
82 for(Plugin *p : qAsConst(availablePlugins)) {
83 bool enablePlugin = plugins.contains(p->name());
84 p->setEnabled(enablePlugin);
85 }
86 }
87 addDevice(d);
88 }); // add device to manager once it is initialized
89 connect(dl, &DeviceLoader::initialized, dl,
90 &QObject::deleteLater); // don't forget to delete loader once we're done
91 dl->init(async);
92
93 return d->id();
94}
95
96// This is only used by scan context collector - should I rethink this ?
97// Map all devices to uris in scan context collector

Callers 1

addDeviceMethod · 0.80

Calls 8

pluginsMethod · 0.80
connectFunction · 0.50
paramMethod · 0.45
containsMethod · 0.45
nameMethod · 0.45
setEnabledMethod · 0.45
initMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected