Document I/O driver initialization code

This commit is contained in:
Alex Spataru 2022-05-01 02:52:34 -05:00
parent 86e7d580c0
commit caefd8a480
4 changed files with 27 additions and 2 deletions

View File

@ -43,15 +43,22 @@ IO::Drivers::BluetoothLE::BluetoothLE()
, m_controller(Q_NULLPTR)
{
// clang-format off
// Update connect button status when a BLE device is selected by the user
connect(this, &IO::Drivers::BluetoothLE::deviceIndexChanged,
this, &IO::Drivers::BluetoothLE::configurationChanged);
// Register discovered devices
connect(&m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
this, &IO::Drivers::BluetoothLE::onDeviceDiscovered);
// Report BLE discovery errors
connect(&m_discoveryAgent,
static_cast<void (QBluetoothDeviceDiscoveryAgent::*)(
QBluetoothDeviceDiscoveryAgent::Error)>(
&QBluetoothDeviceDiscoveryAgent::error),
this, &IO::Drivers::BluetoothLE::onDiscoveryError);
// clang-format on
}

View File

@ -38,6 +38,7 @@ IO::Drivers::Network::Network()
, m_lookupActive(false)
, m_udpIgnoreFrameSequences(false)
{
// Set initial configuration
setRemoteAddress("");
setTcpPort(defaultTcpPort());
setUdpLocalPort(defaultUdpLocalPort());
@ -45,12 +46,16 @@ IO::Drivers::Network::Network()
setSocketType(QAbstractSocket::TcpSocket);
// clang-format off
// Update connect button status when the configuration is changed
connect(this, &IO::Drivers::Network::addressChanged,
this, &IO::Drivers::Network::configurationChanged);
connect(this, &IO::Drivers::Network::socketTypeChanged,
this, &IO::Drivers::Network::configurationChanged);
connect(this, &IO::Drivers::Network::portChanged,
this, &IO::Drivers::Network::configurationChanged);
// Report socket errors
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
connect(&m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(onErrorOccurred(QAbstractSocket::SocketError)));
@ -62,6 +67,7 @@ IO::Drivers::Network::Network()
connect(&m_udpSocket, &QUdpSocket::errorOccurred,
this, &IO::Drivers::Network::onErrorOccurred);
#endif
// clang-format on
}

View File

@ -50,12 +50,16 @@ IO::Drivers::Serial::Serial()
setParity(parityList().indexOf(tr("None")));
setFlowControl(flowControlList().indexOf(tr("None")));
// Build serial devices list and refresh it every second
// clang-format off
// Build serial devices list and refresh it every second
connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout1Hz,
this, &IO::Drivers::Serial::refreshSerialDevices);
// Update connect button status when user selects a serial device
connect(this, &IO::Drivers::Serial::portIndexChanged,
this, &IO::Drivers::Serial::configurationChanged);
// clang-format on
}

View File

@ -63,9 +63,17 @@ IO::Manager::Manager()
, m_finishSequence("*/")
, m_separatorSequence(",")
{
// Set initial settings
setMaxBufferSize(1024 * 1024);
setSelectedDriver(SelectedDriver::Serial);
connect(this, SIGNAL(selectedDriverChanged()), this, SIGNAL(configurationChanged()));
// clang-format off
// Update connect button status when device type is changed
connect(this, &IO::Manager::selectedDriverChanged,
this, &IO::Manager::configurationChanged);
// clang-format on
}
/**