diff --git a/bc.h b/bc.h index fbaaed9..42f2917 100644 --- a/bc.h +++ b/bc.h @@ -119,24 +119,6 @@ struct BC public: - enum class OpID : uint8_t - { - ReadValue, - WriteValue, - }; - Q_ENUM(OpID) - - // __fix! flags draus machen ? - enum class State : uint8_t - { - Invalid, - Locked, - Failed, - InSync, - OK - }; - Q_ENUM(State) - enum class ID : uint8_t { //{%Region Console} diff --git a/bcdeviceview.cpp b/bcdeviceview.cpp index 5b335ee..be0eafa 100644 --- a/bcdeviceview.cpp +++ b/bcdeviceview.cpp @@ -77,7 +77,7 @@ void BCDeviceView::onValueListReady( BCDevice::ID deviceID, BCValueList valueLis _valueModel.takeValueList( valueList ); } -void BCDeviceView::onValueUpdated(int index, BC::State state, const QString& newVisibleValue ) +void BCDeviceView::onValueUpdated(int index, BCValue::State state, const QString& newVisibleValue ) { _valueModel.onValueUpdated( index,state,newVisibleValue); _itemDelegate->onHighlightRow( index ); diff --git a/bcdeviceview.h b/bcdeviceview.h index f65a4f1..c737df0 100644 --- a/bcdeviceview.h +++ b/bcdeviceview.h @@ -58,7 +58,7 @@ public: public slots: void onValueListReady( BCDevice::ID deviceID, BCValueList valueList ); - void onValueUpdated( int index, BC::State state, const QString& newVisibleValue="" ); + void onValueUpdated( int index, BCValue::State state, const QString& newVisibleValue="" ); protected: diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index e35a358..15a7bc4 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -153,7 +153,7 @@ void BCMainWindow::initMainWindow() _transmitter.moveToThread(&_worker); - connect(this, &BCMainWindow::sendValueCommand, &_transmitter, &BCTransmitter::enqueueValueOp); + connect(this, &BCMainWindow::requestValueUpdate, &_transmitter, &BCTransmitter::enqueueValueOp); // B) Ergebnisse empfangen (Runner -> Manager) //connect(&_transmitter, &BCTransmitter::valueStateChanged, this, &BCDataManager::onvalueStateChanged); @@ -221,9 +221,9 @@ void BCMainWindow::onConnectButtonToggled(bool checked ) //_dataManager.setDriverConnectionState( checked ); } -void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue ) +void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue ) { - qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << state << " on:" << newValue; + qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << (uint8_t)state << " on:" << newValue; if( _devicePanels.contains( deviceID ) ) { BCDeviceView& panel = *_devicePanels[deviceID]; @@ -249,15 +249,8 @@ void BCMainWindow::onSyncFromDevice() qDebug() << " --- value: " << value.label; // statt '_transmitter.enqueueValueCommand( value )' entkoppeln - // wir das eleganter über emit sendValueCommand() - - //_transmitter.enqueueValueCommand( value ); - emit sendValueCommand( BC::OpID::ReadValue, &value); - //emit valueTouched( value.indexRow ); - - bc::processEventsFor(50); - - + // wir das eleganter über emit requestValueUpdate() + emit requestValueUpdate( BCValue::OpID::ReadValue, &value); } diff --git a/bcmainwindow.h b/bcmainwindow.h index 6a08541..bcb89bf 100644 --- a/bcmainwindow.h +++ b/bcmainwindow.h @@ -60,13 +60,13 @@ public slots: void onConnectButtonToggled(bool active ); // Slots für Rückmeldungen vom Runner - void onValueUpdated( BCDevice::ID deviceID, int index, BC::State state, const QString& newValue="" ); + void onValueUpdated( BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" ); void onSyncFromDevice(); signals: // Internes Signal, um Daten an den Worker Thread zu senden - void sendValueCommand( BC::OpID, const BCValue* cmd); + void requestValueUpdate( BCValue::OpID, const BCValue* cmd); //void valuedTouched(const BCValue& cmd); void valueTouched(int indexRow ); diff --git a/bctransmitter.cpp b/bctransmitter.cpp index d5a501a..29db2d3 100644 --- a/bctransmitter.cpp +++ b/bctransmitter.cpp @@ -84,7 +84,7 @@ void BCTransmitter::onToggleConnectionState( bool connect ) } -void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value) +void BCTransmitter::enqueueValueOp(BCValue::OpID opID, const BCValue* value) { QMutexLocker locker(&_mutex); _valueQueue.enqueue( value ); @@ -100,11 +100,11 @@ void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value) //QMetaObject::invokeMethod(this, "processValueOp", Qt::QueuedConnection); QMetaObject::invokeMethod(this, [this, opID]() { - this->processValueOp(opID); + processValueOp(opID); }, Qt::QueuedConnection ); } -void BCTransmitter::processValueOp( BC::OpID opID ) +void BCTransmitter::processValueOp( BCValue::OpID opID ) { if (_isBusy) @@ -131,14 +131,14 @@ void BCTransmitter::processValueOp( BC::OpID opID ) // Abkürzung const BCValue& val = *currentValue; // Value ist 'under construction' - //emit valueUpdated( val.deviceID, val.indexRow, BC::State::Locked ); - if( opID == BC::OpID::ReadValue ) + //emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::Locked ); + if( opID == BCValue::OpID::ReadValue ) { QString result = currentValue->readRawValueX( *this ); - emit valueUpdated( val.deviceID, val.indexRow, BC::State::InSync, result ); + emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::InSync, result ); } - else if( opID == BC::OpID::WriteValue ) + else if( opID == BCValue::OpID::WriteValue ) { currentValue->writeRawValueX( *this ); } @@ -149,6 +149,9 @@ void BCTransmitter::processValueOp( BC::OpID opID ) qDebug() << " --- OUCH!"; } + // __fix + bc::processEventsFor(50); + //emit valueStateChanged(cmd.id, true); //emit valueStateChanged(0, true); } diff --git a/bctransmitter.h b/bctransmitter.h index 45c5eea..90db70a 100644 --- a/bctransmitter.h +++ b/bctransmitter.h @@ -56,12 +56,12 @@ public: public slots: void onToggleConnectionState( bool connect ); - void enqueueValueOp(BC::OpID opID, const BCValue* value ); - void processValueOp(BC::OpID opID); + void enqueueValueOp(BCValue::OpID opID, const BCValue* value ); + void processValueOp(BCValue::OpID opID); signals: - void valueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue="" ); + void valueUpdated(BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" ); void messageLogged(const QString& msg); private: diff --git a/bcvalue.h b/bcvalue.h index bf5d19c..310cced 100644 --- a/bcvalue.h +++ b/bcvalue.h @@ -78,6 +78,24 @@ class BCValue public: + enum class OpID : uint8_t + { + ReadValue, + WriteValue, + }; + //Q_ENUM(OpID) + + // __fix! flags draus machen ? + enum class State : uint8_t + { + Invalid, + Locked, + Failed, + InSync, + OK + }; + //Q_ENUM(State) + BCValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ ); QString readRawValueX( const BCAbstractTransmitter& transmitter ) const; @@ -87,7 +105,7 @@ public: // später //protected: - mutable BC::State state{BC::State::Invalid}; + mutable State state{BCValue::State::Invalid}; //const BCValueType& valueType; //BCValueTypeCRef valueType; const BCValueType* valueType{}; diff --git a/bcvaluemodel.cpp b/bcvaluemodel.cpp index 113e882..bde18d0 100644 --- a/bcvaluemodel.cpp +++ b/bcvaluemodel.cpp @@ -93,7 +93,7 @@ void BCValueModel::takeValueList(BCValueList& newValueList) * @param newValue Der neue sichtbare Zahlenwert, formatiert als QString, optionall */ -void BCValueModel::onValueUpdated( int row, BC::State state, const QString& newVisisbleValue ) +void BCValueModel::onValueUpdated( int row, BCValue::State state, const QString& newVisisbleValue ) { qDebug() << " BCValueModel::onValueUpdated update: " << newVisisbleValue; if( row > -1 && row < _valueList.size() ) diff --git a/bcvaluemodel.h b/bcvaluemodel.h index adda31d..d7369a3 100644 --- a/bcvaluemodel.h +++ b/bcvaluemodel.h @@ -69,7 +69,7 @@ public: public slots: - void onValueUpdated(int index, BC::State state, const QString& newVisisbleValue="" ); + void onValueUpdated(int index, BCValue::State state, const QString& newVisisbleValue="" ); protected: