diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index 349a1eb..568f27f 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -164,17 +164,21 @@ void BCMainWindow::initMainWindow() _worker.start(); - - // die Daten des eBikes laden _dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1); _consoleAction->trigger(); + connect( &_transmitter, &BCTransmitter::driverStateChanged, this, &BCMainWindow::onDriverStateChanged ); - // --- STATUSBAR SETUP --- + +} + +void BCMainWindow::initStatusBar() +{ + // __fix QStatusBar *statBar = statusBar(); - // Optional: Normale Nachricht links + // Optional: Normale Nachricht links statBar->showMessage("Ready"); // 1. Unseren Switcher erstellen @@ -199,6 +203,18 @@ void BCMainWindow::initMainWindow() } +void BCMainWindow::autoConnect() +{ + // __fix! + // if( !connect) + // fallBack +} + +void BCMainWindow::onDriverStateChanged( BCDriver::DriverState state, const QString& message ) +{ + qDebug() << " --- on DriverStatusChanged: " << state << ":" << message; +} + void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID ) { qDebug() << " --- onShowDevicePanel:" << deviceID; diff --git a/bcmainwindow.h b/bcmainwindow.h index 3792de2..02b2358 100644 --- a/bcmainwindow.h +++ b/bcmainwindow.h @@ -56,6 +56,7 @@ public slots: //void onValueListReady( BCDevice::ID deviceID ); void onShowDevicePanel( BCDevice::ID deviceID ); void onConnectButtonToggled(bool active ); + void onDriverStateChanged( BCDriver::DriverState state, const QString& message="" ); // Slots für Rückmeldungen vom Runner void onValueUpdated( BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" ); @@ -69,6 +70,8 @@ signals: protected: void initMainWindow(); + void initStatusBar(); + void autoConnect(); BCXmlLoader _dataManager; diff --git a/bctransmitter.cpp b/bctransmitter.cpp index 25724a2..a7cb4f5 100644 --- a/bctransmitter.cpp +++ b/bctransmitter.cpp @@ -39,8 +39,10 @@ BCTransmitter::BCTransmitter(QObject *parent) : QObject(parent), _isBusy(false) { - _canDriver = new BCDriverTinyCan{this}; - //_canDriver = new BCDriverDummy{this}; + //_canDriver = new BCDriverTinyCan{this}; + _canDriver = new BCDriverDummy{this}; + // forward driver state + connect( _canDriver, &BCDriver::driverStateChanged, this, &BCTransmitter::driverStateChanged ); } @@ -82,11 +84,14 @@ void BCTransmitter::enqueueValue( BCValuePtrConst value) // invokeMethod mit QueuedConnection entkoppelt den Aufruf, // damit enqueueValue sofort zurückkehrt (non-blocking für den Aufrufer). - //QMetaObject::invokeMethod(this, "processValue", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "processValue", Qt::QueuedConnection); + + /* QMetaObject::invokeMethod(this, [this]() { processValue(); }, Qt::QueuedConnection ); + */ } void BCTransmitter::processValue() @@ -114,13 +119,15 @@ void BCTransmitter::processValue() const BCValue& value = *(valuePtr.get()); // Value ist 'under construction' - //emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::Locked ); - + //emit valueUpdated( value.deviceID, value.indexRow, BCValue::State::Locked ); const BCValueType& valueType = *value.valueType; uint32_t devID = static_cast(value.deviceID); uint8_t regID = static_cast (value.registerID); + QString newVisibleValue; + BCValue::State newState = BCValue::State::NoState; + if(value.state.testFlag( BCValue::State::WriteMe ) ) { @@ -135,11 +142,18 @@ void BCTransmitter::processValue() // wir sind hier im anderen thread! nicht einfach so reinschreiben, nur lesen TransmitResult result = valueType.readValueFunc( *this, devID, regID ); if( result.has_value() ) + { newVisibleValue = valueType.formatValue( result.value() ); - //emit valueUpdated( value.deviceID, value.indexRow, BCValue::State::InSync, result ); + newState = BCValue::State::InSync; + } + else + { + newState = BCValue::State::Failed; + } + } - // emit valueUpdated( value->deviceID, value->indexRow, BCValue::State::InSync, "fitze!"); + emit valueUpdated( value.deviceID, value.indexRow, newState, newVisibleValue ); // __fix bc::processEventsFor(50); diff --git a/bctransmitter.h b/bctransmitter.h index 5924958..be420e8 100644 --- a/bctransmitter.h +++ b/bctransmitter.h @@ -86,6 +86,7 @@ private: QMutex _mutex; std::atomic _isBusy{ false }; + // __fix! set two BCDriver* _canDriver{}; }; diff --git a/bcvalue.h b/bcvalue.h index 98bd6a1..70823ac 100644 --- a/bcvalue.h +++ b/bcvalue.h @@ -58,7 +58,7 @@ -class BCValueType; +struct BCValueType; class BCValue { diff --git a/doc/bbi_battery.txr.txt b/doc/bbi_battery.txt similarity index 100% rename from doc/bbi_battery.txr.txt rename to doc/bbi_battery.txt diff --git a/doc/challenges.txt b/doc/challenges.txt new file mode 100644 index 0000000..638ae24 --- /dev/null +++ b/doc/challenges.txt @@ -0,0 +1,45 @@ +Challenges + +------------------------------------------------------------------------------------------------- + + +Aufgabe: + +Ansatz: + +------------------------------------------------------------------------------------------------- + + +Aufgabe: + +Ansatz: + +------------------------------------------------------------------------------------------------- + + +Aufgabe: + +Ansatz: + +------------------------------------------------------------------------------------------------- + + +Aufgabe: + +Ansatz: + +------------------------------------------------------------------------------------------------- + + +Aufgabe: + +Ansatz: + +------------------------------------------------------------------------------------------------- + + +Aufgabe: + +Ansatz: + +-------------------------------------------------------------------------------------------------