Driver fixes.

This commit is contained in:
2026-01-09 10:47:29 +01:00
parent c81c38f780
commit 2547ed6e1c
13 changed files with 101 additions and 146 deletions

View File

@@ -124,8 +124,6 @@ void BCMainWindow::initMainWindow()
_connectButton->setDefaultAction( _connectAction);
_syncButton->setDefaultAction( _syncAction);
// besser: model::emit dataChanged
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
connect( _connectAction, &QAction::triggered, &_transmitter, &BCTransmitter::onToggleDriverConnection );
connect( _syncAction, &QAction::triggered, this, &BCMainWindow::onSyncDeviceView );
connect( _exitButton, &QToolButton::clicked, qApp, &QCoreApplication::quit );
@@ -177,29 +175,28 @@ connectIcon.addFile(":/icons/plug_connected.svg", QSize(), QIcon::Normal, QIc
void BCMainWindow::initStatusBar()
{
QStatusBar *statBar = statusBar();
BCDriverStateWidget* conState = new BCDriverStateWidget(this);
connect( &_transmitter, &BCTransmitter::driverStateChanged, conState, &BCDriverStateWidget::onDriverStateChanged );
connect( conState, &BCDriverStateWidget::clicked, _connectAction, &QAction::trigger );
statBar->addPermanentWidget(conState);
_statusBar->addPermanentWidget(conState);
conState->installEventFilter(this);
BCThemeSwitchButton* themeBtn = new BCThemeSwitchButton(this);
statBar->addPermanentWidget(themeBtn);
_statusBar->addPermanentWidget(themeBtn);
connect(themeBtn, &BCThemeSwitchButton::themeChanged, this, [this](bool isDark)
{
QString message = isDark ? "DarkMode aktiviert" : "LightMode aktiviert";
statusBar()->showMessage( message, 3000);
_statusBar->showMessage( message, 3000);
setApplicationStyleSheet( isDark ? cDarkModeStyle : cLightModeStyle );
});
// Wir starten im light mode
//themeBtn->setDarkMode( false );
statBar->showMessage("Ready");
_statusBar->showMessage("Bereit. (Dummy-Treiber eingestellt)");
setApplicationStyleSheet(cLightModeStyle);
@@ -250,27 +247,21 @@ void BCMainWindow::setHeaderLabel( const QString& headerText)
_headerLabel->setText( " BionxControl: " + headerText );
}
void BCMainWindow::onShowMessage( const QString& message, int timeOut )
{
_statusbar->showMessage( message, timeOut );
_statusBar->showMessage( message, timeOut );
}
void BCMainWindow::autoConnect()
{
// __fix!
// if( !connect)
// fallBack
}
void BCMainWindow::onDriverStateChanged( BCDriver::DriverState state, const QString& message )
{
qDebug() << " --- on DriverStatusChanged: " << state << ":" << message;
_statusbar->showMessage( message, 8000 );
Q_UNUSED(state)
_statusBar->showMessage( message, 8000 );
}
void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
{
qDebug() << " --- onShowDevicePanel:" << deviceID;
if( _devicePanels.contains( deviceID ) )
{
BCDeviceView* nxtPanel = _devicePanels[deviceID];
@@ -293,14 +284,12 @@ void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
}
void BCMainWindow::onConnectButtonToggled(bool checked )
{
//_dataManager.setDriverConnectionState( checked );
}
/**
* @brief SLOT, wird aufgerufen, wenn der Treiber eine frischen Wert abgeholt hat.
*/
void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BCValue::Flags newState, uint32_t rawValue )
{
qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << (uint8_t)newState << " on:" << rawValue;
if( _devicePanels.contains( deviceID ) )
{
BCDeviceView& panel = *_devicePanels[deviceID];
@@ -308,10 +297,15 @@ void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BCValue::Fla
}
}
/**
* @brief SLOT, wird aufgerufen, wenn der Treiber die Datenübertrgeung beendet hat.
*/
void BCMainWindow::onEndOfProcessing()
{
qDebug() << " --- END sync";
_syncButton->setEnabled( true );
_statusBar->showMessage( "Synchronisation abgeschlossen.", 3000 );
}
/**
@@ -322,30 +316,27 @@ void BCMainWindow::onEndOfProcessing()
void BCMainWindow::onSyncDeviceView()
{
Q_ASSERT_X(_currentPanel, "onSyncDeviceView()", "_currentpanel ist null!");
const BCValueList& currentList =_currentPanel->getValueListX();
const BCValueList& currentList =_currentPanel->getValueList();
// wir schalten den Button hier ab,
// wir schalten den Sync-Button hier ab,
// wenn der Autrag bearbeitet wurde, wird der
// Button wieder eingeschaltet.
_syncButton->setEnabled( false );
QString devName = _currentPanel->property( cBCKeyHeaderLabel ).toString();
_statusBar->showMessage( "Lese: " + devName, 5000 );
for( const BCValuePtr& value : currentList )
{
qDebug() << " --- ### begin sync of value: " << QThread::currentThreadId() << " : " << value->label;
// wir setzen auf 'lesen'
value->valueFlags.setFlag( BCValue::Flag::ReadMe );
_syncButton->setEnabled( false );
// statt '_transmitter.onUpdateValue( value )' müssen wir hier
// über emit requestValueUpdate() zur Thread sysnchronisation
// entkoppeln,
emit requestValueUpdate( value);
}
qDebug() << " --- sending FORWARD EOT";
emit endOfTransmission();
}