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

Method buildDeviceForSource

app/src/IO/ConnectionManager.cpp:1217–1242  ·  view source on GitHub ↗

* @brief Constructs a DeviceManager for one project source and stores it in m_devices. */

Source from the content-addressed store, hash-verified

1215 * @brief Constructs a DeviceManager for one project source and stores it in m_devices.
1216 */
1217void IO::ConnectionManager::buildDeviceForSource(const DataModel::Source& src,
1218 bool willRebuildDevice0)
1219{
1220 if (src.sourceId == 0 && !willRebuildDevice0)
1221 return;
1222
1223 auto driver = createDriver(static_cast<SerialStudio::BusType>(src.busType));
1224 if (!driver)
1225 return;
1226
1227 if (!src.connectionSettings.isEmpty())
1228 driver->applyConnectionSettings(src.connectionSettings);
1229
1230 auto* rawDriver = driver.get();
1231 auto dm = std::make_unique<DeviceManager>(
1232 src.sourceId, std::move(driver), buildFrameConfig(src.sourceId), this);
1233
1234 connect(rawDriver,
1235 &IO::HAL_Driver::configurationChanged,
1236 this,
1237 &IO::ConnectionManager::configurationChanged,
1238 Qt::UniqueConnection);
1239
1240 wireDevice(dm.get());
1241 m_devices[src.sourceId] = std::move(dm);
1242}
1243
1244/**
1245 * @brief Rebuilds DeviceManagers for all sources when the project source list changes.

Callers

nothing calls this directly

Calls 3

isEmptyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected