* @brief Constructs the ConnectionManager singleton. */
| 65 | * @brief Constructs the ConnectionManager singleton. |
| 66 | */ |
| 67 | IO::ConnectionManager::ConnectionManager() |
| 68 | : m_paused(false) |
| 69 | , m_writeEnabled(true) |
| 70 | , m_syncingFromProject(false) |
| 71 | , m_busType(SerialStudio::BusType::UART) |
| 72 | , m_startSequence("/*") |
| 73 | , m_finishSequence("*/") |
| 74 | , m_replyCaptureArmed(false) |
| 75 | , m_uartUi(std::make_unique<IO::Drivers::UART>()) |
| 76 | , m_networkUi(std::make_unique<IO::Drivers::Network>()) |
| 77 | , m_bluetoothLEUi(std::make_unique<IO::Drivers::BluetoothLE>()) |
| 78 | #ifdef BUILD_COMMERCIAL |
| 79 | , m_audioUi(std::make_unique<IO::Drivers::Audio>()) |
| 80 | , m_canBusUi(std::make_unique<IO::Drivers::CANBus>()) |
| 81 | , m_hidUi(std::make_unique<IO::Drivers::HID>()) |
| 82 | , m_mqttUi(std::make_unique<IO::Drivers::MQTT>()) |
| 83 | , m_modbusUi(std::make_unique<IO::Drivers::Modbus>()) |
| 84 | , m_processUi(std::make_unique<IO::Drivers::Process>()) |
| 85 | , m_usbUi(std::make_unique<IO::Drivers::USB>()) |
| 86 | #endif |
| 87 | { |
| 88 | connect(this, &ConnectionManager::busTypeChanged, this, &ConnectionManager::configurationChanged); |
| 89 | |
| 90 | connect( |
| 91 | this, &ConnectionManager::configurationChanged, this, &ConnectionManager::connectedChanged); |
| 92 | |
| 93 | m_uiDriverSaveTimer.setSingleShot(true); |
| 94 | m_uiDriverSaveTimer.setInterval(750); |
| 95 | connect(&m_uiDriverSaveTimer, &QTimer::timeout, this, [] { |
| 96 | auto& model = DataModel::ProjectModel::instance(); |
| 97 | if (model.jsonFilePath().isEmpty()) |
| 98 | return; |
| 99 | |
| 100 | if (AppState::instance().operationMode() != SerialStudio::ProjectFile) |
| 101 | return; |
| 102 | |
| 103 | if (model.sources().size() != 1) |
| 104 | return; |
| 105 | |
| 106 | (void)model.saveJsonFile(false); |
| 107 | }); |
| 108 | |
| 109 | connect(qApp, &QApplication::aboutToQuit, this, &ConnectionManager::disconnectAllDevices); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @brief Disconnects all UI drivers and tears down active connections. |
nothing calls this directly
no test coverage detected