Move value flags to bcvalue class definition.

This commit is contained in:
2025-12-31 14:06:34 +01:00
parent c7a246e56d
commit ce207b7146
10 changed files with 43 additions and 47 deletions

18
bc.h
View File

@@ -119,24 +119,6 @@ struct BC
public: 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 enum class ID : uint8_t
{ {
//{%Region Console} //{%Region Console}

View File

@@ -77,7 +77,7 @@ void BCDeviceView::onValueListReady( BCDevice::ID deviceID, BCValueList valueLis
_valueModel.takeValueList( valueList ); _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); _valueModel.onValueUpdated( index,state,newVisibleValue);
_itemDelegate->onHighlightRow( index ); _itemDelegate->onHighlightRow( index );

View File

@@ -58,7 +58,7 @@ public:
public slots: public slots:
void onValueListReady( BCDevice::ID deviceID, BCValueList valueList ); 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: protected:

View File

@@ -153,7 +153,7 @@ void BCMainWindow::initMainWindow()
_transmitter.moveToThread(&_worker); _transmitter.moveToThread(&_worker);
connect(this, &BCMainWindow::sendValueCommand, &_transmitter, &BCTransmitter::enqueueValueOp); connect(this, &BCMainWindow::requestValueUpdate, &_transmitter, &BCTransmitter::enqueueValueOp);
// B) Ergebnisse empfangen (Runner -> Manager) // B) Ergebnisse empfangen (Runner -> Manager)
//connect(&_transmitter, &BCTransmitter::valueStateChanged, this, &BCDataManager::onvalueStateChanged); //connect(&_transmitter, &BCTransmitter::valueStateChanged, this, &BCDataManager::onvalueStateChanged);
@@ -221,9 +221,9 @@ void BCMainWindow::onConnectButtonToggled(bool checked )
//_dataManager.setDriverConnectionState( 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 ) ) if( _devicePanels.contains( deviceID ) )
{ {
BCDeviceView& panel = *_devicePanels[deviceID]; BCDeviceView& panel = *_devicePanels[deviceID];
@@ -249,15 +249,8 @@ void BCMainWindow::onSyncFromDevice()
qDebug() << " --- value: " << value.label; qDebug() << " --- value: " << value.label;
// statt '_transmitter.enqueueValueCommand( value )' entkoppeln // statt '_transmitter.enqueueValueCommand( value )' entkoppeln
// wir das eleganter über emit sendValueCommand() // wir das eleganter über emit requestValueUpdate()
emit requestValueUpdate( BCValue::OpID::ReadValue, &value);
//_transmitter.enqueueValueCommand( value );
emit sendValueCommand( BC::OpID::ReadValue, &value);
//emit valueTouched( value.indexRow );
bc::processEventsFor(50);
} }

View File

@@ -60,13 +60,13 @@ public slots:
void onConnectButtonToggled(bool active ); void onConnectButtonToggled(bool active );
// Slots für Rückmeldungen vom Runner // 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(); void onSyncFromDevice();
signals: signals:
// Internes Signal, um Daten an den Worker Thread zu senden // 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 valuedTouched(const BCValue& cmd);
void valueTouched(int indexRow ); void valueTouched(int indexRow );

View File

@@ -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); QMutexLocker locker(&_mutex);
_valueQueue.enqueue( value ); _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, "processValueOp", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, [this, opID]() QMetaObject::invokeMethod(this, [this, opID]()
{ {
this->processValueOp(opID); processValueOp(opID);
}, Qt::QueuedConnection ); }, Qt::QueuedConnection );
} }
void BCTransmitter::processValueOp( BC::OpID opID ) void BCTransmitter::processValueOp( BCValue::OpID opID )
{ {
if (_isBusy) if (_isBusy)
@@ -131,14 +131,14 @@ void BCTransmitter::processValueOp( BC::OpID opID )
// Abkürzung // Abkürzung
const BCValue& val = *currentValue; const BCValue& val = *currentValue;
// Value ist 'under construction' // Value ist 'under construction'
//emit valueUpdated( val.deviceID, val.indexRow, BC::State::Locked ); //emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::Locked );
if( opID == BC::OpID::ReadValue ) if( opID == BCValue::OpID::ReadValue )
{ {
QString result = currentValue->readRawValueX( *this ); 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 ); currentValue->writeRawValueX( *this );
} }
@@ -149,6 +149,9 @@ void BCTransmitter::processValueOp( BC::OpID opID )
qDebug() << " --- OUCH!"; qDebug() << " --- OUCH!";
} }
// __fix
bc::processEventsFor(50);
//emit valueStateChanged(cmd.id, true); //emit valueStateChanged(cmd.id, true);
//emit valueStateChanged(0, true); //emit valueStateChanged(0, true);
} }

View File

@@ -56,12 +56,12 @@ public:
public slots: public slots:
void onToggleConnectionState( bool connect ); void onToggleConnectionState( bool connect );
void enqueueValueOp(BC::OpID opID, const BCValue* value ); void enqueueValueOp(BCValue::OpID opID, const BCValue* value );
void processValueOp(BC::OpID opID); void processValueOp(BCValue::OpID opID);
signals: 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); void messageLogged(const QString& msg);
private: private:

View File

@@ -78,6 +78,24 @@ class BCValue
public: 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_ ); BCValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
QString readRawValueX( const BCAbstractTransmitter& transmitter ) const; QString readRawValueX( const BCAbstractTransmitter& transmitter ) const;
@@ -87,7 +105,7 @@ public:
// später // später
//protected: //protected:
mutable BC::State state{BC::State::Invalid}; mutable State state{BCValue::State::Invalid};
//const BCValueType& valueType; //const BCValueType& valueType;
//BCValueTypeCRef valueType; //BCValueTypeCRef valueType;
const BCValueType* valueType{}; const BCValueType* valueType{};

View File

@@ -93,7 +93,7 @@ void BCValueModel::takeValueList(BCValueList& newValueList)
* @param newValue Der neue sichtbare Zahlenwert, formatiert als QString, optionall * @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; qDebug() << " BCValueModel::onValueUpdated update: " << newVisisbleValue;
if( row > -1 && row < _valueList.size() ) if( row > -1 && row < _valueList.size() )

View File

@@ -69,7 +69,7 @@ public:
public slots: public slots:
void onValueUpdated(int index, BC::State state, const QString& newVisisbleValue="" ); void onValueUpdated(int index, BCValue::State state, const QString& newVisisbleValue="" );
protected: protected: